Add option to sideload js
This commit is contained in:
parent
450f848fac
commit
fb518cc56f
@ -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
30
sample.json
Normal 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",
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user