-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
296 lines (245 loc) · 13.2 KB
/
index.html
File metadata and controls
296 lines (245 loc) · 13.2 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!DOCTYPE html>
<html lang="en" manifest="scouting.appcache">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scouting 2024</title>
<script>
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",d=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,d)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(a){u(a)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,d){if(!d){t=p(t)}var v=this,w=t.type,m=w===s,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&i)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;a(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define("FileSaver.js",function(){return saveAs})}
</script>
<style>
body{
font-family: Arial, sans-serif;
text-align: justify;
background-color: var(--main-darklg);
color: var(--main-light);
}
.hiddenBeforeMatch{
display: none;
}
.scouterInfo{
display: initial;
}
.doNotDoThis{
background-color: red;
color: white;
}
* {
box-sizing: border-box;
}
h1 {
text-align: center;
}
.col {
width: 33.33%;
float: left;
}
button{
height: 45px;
border-radius: 5px;
background-color: var(--primary-color);
color: var(black);
border: var(--main-dark);
border-style: solid;
}
#plusminusbutton {
width: 45px;
font-size: xx-large;
}
button:hover {
background-color: var(--main-dark);
color: var(--primary-color);
}
input[type=checkbox]{
height: 35px;
width: 35px;
}
input[type=number]{
height: 45px;
width: 45px;
}
#matchNb, #teamNb {
width: 100px;
height: 20px;
}
#debutMatch {
height: 75px;
}
:root {
--main-darklg: #414141;
--main-dark: #161d29;
--primary-color: #fff347;
--main-light: #FFFFFF;
}
</style>
</head>
<body>
<h1 id="stateMatch">État du match</h1>
<h3 id="matchTime" class="hiddenBeforeMatch">Match Time: </h3>
<div class="col">
<div class="scouterInfo">
<h4>Nom du scouter:</h4>
<input name="scouterName" type="text" id="scouterName" class="toExport">
<h4># du match</h4>
<input name="matchNb" type="number" id="matchNb" class="toExport">
<h4># de l'Équipe</h4>
<input name="teamNb" type="number" id="teamNb" class="toExport"><br><br>
<button id="debutMatch" onclick="debutMatch()">Début de match</button><br>
<br><br><br><br>
<button id="showScoutData" onclick="showAllScoutingData()">Télécharger/AirDrop les données de tout les matchs</button><br>
<br><br><br><br>
<form action="https://github.com/Evolution2626/scouting-data-parser/new/main" method="get" target="_blank">
<input type="text" name="filename" id="filename" hidden>
<input type="text" name="value" id="value" hidden>
<input type="submit" value="Upload all data to github">
</form>
<br><br><br><br>
<button id="clearScoutData" class="doNotDoThis" onclick="clearLocalstorage()">Supprimer les données de tous les matchs</button><br>
</div>
<div class="hiddenBeforeMatch">
<input name="autoTraverserLigne" type="checkbox" id="autoTraverserLigne" class="toExport">A traverser ligne pendant l'auto?<br>
<h4>Pièce auto</h4>
<p>Note Speaker</p>
<button id="plusminusbutton" onclick="autoNoteSpeaker.value--">-</button><input name="autoNoteSpeaker" type="number" id="autoNoteSpeaker" class="toExport" value="0"><button id="plusminusbutton" onclick="autoNoteSpeaker.value++">+</button><br>
<p>Note Amp </p>
<button id="plusminusbutton" onclick="autoNoteAmp.value--">-</button><input name="autoNoteAmp" type="number" id="autoNoteAmp" class="toExport" value="0"><button id="plusminusbutton" onclick="autoNoteAmp.value++">+</button><br><br><br>
<button id="defense" onclick="faitDefense()">Fait Défense</button><br>
</div>
</div>
<div class="col hiddenBeforeMatch">
<h4>Pièce Teleop</h4>
<p>Note Speaker</p>
<button id="plusminusbutton" onclick="teleopNoteSpeaker.value--">-</button><input name="teleopNoteSpeaker" type="number" id="teleopNoteSpeaker" class="toExport" value="0"><button id="plusminusbutton" onclick="teleopNoteSpeaker.value++">+</button><br>
<p>Note Amp </p>
<button id="plusminusbutton" onclick="teleopNoteAmp.value--">-</button><input name="teleopNoteAmp" type="number" id="teleopNoteAmp" class="toExport" value="0"><button id="plusminusbutton" onclick="teleopNoteAmp.value++">+</button><br>
<h4>Pins</h4>
<p>Nombre de pin reçu</p>
<button id="plusminusbutton" onclick="pinRecu.value--">-</button><input name="pinRecu" type="number" id="pinRecu" class="toExport" value="0"><button id="plusminusbutton" onclick="pinRecu.value++">+</button>
<p>Nombre de pin initié</p>
<button id="plusminusbutton" onclick="pinInitie.value--">-</button><input name="pinInitie" type="number" id="pinInitie" class="toExport" value="0"><button id="plusminusbutton" onclick="pinInitie.value++">+</button>
<p>Nombre de pénalité causé par les pins</p>
<button id="plusminusbutton" onclick="penoPin.value--">-</button><input name="penoPin" type="number" id="penoPin" class="toExport" value="0"><button id="plusminusbutton" onclick="penoPin.value++">+</button>
</div>
<div class="col hiddenBeforeMatch">
<h4>Peut ramasser des notes:</h4>
<input name="ramasseNoteParTerre" type="checkbox" id="ramasseNoteParTerre" class="toExport">Par terre<br>
<input name="ramasseNoteFeedingStation" type="checkbox" id="ramasseNoteFeedingStation" class="toExport">Feeding Station<br>
<h4>Endgame</h4>
<input name="climb" type="checkbox" id="climb" class="toExport">Est-ce que le robot est climbé?<br>
<input name="park" type="checkbox" id="park" class="toExport">Est-ce que le robot est parké?<br>
<input name="trap" type="checkbox" id="trap" class="toExport">Est-ce que le robot a fait la trap?<br>
<p>Commentaire:</p><br>
<textarea name="commentaire" id="commentaire" class="toExport"></textarea><br>
<button id="finMatch" onclick="finMatch()">Fin de match</button>
</div>
</body>
<script>
var timers = [];
var tempsDefense = [];
document.getElementById("filename").value = "/data/2024/Export" + Date.now() + ".json";
if (localStorage.getItem("scoutData")){
document.getElementById("value").value = localStorage.getItem("scoutData");
}
function exportAll(){
var thingsToExport = document.getElementsByClassName("toExport");
var outArray = {};
var totalTempsDefense = 0;
for (var i = 0; i < thingsToExport.length; i++) {
var element = thingsToExport[i];
//console.log(element.value);
if (element.type == "checkbox"){
outArray[element.name] = element.checked;
}else{
outArray[element.name] = element.value;
}
}
for (let i = 0; i < tempsDefense.length; i++) {
totalTempsDefense += tempsDefense[i];
}
outArray["TimeDefense"] = totalTempsDefense;
return outArray;
}
function setDisplayStyle(nomStyle, className){
var elements = document.getElementsByClassName(className);
for (let index = 0; index < elements.length; index++) {
elements[index].style.display = nomStyle;
}
}
setDisplayStyle("none", "hiddenBeforeMatch");
function startTimer(name){
timers[name] = ((new Date()).getTime() / 1000);
}
function getTimer(name){
return(((new Date()).getTime() / 1000) - timers[name]);
}
var interval = setInterval(setMatchState, 1000);
function setMatchState(){
if (getTimer("match")) {
matchTime.innerText = "Remaining Match Time: " + Math.ceil(150-getTimer("match"));
if (getTimer("match") >= 16) {
stateMatch.innerText = "Teleop"
if (getTimer("match") >= 121) {
stateMatch.innerText = "EndGame";
if (getTimer("match") >= 151) {
stateMatch.innerText = "Match finished"
matchTime.innerText = "Remaining Match Time: 0";
}
}
}
}
}
function faitDefense(){
if (defense.innerText == "Fait Défense") {
var timeMatch = getTimer("match");
startTimer("faitDefense");
defense.style.backgroundColor = "Red";
defense.style.color = "White";
defense.innerText = "Fini Défense";
}else {
var timeDefense = getTimer("faitDefense");
tempsDefense.push(timeDefense);
defense.style.backgroundColor = "#fff347";
defense.style.color = "black";
defense.innerText = "Fait Défense";
}
}
function debutMatch(){
startTimer("match");
setDisplayStyle("initial", "hiddenBeforeMatch");
setDisplayStyle("none", "scouterInfo");
stateMatch.innerText = "Autonomous";
}
function finMatch(){
if (confirm("Je confirme que les données sont valides.")) {
var blob = new Blob([JSON.stringify(exportAll())], {type: "text/plain;charset=utf-8"});
if (localStorage.getItem("scoutData")){
var data = JSON.parse(localStorage.getItem("scoutData"));
data.push(exportAll());
localStorage.setItem("scoutData", JSON.stringify(data));
}
else{
var data = [];
data.push(exportAll());
localStorage.setItem("scoutData", JSON.stringify(data));
}
saveAs(blob, "m" + exportAll().matchNb + "t" + exportAll().teamNb + ".json");
location.reload();
}
}
function showAllScoutingData() {
var data = JSON.parse(localStorage.getItem("scoutData"));
var exportAllDataFile = new Blob([JSON.stringify(data)], {type: "text/plain;charset=utf-8"});
saveAs(exportAllDataFile, "scoutingResults.json");
}
function clearLocalstorage(){
if (confirm("Attention, voulez-vous vraiment supprimer toutes les données?")) {
if (confirm("Êtes-vous vraiment sûr?")) {
if (confirm("Êtes-vous vraiment, vraiment sûr? Toutes les données seront perdues.")) {
localStorage.clear();
}
}
}
}
</script>
</html>