aboutsummaryrefslogtreecommitdiffstats
path: root/grapher/script.js
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2022-02-06 16:09:29 +0000
committerAleteoryx <alyx@aleteoryx.me>2022-02-06 16:09:29 +0000
commitfb1876db725b1d96d3fb58d2a597a12e36ca7b39 (patch)
treee3fe932f2ba848dbb6b3f2f13816aead257a4d6a /grapher/script.js
parent21bc06407c450a3ae5643d5462c452ec92b3d782 (diff)
downloadRRCUtils-fb1876db725b1d96d3fb58d2a597a12e36ca7b39.tar.gz
RRCUtils-fb1876db725b1d96d3fb58d2a597a12e36ca7b39.tar.bz2
RRCUtils-fb1876db725b1d96d3fb58d2a597a12e36ca7b39.zip
permalinking is fully operational
Diffstat (limited to 'grapher/script.js')
-rw-r--r--grapher/script.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/grapher/script.js b/grapher/script.js
index a9ec156..5a8d8ef 100644
--- a/grapher/script.js
+++ b/grapher/script.js
@@ -221,7 +221,11 @@ function serializeGraph() {
}
function deserializeGraph(graph) {
+ for(const chip of chips) {
+ chip.el.remove();
+ }
chips.length = 0;
+ connections.length = 0
for (const chip of graph.chips) {
const newchip = newChip(chip.GUID);
@@ -258,6 +262,9 @@ function deserializeGraph(graph) {
});
}
}
+function loadGraphHandler({graph}) {
+ deserializeGraph(graph);
+}
var locked = false;
@@ -265,6 +272,22 @@ function lockGraph() {
locked = true;
document.getElementById('searchbox').remove();
document.getElementById('helpbox') .remove();
+ document.getElementById('plbox') .remove();
+}
+
+async function getPermalink() {
+ const linker = document.getElementById('linktarget');
+ const linkerp = document.getElementById('linkprefix');
+ const ab = document.getElementById('authorbox');
+
+ const ret = await fetch('https://graphpl.aleteoryx.me/save', {
+ method: 'POST',
+ body: JSON.stringify({...serializeGraph(), author: ab.value ? ab.value : undefined})
+ }).then(m => m.text())
+ console.log(ret);
+ linkerp.innerText = "Success! Permalinked at:"
+ linker.href = `https://cv2.aleteoryx.me/grapher/pl#${ret}`
+ linker.innerText = `https://cv2.aleteoryx.me/grapher/pl#${ret}`
}
window.onload = async function() {
@@ -450,4 +473,6 @@ window.onload = async function() {
requestAnimationFrame(updateanim);
})()
+
+ if(window.opener) opener.postMessage({type: 'grapherLoaded'});
}