-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
150 lines (135 loc) · 5.56 KB
/
Copy pathscript.js
File metadata and controls
150 lines (135 loc) · 5.56 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
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById('data-form');
const qrContainer = document.getElementById('qrcode');
// Reset button logic with confirmation
const resetBtn = document.getElementById('reset-btn');
resetBtn.addEventListener('click', () => {
if (confirm("Are you sure you want to reset? All data will be cleared.")) {
form.reset(); // clears all text, numbers, selects, and checkboxes
// Reset counters (since they're readonly number inputs with +/-)
document.querySelectorAll('input[type="number"]').forEach(input => {
input.value = 0;
});
// Clear QR code display
qrContainer.innerHTML = '';
}
});
// Auto section for adding
const autoCoralL1Input = document.getElementById('autoCoralL1');
const autoCoralL2Input = document.getElementById('autoCoralL2');
const autoCoralL3Input = document.getElementById('autoCoralL3');
const autoCoralL4Input = document.getElementById('autoCoralL4');
const autoCoralMissedInput = document.getElementById('autoCoralMissed');
const autoBargeInput = document.getElementById('autoBarge');
const autoProcessorInput = document.getElementById('autoProcessor');
const autoFoulInput = document.getElementById('autoFoul');
// Teleop section for adding
const teleCoralL1Input = document.getElementById('teleCoralL1');
const teleCoralL2Input = document.getElementById('teleCoralL2');
const teleCoralL3Input = document.getElementById('teleCoralL3');
const teleCoralL4Input = document.getElementById('teleCoralL4');
const teleCoralMissed = document.getElementById('teleCoralMissed');
const teleBarge = document.getElementById('teleBarge');
const teleProcesor = document.getElementById('teleProcessor');
const touchedCage = document.getElementById('touchedCage');
// Set up +/- buttons for catogories
[
'autoCoralL1',
'autoCoralL2',
'autoCoralL3',
'autoCoralL4',
'autoCoralMissed',
'autoBarge',
'autoProcessor',
'autoFoul',
'teleCoralL1',
'teleCoralL2',
'teleCoralL3',
'teleCoralL4',
'teleCoralMissed',
'teleBarge',
'teleProcessor',
'touchedCage',
].forEach(setupCounter);
form.addEventListener('submit', function (e) {
e.preventDefault();
// get number/string data
const scouterIni = document.getElementById('scouterInitial').value;
const match = document.getElementById('match-number').value;
const robot = document.getElementById('robot-select').value;
const teamNum = document.getElementById('teamNumber').value;
const startingPos = document.getElementById('startingPosition').value;
const coralPickupLocation = document.getElementById('coralPickup-Location').value;
const algeaPickupLocation = document.getElementById('algeaPickup-Location').value;
const endPos = document.getElementById('endPosition').value;
const defenseSkill = document.getElementById('defensiveSkill').value;
const card = document.getElementById('card').value;
const disable = document.getElementById('disable').value;
const comments = document.getElementById('comments').value;
const tags = document.getElementById('tags').value;
// get bool data
const noShow = document.getElementById('noShow-toggle').checked;
const moved = document.getElementById('moved-toggle').checked;
const autoAlgeaDislodged = document.getElementById('autoDislodgedAlgea-toggle').checked;
const teleAlgeaDislodged = document.getElementById('autoDislodgedAlgea-toggle').checked;
const defensed = document.getElementById('crossfield/defense-toggle').checked;
const defensedAgainst = document.getElementById('defensedAgainst-toggle').checked;
const qrData = [
scouterIni,
match,
robot,
teamNum,
startingPos,
noShow,
moved,
autoCoralL1Input.value,
autoCoralL2Input.value,
autoCoralL3Input.value,
autoCoralL4Input.value,
autoCoralMissedInput.value,
autoBargeInput.value,
autoProcessorInput.value,
autoAlgeaDislodged,
autoFoulInput.value,
teleAlgeaDislodged,
coralPickupLocation,
algeaPickupLocation,
teleCoralL1Input.value,
teleCoralL2Input.value,
teleCoralL3Input.value,
teleCoralL4Input.value,
teleCoralMissed.value,
teleBarge.value,
teleProcesor.value,
defensed,
touchedCage.value,
endPos,
defensedAgainst,
defenseSkill,
card,
disable,
comments,
tags
].join("\t");
qrContainer.innerHTML = '';
new QRCode(qrContainer, {
text: qrData,
width: 256,
height: 256,
correctLevel: QRCode.CorrectLevel.L
});
});
});
function setupCounter(id) {
const input = document.getElementById(id);
const plus = document.getElementById(`${id}-plus`);
const minus = document.getElementById(`${id}-minus`);
plus.addEventListener('click', () => {
input.value = parseInt(input.value) + 1;
});
minus.addEventListener('click', () => {
if (parseInt(input.value) > 0) {
input.value = parseInt(input.value) - 1;
}
});
}