From 14beaf04b94f9cecb1321d1268ab829c0adc80c3 Mon Sep 17 00:00:00 2001 From: Jacob Strieb <jstrieb@users.noreply.github.com> Date: Sun, 30 Jun 2019 01:34:31 -0700 Subject: [PATCH] Add TinyURL shortlink button --- editor/editor.js | 5 ++++- editor/index.html | 6 ++++++ editor/main.css | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/editor/editor.js b/editor/editor.js index 00b4c69..fd96160 100644 --- a/editor/editor.js +++ b/editor/editor.js @@ -43,7 +43,7 @@ ${data["html"]} /* Return a link to view the page */ function getViewLink(pageData) { - return `../#${window.btoa(pageData)}`; + return `http://jstrieb.github.io/urlpages/#${window.btoa(pageData)}`; } @@ -63,6 +63,9 @@ 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}` diff --git a/editor/index.html b/editor/index.html index 30c7c6e..474bd53 100644 --- a/editor/index.html +++ b/editor/index.html @@ -14,6 +14,12 @@ </div> <div id="buttons"> + <!-- Seemingly random attributes necessary for TinyUrl to accept the request --> + <form action="http://tinyurl.com/create.php" method="get" target="_blank"> + <input type="hidden" id="source" name="source" value="indexpage"> + <input type="hidden" name="url" id="url" /> + <button>Get Short Link</button> + </form> <button><a id="getLinkLink" href="" target="_blank">Get Link</a></button> <button onclick="showCopyCodePrompt()">Copy Code</button> <button><a id="downloadLink" href="" target="_blank" download="export.html">Download Code</a></button> diff --git a/editor/main.css b/editor/main.css index 459ad1d..b60a834 100644 --- a/editor/main.css +++ b/editor/main.css @@ -41,3 +41,7 @@ a, button { bottom: 0; right: 0; } + +form { + display: inline; +}