From b2310b38a14ef15e790dc3d25659981a2e08b205 Mon Sep 17 00:00:00 2001 From: Adam Hovorka Date: Sun, 26 Apr 2020 15:40:35 -0600 Subject: Allow visiting pages directly via their ID --- main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 741e39c..7b8f761 100644 --- a/main.js +++ b/main.js @@ -136,14 +136,19 @@ function resizeTA(e) { } function renderPath() { - let path = location.hash.slice(2); + let path = location.hash.slice(1); const main = document.getElementById("main"); const o = main.cloneNode(false); state.addcount = 0; + if (!path.startsWith("/")) { + if (/^[0-9]+$/.test(path) && data.pages[+path] && + data.pages[+path].paths[0]) path = data.pages[+path].paths[0]; + else path = ""; + } else path = path.slice(1); state.editing = path.endsWith("edit"); if (state.editing) path = path.slice(0,-5); - if (!/[0-9]+(-[0-9]+)*/.test(path)) path = ""; + if (!/^[0-9]+(-[0-9]+)*$/.test(path)) path = ""; const pieces = path.split("-"); if (pieces[0]) for (let i=0; i