From fc0dbc4555b3c70341afa05644c03bfab63dfe78 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Fri, 13 Sep 2024 19:02:19 -0400 Subject: [PATCH] updates --- js/app.js | 23 ++++++++++++++++------- js/data.js | 12 +++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/js/app.js b/js/app.js index 7ced046..38323f0 100644 --- a/js/app.js +++ b/js/app.js @@ -1,7 +1,7 @@ let area = document.querySelector('#area-main'); let entries = []; let users = {}; -let fetchData; +let fetchData; let sum = 0; let doThings = false; let i = 0; @@ -18,21 +18,28 @@ async function genTree(treeId) { let us = users[entryDat.username]; - let s = 1 / ((new Date() - new Date(entryDat.datetime_created.$date)) + 1000*60*60); + let s = 1 / ((new Date() - new Date(entryDat.datetime_created.$date)) + 1000 * 60 * 60); sum += s; users[entryDat.username] = (us ? us : 0) + s; entry = entryDat.parent_id; } - + return entry; } async function main() { - fetchData = await fetch(`https://scratch.mit.edu/projects/${treeID}/remixtree/bare/`).then(x => x.json()); + // fetchData = await fetch(`https://scratch.mit.edu/projects/${treeID}/remixtree/bare/`).then(x => x.json()); + fetchData = await fetch(`https://hf.zenoverse.net/tree/`).then(x => x.json()); let latestData = await fetch(`https://hf.zenoverse.net/api/`).then(x => x.json()); let lid = latestData[0].id; + let i = 0; + while (!fetchData[lid]) { + i++; + lid = latestData[i].id; + } + while (fetchData[lid].children.length > 0) { let ch = fetchData[lid].children; let ch2 = ch.filter(x => fetchData[x].children.length > 0); @@ -45,13 +52,15 @@ async function main() { let params = new URL(window.location).searchParams; - entries.forEach((x,i) => x && fetchData[x] ? (fetchData[x].id = entries.length - i - 2) : null); + entries.forEach((x, i) => x && fetchData[x] ? (fetchData[x].id = entries.length - i - 2) : null); let start = params.get('start') * 1; let end = params.get('end') * 1; + end = Math.min(end,entries.length-2); + if (start && end) { - entries = entries.splice(entries.length - end - 2,end - start + 1); + entries = entries.splice(entries.length - end - 2, end - start + 1); } doThings = true; @@ -60,7 +69,7 @@ async function main() { .map(x => `${x} ${Math.trunc(users[x] / sum * 100000) / 1000}%`) .join(', '); // Doesn't need to be sanitized (hopefully) - let newEras = importedEras.split('\n').map(x => x.split('-')).map(x => ({start: x[0] * 1, end: x[1] * 1, name: x[2].slice(1)})); + let newEras = importedEras.split('\n').map(x => x.split('-')).map(x => ({ start: x[0] * 1, end: x[1] * 1, name: x[2].slice(1) })); eras = [...eras, ...newEras]; diff --git a/js/data.js b/js/data.js index b7d3fed..e3467a5 100644 --- a/js/data.js +++ b/js/data.js @@ -435,7 +435,17 @@ let eras = [ { 'name': 'Welded Eon', 'start': 7647, - 'end': 8218 + 'end': 8276 }, + { + 'name': 'Unstroyed Eon', + 'start': 8277, + 'end': 8467 + }, + { + 'name': 'Post-Dzje Eon', + 'start': 8468, + 'end': 9000 + }, ];