mirror of
https://github.com/jstrieb/urlpages.git
synced 2025-03-16 13:28:26 +01:00
Add short link button for code
This commit is contained in:
parent
14beaf04b9
commit
b72caa0b91
2 changed files with 27 additions and 7 deletions
editor
|
@ -63,9 +63,6 @@ function update() {
|
||||||
// Update the URL for the "Get Link" button
|
// Update the URL for the "Get Link" button
|
||||||
document.getElementById("getLinkLink").href = getViewLink(html);
|
document.getElementById("getLinkLink").href = getViewLink(html);
|
||||||
|
|
||||||
// Update the URL for the "Short Link" button
|
|
||||||
document.getElementById("url").value = getViewLink(html);
|
|
||||||
|
|
||||||
// Update the download link
|
// Update the download link
|
||||||
document.getElementById("downloadLink").href = `data:text/html,${html}`
|
document.getElementById("downloadLink").href = `data:text/html,${html}`
|
||||||
|
|
||||||
|
@ -73,7 +70,29 @@ function update() {
|
||||||
window.frames[0].location.replace(`data:text/html,${html}`);
|
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() {
|
function showCopyCodePrompt() {
|
||||||
var data = {
|
var data = {
|
||||||
"css" : document.getElementById("css").value,
|
"css" : document.getElementById("css").value,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Create and edit URL pages</title>
|
<title>URL Pages Editor</title>
|
||||||
<link rel="stylesheet" type="text/css" href="main.css">
|
<link rel="stylesheet" type="text/css" href="main.css">
|
||||||
<script src="editor.js" type="text/javascript"></script>
|
<script src="editor.js" type="text/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -18,9 +18,10 @@
|
||||||
<form action="http://tinyurl.com/create.php" method="get" target="_blank">
|
<form action="http://tinyurl.com/create.php" method="get" target="_blank">
|
||||||
<input type="hidden" id="source" name="source" value="indexpage">
|
<input type="hidden" id="source" name="source" value="indexpage">
|
||||||
<input type="hidden" name="url" id="url" />
|
<input type="hidden" name="url" id="url" />
|
||||||
<button>Get Short Link</button>
|
<button onclick="setCodeUrl()">Get Short Link to Editor</button>
|
||||||
|
<button onclick="setViewUrl()">Get Short Link to Publish</button>
|
||||||
</form>
|
</form>
|
||||||
<button><a id="getLinkLink" href="" target="_blank">Get Link</a></button>
|
<button><a id="getLinkLink" href="" target="_blank">Get Link to Publish</a></button>
|
||||||
<button onclick="showCopyCodePrompt()">Copy Code</button>
|
<button onclick="showCopyCodePrompt()">Copy Code</button>
|
||||||
<button><a id="downloadLink" href="" target="_blank" download="export.html">Download Code</a></button>
|
<button><a id="downloadLink" href="" target="_blank" download="export.html">Download Code</a></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue