|
|
|
@ -49,7 +49,7 @@ function isDeliverable(number, street) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveNote(id) {
|
|
|
|
|
function saveNote(id) {
|
|
|
|
|
var exists = false;
|
|
|
|
|
var index = -1;
|
|
|
|
|
for (var i = 0; i < notes.length; i++) {
|
|
|
|
@ -63,6 +63,8 @@ function saveNote(id) {
|
|
|
|
|
id: id,
|
|
|
|
|
number: "",
|
|
|
|
|
street: "",
|
|
|
|
|
zipcode: "",
|
|
|
|
|
route: "",
|
|
|
|
|
notes: "",
|
|
|
|
|
toggles: {}
|
|
|
|
|
};
|
|
|
|
@ -70,9 +72,31 @@ function saveNote(id) {
|
|
|
|
|
note = notes[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
note.number = $("input[name=number]").val();
|
|
|
|
|
note.street = $("input[name=street]").val();
|
|
|
|
|
note.notes = $("textarea#notes").val();
|
|
|
|
|
note.number = $("input[name=number]").val().trim();
|
|
|
|
|
note.street = $("input[name=street]").val().trim();
|
|
|
|
|
note.zipcode = $("input[name=zipcode]").val().trim();
|
|
|
|
|
note.route = $("input[name=route]").val().trim().toUpperCase();
|
|
|
|
|
note.notes = $("textarea#notes").val().trim();
|
|
|
|
|
|
|
|
|
|
if (note.number == "") {
|
|
|
|
|
app.dialog.alert("Fill in an address number.", "Error");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (note.street == "") {
|
|
|
|
|
app.dialog.alert("Fill in a street.", "Error");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (note.zipcode == "") {
|
|
|
|
|
app.dialog.alert("Fill in a zip code.", "Error");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (note.route == "" || /^[CRHG][0-9]{3}$/.test(note.route) != true) {
|
|
|
|
|
app.dialog.alert("Fill in a route (examples: C123, R001, H050).", "Error");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setStorage("lastrouteid", note.route);
|
|
|
|
|
setStorage("zipcode", note.zipcode);
|
|
|
|
|
|
|
|
|
|
for (i in SETTINGS.routenotetoggles) {
|
|
|
|
|
var toggle = SETTINGS.routenotetoggles[i];
|
|
|
|
@ -148,6 +172,12 @@ $(".view-main").on("click", ".deletenotebtn", function () {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(".view-main").on("blur", "#notenumberinput,#notestreetinput", function () {
|
|
|
|
|
if (findNote($("#notenumberinput").val(), $("#notestreetinput").val()) != null) {
|
|
|
|
|
app.dialog.alert("A note already exists for that address.", "Warning");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function getToggleName(id) {
|
|
|
|
|
for (i in SETTINGS.routenotetoggles) {
|
|
|
|
|
if (SETTINGS.routenotetoggles[i].id == id) {
|
|
|
|
@ -157,10 +187,23 @@ function getToggleName(id) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getToggleIcon(id) {
|
|
|
|
|
for (i in SETTINGS.routenotetoggles) {
|
|
|
|
|
if (SETTINGS.routenotetoggles[i].id == id) {
|
|
|
|
|
return SETTINGS.routenotetoggles[i].icon;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Template7.registerHelper('notetogglename', function (key) {
|
|
|
|
|
return getToggleName(key);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template7.registerHelper('notetoggleicon', function (key) {
|
|
|
|
|
return getToggleIcon(key);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template7.registerHelper('newlinestobr', function (text) {
|
|
|
|
|
return text.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
|
|
|
});
|