Merge branch 'master' of git.inpt.fr:tocard-inc/enseeiht/projet-web
This commit is contained in:
commit
54d679bc97
|
@ -83,7 +83,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="pixel-container">
|
||||
<table>
|
||||
<table id="pixelTable">
|
||||
<tr>
|
||||
<td class="pixel" id="r0c0">
|
||||
<div class="info-pixel">
|
||||
|
@ -806,6 +806,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript" src="pixels.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
31
src/front/pixels.js
Normal file
31
src/front/pixels.js
Normal file
|
@ -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";
|
||||
}
|
Loading…
Reference in a new issue