Add slider to choose alert sound frequency (close #8)

master
Skylar Ittner 5 years ago
parent 87ee63efb5
commit 6c43a7df6e

@ -32,11 +32,18 @@ if ("geolocation" in navigator) {
//map.updatePackageLayer(packages); //map.updatePackageLayer(packages);
} }
var alertinterval = localStorage.getItem("alertinterval");
if (alertinterval == null) {
alertinterval = 30;
} else {
alertinterval = alertinterval * 1;
}
lastGpsUpdateTimestamp = currentTimestamp; lastGpsUpdateTimestamp = currentTimestamp;
for (var i = 0; i < packages.length; i++) { for (var i = 0; i < packages.length; i++) {
if (packages[i].distance * 1 < localStorage.getItem("alertradius") * 1) { if (packages[i].distance * 1 < localStorage.getItem("alertradius") * 1) {
if (packages[i].lastAlert > currentTimestamp - 30) { if (packages[i].lastAlert > currentTimestamp - alertinterval) {
continue; continue;
} }

@ -59,6 +59,11 @@ $('.item-content[data-setting=alertvolume] .range-slider').on('range:changed', f
playSound("alert"); playSound("alert");
}); });
$('.item-content[data-setting=alertinterval] .range-slider').on('range:changed', function (e, range) {
var val = app.range.get(".item-content[data-setting=alertinterval] .range-slider").getValue();
localStorage.setItem("alertinterval", val);
});
function pickAlertSound() { function pickAlertSound() {
var currentalertsound = localStorage.getItem("alertsound"); var currentalertsound = localStorage.getItem("alertsound");
app.dialog.create({ app.dialog.create({
@ -155,8 +160,4 @@ function pickMapSource() {
reloadMap(); reloadMap();
} }
}).open(); }).open();
}
function formatPercentLabel(value) {
return value + "%";
} }

@ -42,12 +42,12 @@
{{#if slider}} {{#if slider}}
<div class="item-content" data-setting="{{setting}}"> <div class="item-content" data-setting="{{setting}}">
<div class="item-inner"> <div class="item-inner">
<div class="item-title"> <div class="item-title" style="background-color: rgba(0,0,0,0);">
{{title}} {{title}}
</div> </div>
<div class="item-subtitle padding-horizontal-half"> <div class="item-subtitle padding-horizontal padding-top">
<div class="range-slider range-slider-init"> <div class="range-slider range-slider-init padding-top margin-top" data-label="true">
<input type="range" min="{{min}}" max="{{max}}" step="{{step}}" label="true" formatLabel="formatPercentLabel(value)" value="{{value}}"> <input type="range" min="{{min}}" max="{{max}}" step="{{step}}" value="{{value}}">
</div> </div>
</div> </div>
</div> </div>

@ -82,19 +82,28 @@ var routes = [
settings: [ settings: [
{ {
setting: "alertsound", setting: "alertsound",
title: "Alert Sound", title: "Alert sound",
text: "Select which sound to play when a package is nearby.", text: "Select which sound to play when a package is nearby.",
onclick: "pickAlertSound()" onclick: "pickAlertSound()"
}, },
{ {
setting: "alertvolume", setting: "alertvolume",
title: "Alert Volume", title: "Alert volume",
min: 0, min: 0,
max: 100, max: 100,
step: 5, step: 1,
value: localStorage.getItem("alertvolume"), value: localStorage.getItem("alertvolume"),
slider: true slider: true
}, },
{
setting: "alertinterval",
title: "Alert interval (seconds)",
min: 15,
max: 120,
step: 15,
value: localStorage.getItem("alertinterval") == null ? 30 : localStorage.getItem("alertinterval"),
slider: true
},
{ {
setting: "wakelock", setting: "wakelock",
title: "Keep screen on", title: "Keep screen on",
@ -113,7 +122,7 @@ var routes = [
}, },
{ {
setting: "units", setting: "units",
title: "Distance Units", title: "Measurement units",
text: "Use feet and miles for showing distance", text: "Use feet and miles for showing distance",
toggle: true, toggle: true,
checked: localStorage.getItem("units") == "imperial", checked: localStorage.getItem("units") == "imperial",
@ -121,8 +130,8 @@ var routes = [
}, },
{ {
setting: "mapsource", setting: "mapsource",
title: "Map", title: "Map style",
text: "Choose which map to use.", text: "Choose which map style to use.",
onclick: "pickMapSource()" onclick: "pickMapSource()"
}, },
{ {
@ -133,13 +142,13 @@ var routes = [
}, },
{ {
setting: "opensource", setting: "opensource",
title: "Credits and Open Source", title: "Credits and open source info",
text: "", text: "",
onclick: "router.navigate('/credits')" onclick: "router.navigate('/credits')"
}, },
{ {
setting: "privacy", setting: "privacy",
title: "Privacy Policy and Terms", title: "Privacy policy and legal",
text: "", text: "",
onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=PackageHelpterApp')" onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=PackageHelpterApp')"
}] }]

Loading…
Cancel
Save