Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fuddster authored Jan 9, 2023
2 parents 0e0d900 + 75042ba commit 012a818
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
4 changes: 4 additions & 0 deletions 2023/CU_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ var config_data = `
}
],
"teleop": [
{ "name": "Cycle Timer",
"code": "tct",
"type": "cycle"
},
{ "name": "High Cube Scored",
"code": "tuh",
"type": "counter"
Expand Down
49 changes: 42 additions & 7 deletions resources/js/scoutingPASS.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,26 @@ function addTimer(table, idx, name, data) {
inp.setAttribute("maxLength", 5);
cell2.appendChild(inp);

var button2 = document.createElement("button");
button2.setAttribute("id", "clear_" + data.code);
button2.setAttribute("type", "checkbox");
button2.setAttribute("onclick", "resetTimer(this.parentElement)");
button2.innerHTML += "Reset"
cell2.appendChild(button2);
if (data.type == 'timer') {
var button2 = document.createElement("button");
button2.setAttribute("id", "clear_" + data.code);
button2.setAttribute("type", "checkbox");
button2.setAttribute("onclick", "resetTimer(this.parentElement)");
button2.innerHTML += "Reset"
cell2.appendChild(button2);
} else if (data.type == 'cycle') {
var button2 = document.createElement("button");
button2.setAttribute("id", "cycle_" + data.code);
button2.setAttribute("type", "checkbox");
button2.setAttribute("onclick", "newCycle(this.parentElement)");
button2.innerHTML += "New Cycle"
cell2.appendChild(button2);
var ct = document.createElement('input');
ct.setAttribute("type", "text"); // Change back to hidden?
ct.setAttribute("id", "cycletime_" + data.code);
ct.setAttribute("value", "[]");
cell2.appendChild(ct);
}

idx += 1
row = table.insertRow(idx);
Expand Down Expand Up @@ -487,7 +501,8 @@ function addElement(table, idx, data) {
idx = addCheckbox(table, idx, name, data);
} else if (data.type == 'counter') {
idx = addCounter(table, idx, name, data);
} else if (data.type == 'timer') {
} else if ((data.type == 'timer') ||
(data.type == 'cycle')) {
idx = addTimer(table, idx, name, data);
} else {
console.log(`Unrecognized type: ${data.type}`);
Expand Down Expand Up @@ -1062,6 +1077,26 @@ function counter(element, step) {
}
}

function newCycle(event)
{
let timerID = event.firstChild;
let inp = document.getElementById("input" + getIdBase(timerID.id))
let cycleTime = inp.value
inp.value = 0

console.log(cycleTime);

let cycleInput = document.getElementById("cycletime" + getIdBase(timerID.id));

console.log(cycleInput.value);
console.log(cycleInput.id);
console.log(cycleInput.class);
console.log("***"+cycleInput.value+"***");
var tempValue = Array.from(JSON.parse(cycleInput.value));
tempValue.push(cycleTime);
cycleInput.value = JSON.stringify(tempValue);
}

function resetTimer(event) {
let timerID = event.firstChild;
let inp = document.getElementById("input" + getIdBase(timerID.id))
Expand Down

0 comments on commit 012a818

Please sign in to comment.