Add 15 second cooldown for scanning barcodes (issue #6).
This commit is contained in:
parent
31a57d6563
commit
8cf28bfafa
116
www/css/main.css
116
www/css/main.css
@ -450,3 +450,119 @@ body {
|
||||
color: white;
|
||||
z-index: 90000;
|
||||
}
|
||||
|
||||
|
||||
@keyframes cooldown-fade {
|
||||
/* Apparently gradients don't animate. We'll see about that! */
|
||||
/* SyMAT code (gradient-animate.syjs):
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
print(i+"% { background: linear-gradient(to top, rgba(255,255,255,.8) " + i + "%, rgba(0,0,0,.8) 0%); }");
|
||||
}
|
||||
*/
|
||||
0% { background: linear-gradient(to top, rgba(255,255,255,.8) 0%, rgba(0,0,0,.8) 0%); }
|
||||
1% { background: linear-gradient(to top, rgba(255,255,255,.8) 1%, rgba(0,0,0,.8) 0%); }
|
||||
2% { background: linear-gradient(to top, rgba(255,255,255,.8) 2%, rgba(0,0,0,.8) 0%); }
|
||||
3% { background: linear-gradient(to top, rgba(255,255,255,.8) 3%, rgba(0,0,0,.8) 0%); }
|
||||
4% { background: linear-gradient(to top, rgba(255,255,255,.8) 4%, rgba(0,0,0,.8) 0%); }
|
||||
5% { background: linear-gradient(to top, rgba(255,255,255,.8) 5%, rgba(0,0,0,.8) 0%); }
|
||||
6% { background: linear-gradient(to top, rgba(255,255,255,.8) 6%, rgba(0,0,0,.8) 0%); }
|
||||
7% { background: linear-gradient(to top, rgba(255,255,255,.8) 7%, rgba(0,0,0,.8) 0%); }
|
||||
8% { background: linear-gradient(to top, rgba(255,255,255,.8) 8%, rgba(0,0,0,.8) 0%); }
|
||||
9% { background: linear-gradient(to top, rgba(255,255,255,.8) 9%, rgba(0,0,0,.8) 0%); }
|
||||
10% { background: linear-gradient(to top, rgba(255,255,255,.8) 10%, rgba(0,0,0,.8) 0%); }
|
||||
11% { background: linear-gradient(to top, rgba(255,255,255,.8) 11%, rgba(0,0,0,.8) 0%); }
|
||||
12% { background: linear-gradient(to top, rgba(255,255,255,.8) 12%, rgba(0,0,0,.8) 0%); }
|
||||
13% { background: linear-gradient(to top, rgba(255,255,255,.8) 13%, rgba(0,0,0,.8) 0%); }
|
||||
14% { background: linear-gradient(to top, rgba(255,255,255,.8) 14%, rgba(0,0,0,.8) 0%); }
|
||||
15% { background: linear-gradient(to top, rgba(255,255,255,.8) 15%, rgba(0,0,0,.8) 0%); }
|
||||
16% { background: linear-gradient(to top, rgba(255,255,255,.8) 16%, rgba(0,0,0,.8) 0%); }
|
||||
17% { background: linear-gradient(to top, rgba(255,255,255,.8) 17%, rgba(0,0,0,.8) 0%); }
|
||||
18% { background: linear-gradient(to top, rgba(255,255,255,.8) 18%, rgba(0,0,0,.8) 0%); }
|
||||
19% { background: linear-gradient(to top, rgba(255,255,255,.8) 19%, rgba(0,0,0,.8) 0%); }
|
||||
20% { background: linear-gradient(to top, rgba(255,255,255,.8) 20%, rgba(0,0,0,.8) 0%); }
|
||||
21% { background: linear-gradient(to top, rgba(255,255,255,.8) 21%, rgba(0,0,0,.8) 0%); }
|
||||
22% { background: linear-gradient(to top, rgba(255,255,255,.8) 22%, rgba(0,0,0,.8) 0%); }
|
||||
23% { background: linear-gradient(to top, rgba(255,255,255,.8) 23%, rgba(0,0,0,.8) 0%); }
|
||||
24% { background: linear-gradient(to top, rgba(255,255,255,.8) 24%, rgba(0,0,0,.8) 0%); }
|
||||
25% { background: linear-gradient(to top, rgba(255,255,255,.8) 25%, rgba(0,0,0,.8) 0%); }
|
||||
26% { background: linear-gradient(to top, rgba(255,255,255,.8) 26%, rgba(0,0,0,.8) 0%); }
|
||||
27% { background: linear-gradient(to top, rgba(255,255,255,.8) 27%, rgba(0,0,0,.8) 0%); }
|
||||
28% { background: linear-gradient(to top, rgba(255,255,255,.8) 28%, rgba(0,0,0,.8) 0%); }
|
||||
29% { background: linear-gradient(to top, rgba(255,255,255,.8) 29%, rgba(0,0,0,.8) 0%); }
|
||||
30% { background: linear-gradient(to top, rgba(255,255,255,.8) 30%, rgba(0,0,0,.8) 0%); }
|
||||
31% { background: linear-gradient(to top, rgba(255,255,255,.8) 31%, rgba(0,0,0,.8) 0%); }
|
||||
32% { background: linear-gradient(to top, rgba(255,255,255,.8) 32%, rgba(0,0,0,.8) 0%); }
|
||||
33% { background: linear-gradient(to top, rgba(255,255,255,.8) 33%, rgba(0,0,0,.8) 0%); }
|
||||
34% { background: linear-gradient(to top, rgba(255,255,255,.8) 34%, rgba(0,0,0,.8) 0%); }
|
||||
35% { background: linear-gradient(to top, rgba(255,255,255,.8) 35%, rgba(0,0,0,.8) 0%); }
|
||||
36% { background: linear-gradient(to top, rgba(255,255,255,.8) 36%, rgba(0,0,0,.8) 0%); }
|
||||
37% { background: linear-gradient(to top, rgba(255,255,255,.8) 37%, rgba(0,0,0,.8) 0%); }
|
||||
38% { background: linear-gradient(to top, rgba(255,255,255,.8) 38%, rgba(0,0,0,.8) 0%); }
|
||||
39% { background: linear-gradient(to top, rgba(255,255,255,.8) 39%, rgba(0,0,0,.8) 0%); }
|
||||
40% { background: linear-gradient(to top, rgba(255,255,255,.8) 40%, rgba(0,0,0,.8) 0%); }
|
||||
41% { background: linear-gradient(to top, rgba(255,255,255,.8) 41%, rgba(0,0,0,.8) 0%); }
|
||||
42% { background: linear-gradient(to top, rgba(255,255,255,.8) 42%, rgba(0,0,0,.8) 0%); }
|
||||
43% { background: linear-gradient(to top, rgba(255,255,255,.8) 43%, rgba(0,0,0,.8) 0%); }
|
||||
44% { background: linear-gradient(to top, rgba(255,255,255,.8) 44%, rgba(0,0,0,.8) 0%); }
|
||||
45% { background: linear-gradient(to top, rgba(255,255,255,.8) 45%, rgba(0,0,0,.8) 0%); }
|
||||
46% { background: linear-gradient(to top, rgba(255,255,255,.8) 46%, rgba(0,0,0,.8) 0%); }
|
||||
47% { background: linear-gradient(to top, rgba(255,255,255,.8) 47%, rgba(0,0,0,.8) 0%); }
|
||||
48% { background: linear-gradient(to top, rgba(255,255,255,.8) 48%, rgba(0,0,0,.8) 0%); }
|
||||
49% { background: linear-gradient(to top, rgba(255,255,255,.8) 49%, rgba(0,0,0,.8) 0%); }
|
||||
50% { background: linear-gradient(to top, rgba(255,255,255,.8) 50%, rgba(0,0,0,.8) 0%); }
|
||||
51% { background: linear-gradient(to top, rgba(255,255,255,.8) 51%, rgba(0,0,0,.8) 0%); }
|
||||
52% { background: linear-gradient(to top, rgba(255,255,255,.8) 52%, rgba(0,0,0,.8) 0%); }
|
||||
53% { background: linear-gradient(to top, rgba(255,255,255,.8) 53%, rgba(0,0,0,.8) 0%); }
|
||||
54% { background: linear-gradient(to top, rgba(255,255,255,.8) 54%, rgba(0,0,0,.8) 0%); }
|
||||
55% { background: linear-gradient(to top, rgba(255,255,255,.8) 55%, rgba(0,0,0,.8) 0%); }
|
||||
56% { background: linear-gradient(to top, rgba(255,255,255,.8) 56%, rgba(0,0,0,.8) 0%); }
|
||||
57% { background: linear-gradient(to top, rgba(255,255,255,.8) 57%, rgba(0,0,0,.8) 0%); }
|
||||
58% { background: linear-gradient(to top, rgba(255,255,255,.8) 58%, rgba(0,0,0,.8) 0%); }
|
||||
59% { background: linear-gradient(to top, rgba(255,255,255,.8) 59%, rgba(0,0,0,.8) 0%); }
|
||||
60% { background: linear-gradient(to top, rgba(255,255,255,.8) 60%, rgba(0,0,0,.8) 0%); }
|
||||
61% { background: linear-gradient(to top, rgba(255,255,255,.8) 61%, rgba(0,0,0,.8) 0%); }
|
||||
62% { background: linear-gradient(to top, rgba(255,255,255,.8) 62%, rgba(0,0,0,.8) 0%); }
|
||||
63% { background: linear-gradient(to top, rgba(255,255,255,.8) 63%, rgba(0,0,0,.8) 0%); }
|
||||
64% { background: linear-gradient(to top, rgba(255,255,255,.8) 64%, rgba(0,0,0,.8) 0%); }
|
||||
65% { background: linear-gradient(to top, rgba(255,255,255,.8) 65%, rgba(0,0,0,.8) 0%); }
|
||||
66% { background: linear-gradient(to top, rgba(255,255,255,.8) 66%, rgba(0,0,0,.8) 0%); }
|
||||
67% { background: linear-gradient(to top, rgba(255,255,255,.8) 67%, rgba(0,0,0,.8) 0%); }
|
||||
68% { background: linear-gradient(to top, rgba(255,255,255,.8) 68%, rgba(0,0,0,.8) 0%); }
|
||||
69% { background: linear-gradient(to top, rgba(255,255,255,.8) 69%, rgba(0,0,0,.8) 0%); }
|
||||
70% { background: linear-gradient(to top, rgba(255,255,255,.8) 70%, rgba(0,0,0,.8) 0%); }
|
||||
71% { background: linear-gradient(to top, rgba(255,255,255,.8) 71%, rgba(0,0,0,.8) 0%); }
|
||||
72% { background: linear-gradient(to top, rgba(255,255,255,.8) 72%, rgba(0,0,0,.8) 0%); }
|
||||
73% { background: linear-gradient(to top, rgba(255,255,255,.8) 73%, rgba(0,0,0,.8) 0%); }
|
||||
74% { background: linear-gradient(to top, rgba(255,255,255,.8) 74%, rgba(0,0,0,.8) 0%); }
|
||||
75% { background: linear-gradient(to top, rgba(255,255,255,.8) 75%, rgba(0,0,0,.8) 0%); }
|
||||
76% { background: linear-gradient(to top, rgba(255,255,255,.8) 76%, rgba(0,0,0,.8) 0%); }
|
||||
77% { background: linear-gradient(to top, rgba(255,255,255,.8) 77%, rgba(0,0,0,.8) 0%); }
|
||||
78% { background: linear-gradient(to top, rgba(255,255,255,.8) 78%, rgba(0,0,0,.8) 0%); }
|
||||
79% { background: linear-gradient(to top, rgba(255,255,255,.8) 79%, rgba(0,0,0,.8) 0%); }
|
||||
80% { background: linear-gradient(to top, rgba(255,255,255,.8) 80%, rgba(0,0,0,.8) 0%); }
|
||||
81% { background: linear-gradient(to top, rgba(255,255,255,.8) 81%, rgba(0,0,0,.8) 0%); }
|
||||
82% { background: linear-gradient(to top, rgba(255,255,255,.8) 82%, rgba(0,0,0,.8) 0%); }
|
||||
83% { background: linear-gradient(to top, rgba(255,255,255,.8) 83%, rgba(0,0,0,.8) 0%); }
|
||||
84% { background: linear-gradient(to top, rgba(255,255,255,.8) 84%, rgba(0,0,0,.8) 0%); }
|
||||
85% { background: linear-gradient(to top, rgba(255,255,255,.8) 85%, rgba(0,0,0,.8) 0%); }
|
||||
86% { background: linear-gradient(to top, rgba(255,255,255,.8) 86%, rgba(0,0,0,.8) 0%); }
|
||||
87% { background: linear-gradient(to top, rgba(255,255,255,.8) 87%, rgba(0,0,0,.8) 0%); }
|
||||
88% { background: linear-gradient(to top, rgba(255,255,255,.8) 88%, rgba(0,0,0,.8) 0%); }
|
||||
89% { background: linear-gradient(to top, rgba(255,255,255,.8) 89%, rgba(0,0,0,.8) 0%); }
|
||||
90% { background: linear-gradient(to top, rgba(255,255,255,.8) 90%, rgba(0,0,0,.8) 0%); }
|
||||
91% { background: linear-gradient(to top, rgba(255,255,255,.8) 91%, rgba(0,0,0,.8) 0%); }
|
||||
92% { background: linear-gradient(to top, rgba(255,255,255,.8) 92%, rgba(0,0,0,.8) 0%); }
|
||||
93% { background: linear-gradient(to top, rgba(255,255,255,.8) 93%, rgba(0,0,0,.8) 0%); }
|
||||
94% { background: linear-gradient(to top, rgba(255,255,255,.8) 94%, rgba(0,0,0,.8) 0%); }
|
||||
95% { background: linear-gradient(to top, rgba(255,255,255,.8) 95%, rgba(0,0,0,.8) 0%); }
|
||||
96% { background: linear-gradient(to top, rgba(255,255,255,.8) 96%, rgba(0,0,0,.8) 0%); }
|
||||
97% { background: linear-gradient(to top, rgba(255,255,255,.8) 97%, rgba(0,0,0,.8) 0%); }
|
||||
98% { background: linear-gradient(to top, rgba(255,255,255,.8) 98%, rgba(0,0,0,.8) 0%); }
|
||||
99% { background: linear-gradient(to top, rgba(255,255,255,.8) 99%, rgba(0,0,0,.8) 0%); }
|
||||
100% { background: linear-gradient(to top, rgba(255,255,255,.8) 100%, rgba(0,0,0,.8) 0%); }
|
||||
}
|
||||
|
||||
.cooldown-fade-anim {
|
||||
/* To change cooldown time, also change CODE_SCAN_COOLDOWN_SECONDS in main.js */
|
||||
animation: cooldown-fade 15s ease-in-out;
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Constants
|
||||
// Important Globals
|
||||
username = "";
|
||||
password = "";
|
||||
energy = 100;
|
||||
@ -25,7 +25,7 @@ level = 1;
|
||||
userteamid = 0;
|
||||
MUNZEE_CLIENT_ID = '616cecc70e17f4a3cb64146dce2d33f5';
|
||||
MUNZEE_REDIRECT = 'http://gs.terranquest.net/munzee.php';
|
||||
|
||||
CODE_SCAN_COOLDOWN_SECONDS = 15; // Also change in CSS (.cooldown-fade-anim)
|
||||
|
||||
currentscreen = "";
|
||||
/*
|
||||
@ -152,11 +152,18 @@ function closemodal(modalselector) {
|
||||
$(modalselector).modal(hide);
|
||||
}
|
||||
|
||||
var scanCodeEnabled = true;
|
||||
|
||||
function scanCode() {
|
||||
// If code scanning disabled (cooldown, etc)
|
||||
if (!scanCodeEnabled) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
cordova.plugins.barcodeScanner.scan(
|
||||
function (result) {
|
||||
if (!result.cancelled) {
|
||||
scanCodeEnabled = false;
|
||||
$.getJSON(mkApiUrl('code2item', 'gs'), {
|
||||
code: result.text,
|
||||
latitude: latitude,
|
||||
@ -164,15 +171,24 @@ function scanCode() {
|
||||
accuracy: gpsaccuracy
|
||||
}, function (data) {
|
||||
if (data.status === 'OK') {
|
||||
$('#codescanbtn').addClass('cooldown-fade-anim');
|
||||
setTimeout(function () {
|
||||
scanCodeEnabled = true;
|
||||
$('#codescanbtn').removeClass('cooldown-fade-anim');
|
||||
}, CODE_SCAN_COOLDOWN_SECONDS * 1000);
|
||||
if (data.messages.length >= 2) {
|
||||
showFoundBox2(data.messages[0].title, data.messages[0].text, data.messages[1].title, data.messages[1].text);
|
||||
} else {
|
||||
showFoundBox(data.messages[0].title, data.messages[0].text);
|
||||
}
|
||||
} else {
|
||||
scanCodeEnabled = true;
|
||||
$('#codescanbtn').removeClass('cooldown-fade-anim');
|
||||
showFoundBox("Huh?", data.message);
|
||||
}
|
||||
}).fail(function () {
|
||||
scanCodeEnabled = true;
|
||||
$('#codescanbtn').removeClass('cooldown-fade-anim');
|
||||
showFoundBox("Huh?", "Nothing happened!");
|
||||
//navigator.notification.alert("Nothing happened!", null, "Huh?", 'OK');
|
||||
});
|
||||
@ -180,6 +196,8 @@ function scanCode() {
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
scanCodeEnabled = true;
|
||||
$('#codescanbtn').removeClass('cooldown-fade-anim');
|
||||
navigator.notification.alert("Scanning failed: " + error, null, "Error", 'Dismiss');
|
||||
},
|
||||
{
|
||||
@ -188,6 +206,8 @@ function scanCode() {
|
||||
}
|
||||
);
|
||||
} catch (ex) {
|
||||
scanCodeEnabled = true;
|
||||
$('#codescanbtn').removeClass('cooldown-fade-anim');
|
||||
navigator.notification.alert(ex.message, null, "Error", 'Dismiss');
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
<div class="circlebutton" onclick="openMenu()">
|
||||
<img src="assets/bars.svg" alt="Menu" />
|
||||
</div>
|
||||
<div class="circlebutton" onclick="scanCode()">
|
||||
<div class="circlebutton" onclick="scanCode()" id="codescanbtn">
|
||||
<img src="assets/qrcode.svg" alt="Scan Code" />
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user