Remove extra console logging and improve what's left behind, fix map reload errors
This commit is contained in:
parent
91e31c449e
commit
a0cbb0dbe5
@ -112,12 +112,12 @@ function searchAutofillByStreet(q) {
|
|||||||
return b[1] - a[1];
|
return b[1] - a[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(sortedDB);
|
//console.log(sortedDB);
|
||||||
|
|
||||||
q = q.toLowerCase();
|
q = q.toLowerCase();
|
||||||
|
|
||||||
for (var i = 0; i < sortedDB.length; i++) {
|
for (var i = 0; i < sortedDB.length; i++) {
|
||||||
console.log(sortedDB[i][0].toLowerCase().indexOf(q));
|
//console.log(sortedDB[i][0].toLowerCase().indexOf(q));
|
||||||
if (sortedDB[i][0].toLowerCase().includes(q)) {
|
if (sortedDB[i][0].toLowerCase().includes(q)) {
|
||||||
streets.push(sortedDB[i][0]);
|
streets.push(sortedDB[i][0]);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ $(".view-main").on("click", "#addresslist .package-list-item .directions-btn", f
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(".view-main").on("swipeout:delete", "#addresslist .package-list-item", function () {
|
$(".view-main").on("swipeout:delete", "#addresslist .package-list-item", function () {
|
||||||
console.log("Deleting package", $(this).data("packageid"));
|
console.log("Info", "Deleting package", $(this).data("packageid"));
|
||||||
deletePackage($(this).data("packageid"));
|
deletePackage($(this).data("packageid"));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ function loadPackageList(sortType) {
|
|||||||
var anum = parseInt(a.value.address.split(" ", 1)[0], 10);
|
var anum = parseInt(a.value.address.split(" ", 1)[0], 10);
|
||||||
var bnum = parseInt(b.value.address.split(" ", 1)[0], 10);
|
var bnum = parseInt(b.value.address.split(" ", 1)[0], 10);
|
||||||
|
|
||||||
console.log("aalpha", aalpha);
|
//console.log("aalpha", aalpha);
|
||||||
console.log("balpha", balpha);
|
//console.log("balpha", balpha);
|
||||||
switch (sortType) {
|
switch (sortType) {
|
||||||
case "alpha_desc":
|
case "alpha_desc":
|
||||||
if (aalpha > balpha) {
|
if (aalpha > balpha) {
|
||||||
|
@ -100,7 +100,7 @@ if ("geolocation" in navigator) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
geoerrorcount++;
|
geoerrorcount++;
|
||||||
console.log("Geolocation error #" + geoerrorcount + ": ", error);
|
console.log("Warn", "Geolocation error #" + geoerrorcount + ": ", error);
|
||||||
// Stop showing error toasts if they're happening a lot
|
// Stop showing error toasts if they're happening a lot
|
||||||
if (geoerrorcount <= 3) {
|
if (geoerrorcount <= 3) {
|
||||||
app.toast.show({
|
app.toast.show({
|
||||||
|
@ -63,10 +63,7 @@ router.on("pageInit", function (pagedata) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.on("routeChange", function (newRoute) {
|
router.on("routeChange", function (newRoute) {
|
||||||
console.log(newRoute);
|
console.log("Info", "Navigating to ", newRoute.path);
|
||||||
if (newRoute == "home") {
|
|
||||||
router.refreshPage();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set alert radius to 100 meters by default
|
// Set alert radius to 100 meters by default
|
||||||
|
@ -66,9 +66,9 @@ $("#addpackagebtn").click(function () {
|
|||||||
$(".view-main").off("click", "#historylist .history-list-item");
|
$(".view-main").off("click", "#historylist .history-list-item");
|
||||||
|
|
||||||
$(".view-main").on("click", "#historylist .history-list-item", function () {
|
$(".view-main").on("click", "#historylist .history-list-item", function () {
|
||||||
console.log("Asking to delete ", $(this).data("package"));
|
console.log("Info", "Asking to delete ", $(this).data("package"));
|
||||||
confirmDeletePackage(getPackage($(this).data("package")), function (id) {
|
confirmDeletePackage(getPackage($(this).data("package")), function (id) {
|
||||||
console.log("Removing history item", id);
|
console.log("Info", "Removing history item", id);
|
||||||
$('#historylist .history-list-item[data-package="' + id + '"]').remove();
|
$('#historylist .history-list-item[data-package="' + id + '"]').remove();
|
||||||
if ($('#historylist .history-list-item').length == 0) {
|
if ($('#historylist .history-list-item').length == 0) {
|
||||||
$("#no-history").removeClass("display-none");
|
$("#no-history").removeClass("display-none");
|
||||||
|
@ -17,7 +17,7 @@ function createMap() {
|
|||||||
if (mapboxgl.supported()) {
|
if (mapboxgl.supported()) {
|
||||||
map = mapboxMap();
|
map = mapboxMap();
|
||||||
} else {
|
} else {
|
||||||
console.log("Warning: mapbox-gl not supported, falling back to Leaflet");
|
console.log("Warn", "mapbox-gl not supported, falling back to Leaflet");
|
||||||
maptype = "leaflet";
|
maptype = "leaflet";
|
||||||
map = leafletMap();
|
map = leafletMap();
|
||||||
}
|
}
|
||||||
@ -44,17 +44,22 @@ function reloadMap() {
|
|||||||
map.off();
|
map.off();
|
||||||
map.remove();
|
map.remove();
|
||||||
map = null;
|
map = null;
|
||||||
createMap();
|
|
||||||
|
|
||||||
if (map.maptype == "mapbox") {
|
if (document.getElementById("mapbox") != null) {
|
||||||
map.jumpTo({
|
createMap();
|
||||||
center: mapcenter,
|
|
||||||
zoom: mapzoom,
|
if (map.maptype == "mapbox") {
|
||||||
bearing: mapbearing,
|
map.jumpTo({
|
||||||
pitch: mappitch
|
center: mapcenter,
|
||||||
});
|
zoom: mapzoom,
|
||||||
|
bearing: mapbearing,
|
||||||
|
pitch: mappitch
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
map.setView(mapcenter, mapzoom);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
map.setView(mapcenter, mapzoom);
|
console.log("Info", "Not re-creating map because #mapbox is not in DOM. Creation will be automatically triggered when map page is loaded.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
createMap();
|
createMap();
|
||||||
@ -80,12 +85,12 @@ function openPackageInfoSheet(coordid, refreshOnly) {
|
|||||||
refreshOnly = false;
|
refreshOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Packages array: ", packages);
|
//console.log("Packages array: ", packages);
|
||||||
|
|
||||||
for (var i = 0; i < packages.length; i++) {
|
for (var i = 0; i < packages.length; i++) {
|
||||||
if (packages[i].id == coordid) {
|
if (packages[i].id == coordid) {
|
||||||
package = packages[i];
|
package = packages[i];
|
||||||
console.log("Single Address:", package);
|
//console.log("Single Address:", package);
|
||||||
|
|
||||||
$("#package-info-get-directions").attr("href", "geo:" + package.coords[0] + "," + package.coords[1]);
|
$("#package-info-get-directions").attr("href", "geo:" + package.coords[0] + "," + package.coords[1]);
|
||||||
$("#package-info-sheet-inner .list ul").html("");
|
$("#package-info-sheet-inner .list ul").html("");
|
||||||
|
@ -67,7 +67,7 @@ function leafletMap() {
|
|||||||
map.updatePackageLayer = function (data) {
|
map.updatePackageLayer = function (data) {
|
||||||
map.packagelayer.clearLayers();
|
map.packagelayer.clearLayers();
|
||||||
|
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
// JavaScript variable scope and anonymous functions are dumb
|
// JavaScript variable scope and anonymous functions are dumb
|
||||||
@ -75,7 +75,7 @@ function leafletMap() {
|
|||||||
// of the loop, or something like that
|
// of the loop, or something like that
|
||||||
(function (datai) {
|
(function (datai) {
|
||||||
var iconName = getMapIconForItems(datai.items);
|
var iconName = getMapIconForItems(datai.items);
|
||||||
console.log(iconName);
|
//console.log(iconName);
|
||||||
|
|
||||||
var icon = L.icon({
|
var icon = L.icon({
|
||||||
iconUrl: "assets/images/" + iconName + ".png",
|
iconUrl: "assets/images/" + iconName + ".png",
|
||||||
|
@ -91,7 +91,7 @@ function mapboxMap() {
|
|||||||
// of the loop, or something like that
|
// of the loop, or something like that
|
||||||
(function (datai) {
|
(function (datai) {
|
||||||
var iconName = getMapIconForItems(datai.items);
|
var iconName = getMapIconForItems(datai.items);
|
||||||
console.log(iconName);
|
//console.log(iconName);
|
||||||
|
|
||||||
var el = document.createElement("div");
|
var el = document.createElement("div");
|
||||||
el.className = "package-marker";
|
el.className = "package-marker";
|
||||||
|
@ -65,16 +65,16 @@ function getMapIconForItems(items) {
|
|||||||
// Count how many types we have, and set/overwrite the icon assuming we
|
// Count how many types we have, and set/overwrite the icon assuming we
|
||||||
// only have that type. If we end up with multiple types, we return that
|
// only have that type. If we end up with multiple types, we return that
|
||||||
// icon instead of a specific one.
|
// icon instead of a specific one.
|
||||||
console.log(types);
|
//console.log(types);
|
||||||
for (var type in types) {
|
for (var type in types) {
|
||||||
console.log(type);
|
//console.log(type);
|
||||||
item_types++;
|
item_types++;
|
||||||
if (types[type] == 1) {
|
if (types[type] == 1) {
|
||||||
icon = SETTINGS.itemtypes[type].mapicon;
|
icon = SETTINGS.itemtypes[type].mapicon;
|
||||||
} else {
|
} else {
|
||||||
icon = SETTINGS.itemtypes[type].pluralmapicon;
|
icon = SETTINGS.itemtypes[type].pluralmapicon;
|
||||||
}
|
}
|
||||||
console.log(icon);
|
//console.log(icon);
|
||||||
}
|
}
|
||||||
if (item_types > 1) {
|
if (item_types > 1) {
|
||||||
return "multiple-items";
|
return "multiple-items";
|
||||||
|
@ -71,7 +71,7 @@ function setupHTML5BarcodeScanner() {
|
|||||||
$("#web-barcode-ui").removeClass("hidden");
|
$("#web-barcode-ui").removeClass("hidden");
|
||||||
// Stolen from https://zxing-js.github.io/library/examples/multi-camera/
|
// Stolen from https://zxing-js.github.io/library/examples/multi-camera/
|
||||||
const codeReader = new ZXing.BrowserMultiFormatReader();
|
const codeReader = new ZXing.BrowserMultiFormatReader();
|
||||||
console.log('ZXing code reader initialized');
|
console.log("Info", 'ZXing code reader initialized');
|
||||||
codeReader.getVideoInputDevices()
|
codeReader.getVideoInputDevices()
|
||||||
.then((videoInputDevices) => {
|
.then((videoInputDevices) => {
|
||||||
if (videoInputDevices.length == 0) {
|
if (videoInputDevices.length == 0) {
|
||||||
@ -84,7 +84,6 @@ function setupHTML5BarcodeScanner() {
|
|||||||
|
|
||||||
codeReader.decodeFromInputVideoDeviceContinuously(selectedDeviceId, 'barcode-viewer', (result, err) => {
|
codeReader.decodeFromInputVideoDeviceContinuously(selectedDeviceId, 'barcode-viewer', (result, err) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
console.log(result);
|
|
||||||
codeReader.reset();
|
codeReader.reset();
|
||||||
$("#web-barcode-ui").addClass("hidden");
|
$("#web-barcode-ui").addClass("hidden");
|
||||||
success(result.text);
|
success(result.text);
|
||||||
@ -123,15 +122,15 @@ function initCordova() {
|
|||||||
document.addEventListener("deviceready", function () {
|
document.addEventListener("deviceready", function () {
|
||||||
if (localStorage.getItem("wakelock") == "true") {
|
if (localStorage.getItem("wakelock") == "true") {
|
||||||
window.powerManagement.acquire(function () {
|
window.powerManagement.acquire(function () {
|
||||||
console.log('Wakelock acquired');
|
console.log("Info", 'Wakelock acquired');
|
||||||
}, function () {
|
}, function () {
|
||||||
console.log('Failed to acquire wakelock');
|
console.log("Warn", 'Failed to acquire wakelock');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.powerManagement.release(function () {
|
window.powerManagement.release(function () {
|
||||||
console.log('Wakelock released');
|
console.log("Info", 'Wakelock released');
|
||||||
}, function () {
|
}, function () {
|
||||||
console.log('Failed to release wakelock');
|
console.log("Warn", 'Failed to release wakelock');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user