updates
This commit is contained in:
parent
212fce1dcf
commit
fc0dbc4555
2 changed files with 27 additions and 8 deletions
23
js/app.js
23
js/app.js
|
@ -1,7 +1,7 @@
|
||||||
let area = document.querySelector('#area-main');
|
let area = document.querySelector('#area-main');
|
||||||
let entries = [];
|
let entries = [];
|
||||||
let users = {};
|
let users = {};
|
||||||
let fetchData;
|
let fetchData;
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
let doThings = false;
|
let doThings = false;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
@ -18,21 +18,28 @@ async function genTree(treeId) {
|
||||||
|
|
||||||
let us = users[entryDat.username];
|
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;
|
sum += s;
|
||||||
users[entryDat.username] = (us ? us : 0) + s;
|
users[entryDat.username] = (us ? us : 0) + s;
|
||||||
entry = entryDat.parent_id;
|
entry = entryDat.parent_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
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 latestData = await fetch(`https://hf.zenoverse.net/api/`).then(x => x.json());
|
||||||
|
|
||||||
let lid = latestData[0].id;
|
let lid = latestData[0].id;
|
||||||
|
let i = 0;
|
||||||
|
while (!fetchData[lid]) {
|
||||||
|
i++;
|
||||||
|
lid = latestData[i].id;
|
||||||
|
}
|
||||||
|
|
||||||
while (fetchData[lid].children.length > 0) {
|
while (fetchData[lid].children.length > 0) {
|
||||||
let ch = fetchData[lid].children;
|
let ch = fetchData[lid].children;
|
||||||
let ch2 = ch.filter(x => fetchData[x].children.length > 0);
|
let ch2 = ch.filter(x => fetchData[x].children.length > 0);
|
||||||
|
@ -45,13 +52,15 @@ async function main() {
|
||||||
|
|
||||||
let params = new URL(window.location).searchParams;
|
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 start = params.get('start') * 1;
|
||||||
let end = params.get('end') * 1;
|
let end = params.get('end') * 1;
|
||||||
|
|
||||||
|
end = Math.min(end,entries.length-2);
|
||||||
|
|
||||||
if (start && end) {
|
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;
|
doThings = true;
|
||||||
|
@ -60,7 +69,7 @@ async function main() {
|
||||||
.map(x => `<a href='https://scratch.mit.edu/users/${x}'>${x}</a> <sub>${Math.trunc(users[x] / sum * 100000) / 1000}%</sub>`)
|
.map(x => `<a href='https://scratch.mit.edu/users/${x}'>${x}</a> <sub>${Math.trunc(users[x] / sum * 100000) / 1000}%</sub>`)
|
||||||
.join(', '); // Doesn't need to be sanitized (hopefully)
|
.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];
|
eras = [...eras, ...newEras];
|
||||||
|
|
||||||
|
|
12
js/data.js
12
js/data.js
|
@ -435,7 +435,17 @@ let eras = [
|
||||||
{
|
{
|
||||||
'name': 'Welded Eon',
|
'name': 'Welded Eon',
|
||||||
'start': 7647,
|
'start': 7647,
|
||||||
'end': 8218
|
'end': 8276
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Unstroyed Eon',
|
||||||
|
'start': 8277,
|
||||||
|
'end': 8467
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Post-Dzje Eon',
|
||||||
|
'start': 8468,
|
||||||
|
'end': 9000
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue