diff --git a/js/2.0.0/init.js b/js/2.0.0/init.js index 148579d..9fda0c1 100644 --- a/js/2.0.0/init.js +++ b/js/2.0.0/init.js @@ -14,7 +14,7 @@ import setPassword, { } from "./scripts.js"; import parseFormOnSubmit from "./parseForm.js"; import { createStorageObj, storeSettings } from "./storage.js"; -import { loadNavBar, initTextBlocks } from "./web.js"; +import { loadNavBar, initTextBlocks, loadNewTemplate } from "./web.js"; window.activeState = { userId: "", @@ -145,6 +145,22 @@ function eventListeners() { } } }); + + //add url listener + window.addEventListener("hashchange", (e) => { + + let newURLArr = e.newURL.split("/"); + let template; + if (newURLArr != undefined) { + template = newURLArr[newURLArr.length -1]; + if (template != undefined) { + template = template.split("=")[1]; + } + } + + console.log(template); + //loadNewTemplate(template); + }); } init(); diff --git a/js/2.0.0/web.js b/js/2.0.0/web.js index 6266aad..714ff45 100644 --- a/js/2.0.0/web.js +++ b/js/2.0.0/web.js @@ -48,7 +48,6 @@ function loadTemplate(template, newFlag = false, loadOnly = false) { } else { cdata = retrieveData("userInputForce"); } - console.log(cdata); if (cdata != "") { if (cdata != null) { retrieveForm(cdata); @@ -136,6 +135,7 @@ function loadNavBar() { divMob.addEventListener("click", (e) => { if (e.target && e.target.matches("a.w3-bar-item")) { + e.preventDefault; let template = e.target.dataset.template; if (template == "!createNew") { createTemplate();