Browse Source

client: use name from location hash

master
Milan Pässler 1 year ago
parent
commit
4ea333a6fd
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      client/src/index.js

+ 16
- 3
client/src/index.js View File

@@ -130,25 +130,38 @@ function init() {
.force("charge", d3Force.forceManyBody())
.force("center", d3Force.forceCenter());

async function go() {
async function go(name) {
document.getElementById("derivation").blur();
document.getElementById("derivation").value = name;
window.location.hash = `#${name}`;
queryNum++;
queued = 0;
graph.nodes = {};
graph.links = [];
const name = document.getElementById("derivation").value;
const node = await fetchNode("name", name);
node.weight = 10;
addNode(node);
view.selectedNode = node;
}
document.getElementById("inputs").addEventListener("submit", function(event) {
const name = document.getElementById("derivation").value;
event.preventDefault();
go();
go(name);
return true;
});

drawGraph();

function goLocationHash() {
const name = window.location.hash.substr(1);
go(name);
}

if (window.location.hash.length) {
goLocationHash();
}

window.addEventListener("hashchange", goLocationHash);
}

function handleResize() {


Loading…
Cancel
Save