From b72caa0b91b09babb688c3711119658e96b68e76 Mon Sep 17 00:00:00 2001 From: Jacob Strieb Date: Sun, 30 Jun 2019 03:07:52 -0700 Subject: [PATCH] Add short link button for code --- editor/editor.js | 27 +++++++++++++++++++++++---- editor/index.html | 7 ++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/editor/editor.js b/editor/editor.js index fd96160..62997a9 100644 --- a/editor/editor.js +++ b/editor/editor.js @@ -63,9 +63,6 @@ function update() { // Update the URL for the "Get Link" button document.getElementById("getLinkLink").href = getViewLink(html); - // Update the URL for the "Short Link" button - document.getElementById("url").value = getViewLink(html); - // Update the download link document.getElementById("downloadLink").href = `data:text/html,${html}` @@ -73,7 +70,29 @@ function update() { window.frames[0].location.replace(`data:text/html,${html}`); } -/* Show a prompt with the HTML so the user can copy the code */ + +/* Set the TinyUrl form hidden 'url' field to the view URL */ +function setViewUrl() { + var data = { + "css" : document.getElementById("css").value, + "js" : document.getElementById("javascript").value, + "html" : document.getElementById("html").value + }; + + var html = encodeURIComponent(getHTML(data)); + + // Update the URL for the "Short Link" button + document.getElementById("url").value = getViewLink(html); +} + + +/* Set the TinyUrl form hidden 'url' field to the code URL */ +function setCodeUrl() { + document.getElementById("url").value = window.location.href; +} + + +/* Show a prompt with the HTML page data so the user can copy the code */ function showCopyCodePrompt() { var data = { "css" : document.getElementById("css").value, diff --git a/editor/index.html b/editor/index.html index 474bd53..bde3966 100644 --- a/editor/index.html +++ b/editor/index.html @@ -1,7 +1,7 @@ -Create and edit URL pages +URL Pages Editor @@ -18,9 +18,10 @@
- + +
- +