Add TinyURL shortlink button

This commit is contained in:
Jacob Strieb 2019-06-30 01:34:31 -07:00
parent b7d901b0af
commit 14beaf04b9
3 changed files with 14 additions and 1 deletions

View File

@ -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}`

View File

@ -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>

View File

@ -41,3 +41,7 @@ a, button {
bottom: 0;
right: 0;
}
form {
display: inline;
}