cdf12250c6
textarea -> div
43 lines
No EOL
1.3 KiB
Text
43 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 class=short_url_text ><%= $page_data->{'shorten_url'} %></div><button class="copy_short_url"><img src="/icons/copy2.png"></button></p>
|
|
</div>
|
|
<% } %>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
var copyTextareaBtn = document.querySelector('.copy_short_url');
|
|
|
|
copyTextareaBtn.addEventListener('click', function(event) {
|
|
var copyTextarea = document.querySelector('.short_url_text');
|
|
copyTextarea.focus();
|
|
copyTextarea.select();
|
|
|
|
try {
|
|
var successful = document.execCommand('copy');
|
|
var msg = successful ? 'successful' : 'unsuccessful';
|
|
console.log('Copying text command was ' + msg);
|
|
} catch (err) {
|
|
console.log('Oops, unable to copy');
|
|
}
|
|
});
|
|
</script>
|
|
</html> |