From 9f3580396e0bca3dbf9ec712ce6183528b260fbd Mon Sep 17 00:00:00 2001 From: Jacob Strieb Date: Sun, 30 Jun 2019 05:22:59 -0700 Subject: [PATCH] Clean up a bit --- editor/editor.js | 90 +++++++++++++++++++++++++++++------------------ editor/index.html | 6 ++-- index.html | 5 +++ 3 files changed, 64 insertions(+), 37 deletions(-) diff --git a/editor/editor.js b/editor/editor.js index 62997a9..4e5051d 100644 --- a/editor/editor.js +++ b/editor/editor.js @@ -1,19 +1,13 @@ -/* Run once when the page is loaded */ -function initialize() { - // Get page data from the URL and load it into the boxes - if (window.location.hash) { - var b64 = window.location.hash.slice(1); - var json = window.atob(b64); - var data = JSON.parse(json); +/** + * editor/editor.js: the main code that runs what is referred to as the "editor" + * in the documentation + */ - document.getElementById("css").value = data["css"]; - document.getElementById("javascript").value = data["js"]; - document.getElementById("html").value = data["html"]; - } - update(); -} +/*** + * Helper functions + ***/ /* Return the HTML string for the page */ function getHTML(data) { @@ -47,28 +41,10 @@ function getViewLink(pageData) { } -/* Run each time a key is pressed on a text box */ -function update() { - var data = { - "css" : document.getElementById("css").value, - "js" : document.getElementById("javascript").value, - "html" : document.getElementById("html").value - }; - var html = encodeURIComponent(getHTML(data)); - - // Save encoded page data to the URL - window.location.hash = "#" + window.btoa(JSON.stringify(data)); - - // Update the URL for the "Get Link" button - document.getElementById("getLinkLink").href = getViewLink(html); - - // Update the download link - document.getElementById("downloadLink").href = `data:text/html,${html}` - - // Update the