1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
window.addEventListener('load', async e => {
const frame = document.getElementById('frame');
const author = document.getElementById('author');
const linker = document.getElementById('linker');
linker.target = window.location.hash.substr(1);
const graph = await (await fetch(`https://graphpl.aleteoryx.me/load/${window.location.hash.substr(1)}`)).json()
if (frame.contentWindow.document.readyState != 'complete')
await new Promise((res, rej) => frame.contentWindow.addEventListener('load', e => {res();}));
author.innerText = graph.author ? graph.author : [
"a ghost",
"nobody",
"thine mother",
"god's mistake",
"the zodiac killer",
"tyleo, secretly",
"someone else",
"Danny Elfman",
"a rat in a cage",
"viewers like you"
][Math.round(Math.random() * 10)];
frame.contentWindow.postMessage({type: 'lock'});
frame.contentWindow.postMessage({type: 'loadGraph', graph: graph});
linker.addEventListener('click', e => {
let newwin = window.open('', window.location.hash.substr(1));
window.onmessage = ({data}) => {
console.log(data.type);
if(data.type == 'grapherLoaded') {
newwin.postMessage({type: 'loadGraph', graph: graph});
newwin.name = '';
window.onmessage = null;
}
}
})
})
|