Add refresh button on tracking info page (close #24), add scan sound
This commit is contained in:
parent
2bb6aa0b8d
commit
f6f811d404
BIN
www/assets/audio/scan.mp3
Normal file
BIN
www/assets/audio/scan.mp3
Normal file
Binary file not shown.
@ -20,7 +20,8 @@ function initSFX() {
|
||||
sfx = {
|
||||
"alert": new Audio("assets/audio/" + alertNoiseFile),
|
||||
"ok": new Audio("assets/audio/ok.mp3"),
|
||||
"error": new Audio("assets/audio/error.mp3")
|
||||
"error": new Audio("assets/audio/error.mp3"),
|
||||
"scan": new Audio("assets/audio/scan.mp3")
|
||||
};
|
||||
|
||||
setVolume("alert", alertVolume);
|
||||
|
@ -113,7 +113,7 @@ function initCordova() {
|
||||
showFlipCameraButton : true,
|
||||
prompt: "Scan barcode",
|
||||
resultDisplayDuration: 0,
|
||||
disableSuccessBeep: false,
|
||||
disableSuccessBeep: true,
|
||||
formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE"
|
||||
}
|
||||
);
|
||||
|
@ -4,6 +4,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
var lasttrackingcode = "";
|
||||
|
||||
function locationArrayToString(location) {
|
||||
var locarray = [];
|
||||
if (location.street != "" && location.street != null) {
|
||||
@ -58,7 +60,15 @@ function trackingStatusToNiceString(status, icon) {
|
||||
}
|
||||
}
|
||||
|
||||
function openTrackingHistory(trackingcode) {
|
||||
function openTrackingHistory(code) {
|
||||
var refresh = false;
|
||||
if (typeof code == "undefined") {
|
||||
trackingcode = lasttrackingcode;
|
||||
refresh = true;
|
||||
} else {
|
||||
trackingcode = code;
|
||||
}
|
||||
lasttrackingcode = trackingcode;
|
||||
var requestfinished = false;
|
||||
var trackingdialogopen = false;
|
||||
$.ajax({
|
||||
@ -89,11 +99,18 @@ function openTrackingHistory(trackingcode) {
|
||||
infocontext.history[i].status = trackingStatusToNiceString(infocontext.history[i].status, true);
|
||||
}
|
||||
// TODO: format timestamps as local time
|
||||
router.navigate("/toolbox/track/info", {
|
||||
context: infocontext
|
||||
});
|
||||
|
||||
if (refresh) {
|
||||
router.navigate("/toolbox/track/info", {
|
||||
context: infocontext,
|
||||
reloadCurrent: true
|
||||
});
|
||||
} else {
|
||||
router.navigate("/toolbox/track/info", {
|
||||
context: infocontext
|
||||
});
|
||||
}
|
||||
} else {
|
||||
playSound("error");
|
||||
app.dialog.alert(resp.message, "Error");
|
||||
}
|
||||
},
|
||||
@ -103,22 +120,27 @@ function openTrackingHistory(trackingcode) {
|
||||
trackingdialogopen = false;
|
||||
}
|
||||
requestfinished = true;
|
||||
playSound("error");
|
||||
app.dialog.alert("There was a network issue while tracking the item. Please try again.", "Error");
|
||||
}
|
||||
});
|
||||
|
||||
// Open a loading message if there's a delay
|
||||
setTimeout(function () {
|
||||
if (!requestfinished) {
|
||||
app.dialog.preloader("Tracking...");
|
||||
trackingdialogopen = true;
|
||||
}
|
||||
}, 750);
|
||||
// Open a loading message if there's a delay or we're refreshing the page
|
||||
if (refresh) {
|
||||
app.dialog.preloader("Tracking...");
|
||||
trackingdialogopen = true;
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
if (!requestfinished) {
|
||||
app.dialog.preloader("Tracking...");
|
||||
trackingdialogopen = true;
|
||||
}
|
||||
}, 750);
|
||||
}
|
||||
}
|
||||
|
||||
function scanTrackingBarcode() {
|
||||
scanBarcode(function (code) {
|
||||
playSound("scan");
|
||||
if (code != "" && code.length > 5) {
|
||||
openTrackingHistory(code);
|
||||
} else {
|
||||
|
@ -13,6 +13,11 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">Tracking Status</div>
|
||||
<div class="right">
|
||||
<a class="link" onclick="openTrackingHistory()">
|
||||
<i class="material-icons">refresh</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user