Merge branch 'master' of git.inpt.fr:tocard-inc/enseeiht/projet-web
This commit is contained in:
commit
211bbb3cb0
|
@ -15,6 +15,7 @@
|
||||||
document.getElementById("show-signup").checked = s;
|
document.getElementById("show-signup").checked = s;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/javascript" src="pixels.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -806,7 +807,6 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="pixels.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -1,31 +1,25 @@
|
||||||
debugger;
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
var url = "http://localhost:8080/api/pixel";
|
||||||
|
|
||||||
function readTextFile(file)
|
xmlhttp.onreadystatechange = function() {
|
||||||
{
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var rawFile = new XMLHttpRequest();
|
var json = JSON.parse(this.responseText);
|
||||||
rawFile.open("GET", file, false);
|
setPixels(json);
|
||||||
rawFile.onreadystatechange = function ()
|
|
||||||
{
|
|
||||||
if(rawFile.readyState === 4)
|
|
||||||
{
|
|
||||||
if(rawFile.status === 200 || rawFile.status == 0)
|
|
||||||
{
|
|
||||||
var allText = rawFile.responseText;
|
|
||||||
alert(allText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rawFile.send(null);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
xmlhttp.open("GET", url, true);
|
||||||
|
xmlhttp.send();
|
||||||
|
|
||||||
// fetch("https://URL/file").then((r)=>{r.text().then((d)=>{let json = d})})
|
function setPixels(json) {
|
||||||
const json = readTextFile("test.json");
|
console.log(json);
|
||||||
const obj = JSON.parse(json);
|
|
||||||
|
|
||||||
var table = document.getElementById("pixelTable");
|
var table = document.getElementById("pixelTable");
|
||||||
var num_columns = table.rows[0].cells.length;
|
var num_columns = table.rows[0].cells.length;
|
||||||
|
|
||||||
for (pixel in obj) {
|
for (i in json) {
|
||||||
var cell = table.rows[Math.floor(pixel.id / num_columns)].cells[pixel.id % num_columns];
|
var pixel = json[i]
|
||||||
cell.style.background = "#f00";
|
console.log(pixel)
|
||||||
|
var cell = table.rows[Math.floor((pixel.id - 1) / num_columns)].cells[(pixel.id - 1) % num_columns];
|
||||||
|
cell.style.background = pixel.color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue