|
|
@ -2,6 +2,11 @@
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<title>sURL</title>
|
|
|
|
<title>sURL</title>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
|
|
|
<!-- PWA support -->
|
|
|
|
|
|
|
|
<link rel="manifest" href="/manifest.json">
|
|
|
|
|
|
|
|
<meta name="theme-color" content="#2F3BA2">
|
|
|
|
|
|
|
|
<meta name="description" content="short your url">
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="./sym/dark.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="./sym/dark.css">
|
|
|
|
<script src="./sym/script.js"></script>
|
|
|
|
<script src="./sym/script.js"></script>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
@ -14,39 +19,42 @@
|
|
|
|
socket.onerror = (error) => {
|
|
|
|
socket.onerror = (error) => {
|
|
|
|
console.log(`WebSocket error: ${error}`)
|
|
|
|
console.log(`WebSocket error: ${error}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
socket.onclose = () => {
|
|
|
|
socket.onclose = error => show_error('session timed out (refresh)')
|
|
|
|
document.getElementById('error-message').innerText = 'session timed out (refresh)'
|
|
|
|
|
|
|
|
document.getElementById('error-box').style.display = 'block'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.onmessage = (e) => {
|
|
|
|
socket.onmessage = (e) => {
|
|
|
|
console.log(e.data)
|
|
|
|
console.log(e.data)
|
|
|
|
let msg = e.data.split(";", 2)
|
|
|
|
let msg = e.data.split(";", 2)
|
|
|
|
if (msg[0] === 'error') {
|
|
|
|
if (msg[0] === 'error') show_error(msg[1])
|
|
|
|
document.getElementById('error-message').innerText = msg[1]
|
|
|
|
else if (msg[0] === 'surl') {
|
|
|
|
document.getElementById('error-box').style.display = 'block'
|
|
|
|
|
|
|
|
} else if (msg[0] === 'surl') {
|
|
|
|
|
|
|
|
document.getElementById('surl-input').value = msg[1]
|
|
|
|
document.getElementById('surl-input').value = msg[1]
|
|
|
|
document.getElementById('new-user-box').style.display = 'block'
|
|
|
|
document.getElementById('surl-popup').style.display = 'block'
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function short_url(){
|
|
|
|
|
|
|
|
socket.send('long_url '+document.getElementById('name-input').value)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function copy_url() {
|
|
|
|
function copy_url() {
|
|
|
|
document.getElementById('surl-input').select();
|
|
|
|
document.getElementById('surl-input').select()
|
|
|
|
document.execCommand("copy");
|
|
|
|
document.execCommand("copy")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//document.surl_form.action = surl_submit()
|
|
|
|
|
|
|
|
function lurl_submit() {
|
|
|
|
|
|
|
|
socket.send('long_url;'+document.getElementById('longurl-input').value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_error(msg) {
|
|
|
|
|
|
|
|
let error_style = document.getElementById('error-box').style
|
|
|
|
|
|
|
|
document.getElementById('error-message').innerText = msg
|
|
|
|
|
|
|
|
error_style.display = "block"
|
|
|
|
|
|
|
|
error_style.animation = "slide-from-left alternate 0.2s"
|
|
|
|
|
|
|
|
setTimeout(to => {error_style.animation = ""}, 200)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<body>
|
|
|
|
<div class="login">
|
|
|
|
<div class="input-box">
|
|
|
|
<div class="title">short your url</div>
|
|
|
|
<div class="title">short your url</div>
|
|
|
|
<form name="search" action="javascript:socket.send('long_url;'+document.getElementById('name-input').value)" method="POST">
|
|
|
|
<form name="surl_form" action="javascript:lurl_submit()">
|
|
|
|
<div class="inputbox" id="name">
|
|
|
|
<div class="input-field" id="longurl">
|
|
|
|
<input class="input" id="name-input" type="text" onblur="deselected('name');" onfocus="selected('name');" name="url" value="" maxlength="2000" placeholder="https://your.long.url/junk">
|
|
|
|
<input class="input" id="longurl-input" type="text" onblur="deselected('longurl');" onfocus="selected('longurl');" name="url" value="" maxlength="2000" placeholder="https://your.long.url/junk">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input type="hidden" value="search" name="login">
|
|
|
|
<input type="hidden" value="search" name="login">
|
|
|
|
<a href="javascript:socket.send('long_url;'+document.getElementById('name-input').value)">
|
|
|
|
<a href="javascript:lurl_submit()">
|
|
|
|
<div class="btn-blue" id="short-btn">
|
|
|
|
<div class="btn-blue" id="short-btn">
|
|
|
|
<div class="btn-text">short</div>
|
|
|
|
<div class="btn-text">short</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -54,10 +62,10 @@
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="box-dark" id="new-user-box">
|
|
|
|
<div class="box-dark" id="surl-popup">
|
|
|
|
<div class="login">
|
|
|
|
<div class="input-box">
|
|
|
|
<div class="title2">your sURL:</div>
|
|
|
|
<div class="title2">your sURL:</div>
|
|
|
|
<div class="inputbox" id="surl">
|
|
|
|
<div class="input-field" id="surl">
|
|
|
|
<input class="input" id="surl-input" type="text" onblur="deselected('surl');" onfocus="selected('surl');" size="30" value="" maxlength="20" placeholder="surl">
|
|
|
|
<input class="input" id="surl-input" type="text" onblur="deselected('surl');" onfocus="selected('surl');" size="30" value="" maxlength="20" placeholder="surl">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input type="hidden" value="search" name="login">
|
|
|
|
<input type="hidden" value="search" name="login">
|
|
|
@ -65,13 +73,13 @@
|
|
|
|
<div class="btn-text">copy</div>
|
|
|
|
<div class="btn-text">copy</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div onclick="visible('new-user-box','off')" style="position: absolute; top:5px; right: 5px;" class="sym_btn-invisible">
|
|
|
|
<div onclick="this.parentNode.style.display = 'none'" style="position: absolute; top:5px; right: 5px;" class="sym_btn-invisible">
|
|
|
|
<img class="icon" src="sym/ic_close_white_24px.svg" />
|
|
|
|
<img class="icon" src="./sym/ic_close_white_24px.svg" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="error-box" class="error">
|
|
|
|
<div id="error-box" class="error">
|
|
|
|
<div onclick="document.getElementById('error-box').style.display = 'none'" style="position: absolute; top:5px; right: 5px;" class="sym_btn-invisible">
|
|
|
|
<div onclick="this.parentNode.style.display = 'none'" style="position: absolute; top:5px; right: 5px;" class="sym_btn-invisible">
|
|
|
|
<img class="icon" src="./sym/ic_close_white_24px.svg">
|
|
|
|
<img class="icon" src="./sym/ic_close_white_24px.svg">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="error-message" class="btn-text">
|
|
|
|
<div id="error-message" class="btn-text">
|
|
|
|