From f57987eceb18b61b9f82b55be5ca3d90eb0b3e37 Mon Sep 17 00:00:00 2001 From: gdamms Date: Fri, 13 May 2022 11:27:13 +0200 Subject: [PATCH] tests --- src/front/index.html | 3 ++- src/front/pixels.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/front/pixels.js diff --git a/src/front/index.html b/src/front/index.html index e30b5c5..d74890c 100644 --- a/src/front/index.html +++ b/src/front/index.html @@ -83,7 +83,7 @@
- +
@@ -806,6 +806,7 @@
+ \ No newline at end of file diff --git a/src/front/pixels.js b/src/front/pixels.js new file mode 100644 index 0000000..65fb37a --- /dev/null +++ b/src/front/pixels.js @@ -0,0 +1,31 @@ +debugger; + +function readTextFile(file) +{ + var rawFile = new XMLHttpRequest(); + rawFile.open("GET", file, false); + rawFile.onreadystatechange = function () + { + if(rawFile.readyState === 4) + { + if(rawFile.status === 200 || rawFile.status == 0) + { + var allText = rawFile.responseText; + alert(allText); + } + } + } + rawFile.send(null); +} + +// fetch("https://URL/file").then((r)=>{r.text().then((d)=>{let json = d})}) +const json = readTextFile("test.json"); +const obj = JSON.parse(json); + +var table = document.getElementById("pixelTable"); +var num_columns = table.rows[0].cells.length; + +for (pixel in obj) { + var cell = table.rows[Math.floor(pixel.id / num_columns)].cells[pixel.id % num_columns]; + cell.style.background = "#f00"; +}