-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (73 loc) · 2.25 KB
/
Copy pathindex.html
File metadata and controls
87 lines (73 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-3.3.1.min.js" ></script>
<style>
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 65%;
}
</style>
</head>
<body>
<img id="lock" src="images/noun_Lock_100423.png" width="512" alt="Locked" class="center"/>
<BR />
<script>
$(document).ready(function(){
console.log("reay");
$("#solve").click(function(){
console.log("solving");
solve();
});
function loadUnlockImage(){
$("#lock").attr("src", "images/noun_Unlock_100425.png");
}
function loadLockImage(){
$("#lock").attr("src", "images/noun_Lock_100423.png");
}
var currentTimeout;
var payload = "";
var recording = false;
$(document).keydown(function( event ) {
event.preventDefault();//prevents default actions
console.log(event.key);
if (event.key == "%" /*53*/) { //when a is pressed, start recording and move to second page
// note: this will change when we use a real card.
recording = true;
console.log("start recording");
clearTimeout(currentTimeout); // make sure there aren't any other timeouts current in operation
currentTimeout = setTimeout(function(){
if(recording){
recording = false;
payload = "";
currentUser= false;
}
},9000) //wait nine seconds on this page: should probs be changed to wait for data
} else if (recording && event.key == "?" /*191*/){ //when b is pressed, stop recording, update card, reset
console.log("stop recording");
console.log("card id is " + payload);
recording = false;
// do stuff here
if(payload.trim() == "4142003532000Shift"){
loadUnlockImage();
}else{
console.log("nope");
}
payload = "";
clearTimeout(currentTimeout);
currentTimeout = setTimeout(function(){
loadLockImage(false);
}, 30000); //wait 30 seconds on this page then go back to the beginning
} else if (recording){
payload += event.key; //add the keys that are pressed between "%" and "?"
} else {
console.log("nope");
return false;
}
});
});
</script>
</body>
</html>