Skip to content

Commit 0c0d599

Browse files
committed
added homepages in json
1 parent 7b441bc commit 0c0d599

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

index.html

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ <h2>Tools</h2>
2323
<button onclick="sketchpad.mode = 'erase'">Erase</button>
2424
<input type="number" onchange="sketchpad.weight = parseFloat(this.value)" value="2">
2525
</div>
26+
<div>
27+
Homepages: <input id="homepages-input" type="text" onchange="website.homepages = JSON.parse(this.value)">
28+
</div>
2629
<h2>Timeline</h2>
2730
<p>When you have selected a position in the timeline, press <span class="key">Space</span> to start recording, and <span class="key">Space</span> again to stop recording.</p>
2831
<button onclick="if(!recording){clearSketchpad(); drawPage(page, 1);}">Refresh</button>
@@ -91,13 +94,13 @@ <h2>Timeline</h2>
9194

9295
/* Recording stuff */
9396

94-
var website = [{name: "ui", blocks: [], speed: 1}]
95-
var page = website[0]
97+
var website = {pages: [{name: "ui", blocks: [], speed: 1}], homepages:["ui"]}
98+
var page = website.pages[0]
9699
var current_index
97100
current_index = 0
98101
var activeBlockLinks
99102
activeBlockLinks = []
100-
setPage(website[0])
103+
setPage(website.pages[0])
101104
async function setPage(new_page) {
102105
/* clearSketchpad()*/
103106
page = new_page
@@ -318,7 +321,7 @@ <h2>Timeline</h2>
318321
let f = async function() {
319322
for(const pageName of pageNames) {
320323
if(cancel) return;
321-
await drawPage(website.find((page) => page.name == pageName), 1)
324+
await drawPage(website.pages.find((page) => page.name == pageName), 1)
322325
}
323326
}
324327
cancel = true
@@ -427,7 +430,7 @@ <h2>Timeline</h2>
427430
while(websiteInfo.firstChild){
428431
websiteInfo.removeChild(websiteInfo.firstChild);
429432
}
430-
for(const pageOf of website) {
433+
for(const pageOf of website.pages) {
431434
let button = document.createElement("button")
432435
button.innerText = pageOf.name
433436
button.addEventListener("click", (ev) => {
@@ -439,10 +442,12 @@ <h2>Timeline</h2>
439442
button.innerText = "+"
440443
button.addEventListener("click", (ev) => {
441444
let new_page = {name: "No name", speed: 1, blocks: []}
442-
website.push(new_page)
445+
website.pages.push(new_page)
443446
setPage(new_page)
444447
})
445448
websiteInfo.appendChild(button)
449+
let homePagesInput = document.querySelector("#homepages-input")
450+
homePagesInput.value = JSON.stringify(website.homepages);
446451
}
447452

448453
function save() {
@@ -462,7 +467,8 @@ <h2>Timeline</h2>
462467
}
463468
function loadJSON(file) {
464469
website = JSON.parse(file);
465-
page = website[0]
470+
displayWebsiteInfo()
471+
page = website.pages[0]
466472
displayPageInfo()
467473
displayTimeline()
468474
displayWebsiteInfo()
@@ -497,7 +503,8 @@ <h2>Timeline</h2>
497503
// it is available
498504
fetchJSONFile('written-website.json', function(data){
499505
loadJSON(data);
500-
gotoPage(["ui","home"])
506+
if(window.location.search.substr(1) != "modify")
507+
gotoPage(website.homepages)
501508
});
502509

503510
</script>

0 commit comments

Comments
 (0)