-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (75 loc) · 1.78 KB
/
script.js
File metadata and controls
87 lines (75 loc) · 1.78 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
/**
* Created by mz on 06/02/2017.
*/
var formResponse = "https://docs.google.com/a/starship.co/forms/d/e/1FAIpQLSd45fatauSzdGu33ZWZiDOMIU0wFFv9ia3r5YpVjQPrEx_XGA/formResponse";
var concepts = [
"static",
"flashing"
];
var reactions = [
"unchanged speed",
"brake reaction",
"full stop"
];
var backoffs = [
"standing",
"backoff"
];
var active = {
concept: 0,
backoff: 0
}
var timer;
var time = 0;
function submit(reaction, additional) {
$('#wait').css('display', 'flex');
var data = {
"entry.364832717": concepts[active["concept"]],
"entry.1995415787": reactions[reaction],
};
if (additional) {
$.extend(data, additional);
}
$.ajax({
cache: false,
type: "POST",
url: formResponse,
data: data,
dataType: "xml",
success: function() {
setTimeout(function(){$('#wait').hide()},500);
},
error: function(error) {
setTimeout(function(){$('#wait').hide()},500);
}
});
}
function change(what, concept) {
active[what] = concept;
$("." + what).removeClass("active");
$("#"+what+concept).addClass("active");
}
function react(reaction) {
if (reaction < 2) {
submit(reaction);
} else {
time = 0;
timer = setInterval(function(){
time += 1;
$('#watch').text(time);
}, 1000);
$('#stop').show();
$('.concept').prop('disabled', true);
$('.reaction').prop('disabled', true);
}
}
function stop() {
clearInterval(timer);
$('#stop').hide();
$('.concept').prop('disabled', false);
$('.reaction').prop('disabled', false);
submit(2, {
"entry.275698104":backoffs[active['backoff']],
"entry.919184611":time
});
}