shrl.be/templates/index.html.ep
2019-02-13 11:51:06 +03:00

42 lines
No EOL
1.3 KiB
Text

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/css/main.css" media="screen">
</head>
<body>
<div class=content>
<div class=title>
URL Shortener
</div>
<div class=shorten_form>
<form method=post>
<input type=text name=url class="url_input">
<input type=submit value=short!>
</form>
</div>
<% if (exists($page_data->{'url'})) { %>
<div class=url_data>
<p>source url: <a href='<%== $page_data->{'url'} %>'><%= $page_data->{'url'} %></a></p>
<p><div id='short_url_container' class=short_url_text ><%= $page_data->{'shorten_url'} %></div>
<button class="copy_short_url" onclick="CopyToClipboard('short_url_container')"><img src="/icons/copy2.png"></button></p>
</div>
<% } %>
</div>
</body>
<script>
function CopyToClipboard(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
}}
</script>
</html>