Add option to sideload js

This commit is contained in:
Joshua Ramon Enslin 2025-05-13 14:41:06 +02:00
parent 450f848fac
commit fb518cc56f
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 109 additions and 74 deletions

View File

@ -1,5 +1,8 @@
(async function() {
const data = { // const response = await fetch('./sample.json');
// const data = await response.json();
const data = {
"size_x" : 8, "size_x" : 8,
"size_y" : 8, "size_y" : 8,
@ -28,19 +31,19 @@ const data = {
2: "test", 2: "test",
} }
} };
const wrap = document.createElement("div"); const wrap = document.createElement("div");
wrap.id = "wrap"; wrap.id = "wrap";
const solutionArea = document.createElement("div"); const solutionArea = document.createElement("div");
const hintsArea = document.createElement("div"); const hintsArea = document.createElement("div");
document.body.appendChild(wrap); document.body.appendChild(wrap);
document.body.appendChild(solutionArea); document.body.appendChild(solutionArea);
document.body.appendChild(hintsArea); document.body.appendChild(hintsArea);
for (let i = 0; i < data.size_x; i++) { for (let i = 0; i < data.size_x; i++) {
/* /*
const row = document.createElement("div"); const row = document.createElement("div");
@ -91,9 +94,9 @@ for (let i = 0; i < data.size_x; i++) {
} }
} }
for (const hintId in data.hints) { for (const hintId in data.hints) {
hint = data.hints[hintId]; hint = data.hints[hintId];
@ -104,4 +107,6 @@ for (const hintId in data.hints) {
hintsArea.appendChild(li); hintsArea.appendChild(li);
} }
})();

30
sample.json Normal file
View File

@ -0,0 +1,30 @@
{
"size_x" : 8,
"size_y" : 8,
"cells" : {
// x-axis
1 : {
// y-axis
1 : {
"character" : "a",
"hidden" : false,
"hint" : 1,
"in_solution" : 3,
},
2 : {
"character" : "b",
// "hidden" : true,
}
}
},
"hints" : {
1: "hallo",
2: "test",
}
}