From 7495b7eaf04adce6b320d6ce2ae0d323f43ad505 Mon Sep 17 00:00:00 2001 From: CatonQ Date: Sun, 25 Feb 2024 16:45:25 -0800 Subject: [PATCH] removed clickable image stuff --- resources/js/scoutingPASS.js | 374 +++++++++++++++++------------------ 1 file changed, 187 insertions(+), 187 deletions(-) diff --git a/resources/js/scoutingPASS.js b/resources/js/scoutingPASS.js index 3194164..fecdd78 100644 --- a/resources/js/scoutingPASS.js +++ b/resources/js/scoutingPASS.js @@ -214,190 +214,190 @@ function addCounter(table, idx, name, data) { return idx + 1; } -function addClickableImage(table, idx, name, data) { - var row = table.insertRow(idx); - var cell = row.insertCell(0); - cell.setAttribute("colspan", 2); - cell.setAttribute("style", "text-align: center;"); - cell.classList.add("title"); - if (!data.hasOwnProperty('code')) { - cell1.innerHTML = `Error: No code specified for ${name}`; - return idx + 1; - } - cell.innerHTML = name; - if (data.hasOwnProperty('tooltip')) { - cell.setAttribute("title", data.tooltip); - } - - let showFlip = true; - if (data.hasOwnProperty('showFlip')) { - if (data.showFlip.toLowerCase() == 'false') { - showFlip = false; - } - } - - let showUndo = true; - if (data.hasOwnProperty('showUndo')) { - if (data.showUndo.toLowerCase() == 'false') { - showUndo = false; - } - } - - if (showFlip || showUndo) { - idx += 1 - row = table.insertRow(idx); - cell = row.insertCell(0); - cell.setAttribute("colspan", 2); - cell.setAttribute("style", "text-align: center;"); - - if (showUndo) { - // Undo button - let undoButton = document.createElement("input"); - undoButton.setAttribute("type", "button"); - undoButton.setAttribute("onclick", "undo(this.parentElement)"); - undoButton.setAttribute("value", "Undo"); - undoButton.setAttribute("id", "undo_" + data.code); - undoButton.setAttribute("class", "undoButton"); - cell.appendChild(undoButton); - } - - if (showFlip) { - // Flip button - let flipButton = document.createElement("input"); - flipButton.setAttribute("type", "button"); - flipButton.setAttribute("onclick", "flip(this.parentElement)"); - flipButton.setAttribute("value", "Flip Image"); - flipButton.setAttribute("id", "flip_" + data.code); - flipButton.setAttribute("class", "flipButton"); - if (showUndo) { - flipButton.setAttribute("margin-left", '8px'); - } - cell.appendChild(flipButton); - } - } - - idx += 1; - row = table.insertRow(idx); - cell = row.insertCell(0); - cell.setAttribute("colspan", 2); - cell.setAttribute("style", "text-align: center;"); - var canvas = document.createElement('canvas'); - //canvas.onclick = onFieldClick; - canvas.setAttribute("onclick", "onFieldClick(event)"); - canvas.setAttribute("class", "field-image-src"); - canvas.setAttribute("id", "canvas_" + data.code); - canvas.innerHTML = "No canvas support"; - cell.appendChild(canvas); - - idx += 1; - row = table.insertRow(idx); - row.setAttribute("style", "display:none"); - cell = row.insertCell(0); - cell.setAttribute("colspan", 2); - var inp = document.createElement('input'); - inp.setAttribute("type", "hidden"); - inp.setAttribute("id", "XY_" + data.code); - inp.setAttribute("value", "[]"); - cell.appendChild(inp); - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - if (enableGoogleSheets && data.hasOwnProperty('gsCol')) { - inp.setAttribute("name", data.gsCol); - } else { - inp.setAttribute("name", data.code); - } - inp.setAttribute("id", "input_" + data.code); - inp.setAttribute("value", "[]"); - inp.setAttribute("class", "clickableImage"); - - cell.appendChild(inp); - - // TODO: Make these more efficient/elegant - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "clickRestriction_" + data.code); - inp.setAttribute("value", "none"); - if (data.hasOwnProperty('clickRestriction')) { - if ((data.clickRestriction == "one") || - (data.clickRestriction == "onePerBox")) { - inp.setAttribute("value", data.clickRestriction); - } - } - cell.appendChild(inp); - - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "allowableResponses_" + data.code); - inp.setAttribute("value", "none"); - if (data.hasOwnProperty('allowableResponses')) { - let responses = data.allowableResponses.split(' ').map(Number) - console.log(responses) - inp.setAttribute("value", responses); - } - cell.appendChild(inp); - - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "dimensions_" + data.code); - inp.setAttribute("value", "12 6"); - if (data.hasOwnProperty('dimensions')) { - if (data.dimensions != "") { - // TODO: Add validation for "X Y" format - inp.setAttribute("value", data.dimensions); - } - } - cell.appendChild(inp); - - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "shape_" + data.code); - // Default shape: white circle of size 5 not filled in - inp.setAttribute("value", "circle 5 white white true"); - if (data.hasOwnProperty('shape')) { - if (data.shape != "") { - // TODO: Add validation for "shape size color fill" format - inp.setAttribute("value", data.shape); - } - } - cell.appendChild(inp); - - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "toggleClick_" + data.code); - inp.setAttribute("value", "false"); - if (data.hasOwnProperty('toggleClick')) { - if (data.toggleClick != "") { - // TODO: Add validation for true/false format - inp.setAttribute("value", data.toggleClick); - } - } - cell.appendChild(inp); - - if (data.hasOwnProperty('cycleTimer')) { - if (data.cycleTimer != "") { - inp = document.createElement('input'); - inp.setAttribute("hidden", ""); - inp.setAttribute("id", "cycleTimer_" + data.code); - inp.setAttribute("value", data.cycleTimer); - cell.appendChild(inp); - } - } - - idx += 1 - row = table.insertRow(idx); - row.setAttribute("style", "display:none"); - cell = row.insertCell(0); - cell.setAttribute("colspan", 2); - var img = document.createElement('img'); - img.src = data.filename; - img.setAttribute("id", "img_" + data.code); - img.setAttribute("class", "field-image-src"); - img.setAttribute("onload", "drawFields()"); - img.setAttribute("hidden", ""); - cell.appendChild(img); - - return idx + 1 -} +// function addClickableImage(table, idx, name, data) { +// var row = table.insertRow(idx); +// var cell = row.insertCell(0); +// cell.setAttribute("colspan", 2); +// cell.setAttribute("style", "text-align: center;"); +// cell.classList.add("title"); +// if (!data.hasOwnProperty('code')) { +// cell1.innerHTML = `Error: No code specified for ${name}`; +// return idx + 1; +// } +// cell.innerHTML = name; +// if (data.hasOwnProperty('tooltip')) { +// cell.setAttribute("title", data.tooltip); +// } + +// let showFlip = true; +// if (data.hasOwnProperty('showFlip')) { +// if (data.showFlip.toLowerCase() == 'false') { +// showFlip = false; +// } +// } + +// let showUndo = true; +// if (data.hasOwnProperty('showUndo')) { +// if (data.showUndo.toLowerCase() == 'false') { +// showUndo = false; +// } +// } + +// if (showFlip || showUndo) { +// idx += 1 +// row = table.insertRow(idx); +// cell = row.insertCell(0); +// cell.setAttribute("colspan", 2); +// cell.setAttribute("style", "text-align: center;"); + +// if (showUndo) { +// // Undo button +// let undoButton = document.createElement("input"); +// undoButton.setAttribute("type", "button"); +// undoButton.setAttribute("onclick", "undo(this.parentElement)"); +// undoButton.setAttribute("value", "Undo"); +// undoButton.setAttribute("id", "undo_" + data.code); +// undoButton.setAttribute("class", "undoButton"); +// cell.appendChild(undoButton); +// } + +// if (showFlip) { +// // Flip button +// let flipButton = document.createElement("input"); +// flipButton.setAttribute("type", "button"); +// flipButton.setAttribute("onclick", "flip(this.parentElement)"); +// flipButton.setAttribute("value", "Flip Image"); +// flipButton.setAttribute("id", "flip_" + data.code); +// flipButton.setAttribute("class", "flipButton"); +// if (showUndo) { +// flipButton.setAttribute("margin-left", '8px'); +// } +// cell.appendChild(flipButton); +// } +// } + +// idx += 1; +// row = table.insertRow(idx); +// cell = row.insertCell(0); +// cell.setAttribute("colspan", 2); +// cell.setAttribute("style", "text-align: center;"); +// var canvas = document.createElement('canvas'); +// //canvas.onclick = onFieldClick; +// canvas.setAttribute("onclick", "onFieldClick(event)"); +// canvas.setAttribute("class", "field-image-src"); +// canvas.setAttribute("id", "canvas_" + data.code); +// canvas.innerHTML = "No canvas support"; +// cell.appendChild(canvas); + +// idx += 1; +// row = table.insertRow(idx); +// row.setAttribute("style", "display:none"); +// cell = row.insertCell(0); +// cell.setAttribute("colspan", 2); +// var inp = document.createElement('input'); +// inp.setAttribute("type", "hidden"); +// inp.setAttribute("id", "XY_" + data.code); +// inp.setAttribute("value", "[]"); +// cell.appendChild(inp); +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// if (enableGoogleSheets && data.hasOwnProperty('gsCol')) { +// inp.setAttribute("name", data.gsCol); +// } else { +// inp.setAttribute("name", data.code); +// } +// inp.setAttribute("id", "input_" + data.code); +// inp.setAttribute("value", "[]"); +// inp.setAttribute("class", "clickableImage"); + +// cell.appendChild(inp); + +// // TODO: Make these more efficient/elegant +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "clickRestriction_" + data.code); +// inp.setAttribute("value", "none"); +// if (data.hasOwnProperty('clickRestriction')) { +// if ((data.clickRestriction == "one") || +// (data.clickRestriction == "onePerBox")) { +// inp.setAttribute("value", data.clickRestriction); +// } +// } +// cell.appendChild(inp); + +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "allowableResponses_" + data.code); +// inp.setAttribute("value", "none"); +// if (data.hasOwnProperty('allowableResponses')) { +// let responses = data.allowableResponses.split(' ').map(Number) +// console.log(responses) +// inp.setAttribute("value", responses); +// } +// cell.appendChild(inp); + +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "dimensions_" + data.code); +// inp.setAttribute("value", "12 6"); +// if (data.hasOwnProperty('dimensions')) { +// if (data.dimensions != "") { +// // TODO: Add validation for "X Y" format +// inp.setAttribute("value", data.dimensions); +// } +// } +// cell.appendChild(inp); + +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "shape_" + data.code); +// // Default shape: white circle of size 5 not filled in +// inp.setAttribute("value", "circle 5 white white true"); +// if (data.hasOwnProperty('shape')) { +// if (data.shape != "") { +// // TODO: Add validation for "shape size color fill" format +// inp.setAttribute("value", data.shape); +// } +// } +// cell.appendChild(inp); + +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "toggleClick_" + data.code); +// inp.setAttribute("value", "false"); +// if (data.hasOwnProperty('toggleClick')) { +// if (data.toggleClick != "") { +// // TODO: Add validation for true/false format +// inp.setAttribute("value", data.toggleClick); +// } +// } +// cell.appendChild(inp); + +// if (data.hasOwnProperty('cycleTimer')) { +// if (data.cycleTimer != "") { +// inp = document.createElement('input'); +// inp.setAttribute("hidden", ""); +// inp.setAttribute("id", "cycleTimer_" + data.code); +// inp.setAttribute("value", data.cycleTimer); +// cell.appendChild(inp); +// } +// } + +// idx += 1 +// row = table.insertRow(idx); +// row.setAttribute("style", "display:none"); +// cell = row.insertCell(0); +// cell.setAttribute("colspan", 2); +// var img = document.createElement('img'); +// img.src = data.filename; +// img.setAttribute("id", "img_" + data.code); +// img.setAttribute("class", "field-image-src"); +// img.setAttribute("onload", "drawFields()"); +// img.setAttribute("hidden", ""); +// cell.appendChild(img); + +// return idx + 1 +// } function addText(table, idx, name, data) { var row = table.insertRow(idx); @@ -646,9 +646,9 @@ function addElement(table, idx, data) { (data.type == 'number') ) { idx = addNumber(table, idx, name, data); - } else if ((data.type == 'field_image') || - (data.type == 'clickable_image')) { - idx = addClickableImage(table, idx, name, data); + // } else if ((data.type == 'field_image') || + // (data.type == 'clickable_image')) { + // idx = addClickableImage(table, idx, name, data); } else if ((data.type == 'bool') || (data.type == 'checkbox') || (data.type == 'pass_fail')