101 lines
3.6 KiB
HTML
101 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Kakubovna: Download</title>
|
|
<link rel="stylesheet" href="/css/style.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Geologica:wght@800&display=swap" rel="stylesheet">
|
|
</head>
|
|
|
|
<body>
|
|
<div class="flex-container">
|
|
<div id="code-view" class="container vertical" style="display:none">
|
|
<input id="code" type="text" placeholder="Enter code">
|
|
<button onclick="checkUpload()">Submit</button>
|
|
<p id="status"></p>
|
|
</div>
|
|
<div id="file-view" class="container vertical" style="display:none">
|
|
<table>
|
|
<tr><td>filename.png</td><td><a target=”_blank” href="">Download</a></td></tr>
|
|
<tr><td>filename.png</td><td><a target=”_blank” href="">Download</a></td></tr>
|
|
<tr><td>filename.png</td><td><a target=”_blank” href="">Download</a></td></tr>
|
|
</table>
|
|
</div>
|
|
<div id="admin-file-view" class="container vertical" style="display:none">
|
|
<input id="code" type="text" placeholder="Enter code">
|
|
<button onclick="checkUpload()">Submit</button>
|
|
<p id="status"></p>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
var hash = "";
|
|
var adminHash = "";
|
|
handleUrl();
|
|
function handleUrl() {
|
|
console.log(document.location.pathname.split("/", 4));
|
|
path = document.location.pathname.split("/", 4)
|
|
if(path[2] !== undefined && path[2].length > 10 && path[2] === path[2].toUpperCase()) {
|
|
hash = path[2];
|
|
loadFiles();
|
|
document.getElementById("file-view").style = "";
|
|
if(path[3] !== undefined && path[3].length == 10 && path[3] === path[3].toUpperCase()) {
|
|
adminHash = path[3];
|
|
document.getElementById("admin-file-view").style = "";
|
|
}
|
|
} else {
|
|
document.getElementById("code-view").style = "";
|
|
}
|
|
}
|
|
codeInput = document.getElementById("code");
|
|
statusText = document.getElementById("status");
|
|
function checkUpload() {
|
|
if (!(codeInput.value.length > 10 && codeInput.value === codeInput.value.toUpperCase())) {
|
|
statusText.innerHTML = 'Wrong Code';
|
|
return;
|
|
}
|
|
|
|
fetch('/api/download/' + codeInput.value)
|
|
.then(
|
|
response => response.json()
|
|
).then(jsonResponse => {
|
|
console.log(jsonResponse);
|
|
|
|
if (jsonResponse.code == 404) {
|
|
statusText.innerHTML = 'Not Found';
|
|
} else if (jsonResponse.code == 200) {
|
|
statusText.innerHTML = 'Found';
|
|
window.location.href = document.location.protocol + "//" + document.location.host + "/download/" + codeInput.value
|
|
} else {
|
|
statusText.innerHTML = 'Error';
|
|
}
|
|
});
|
|
};
|
|
function loadFiles() {
|
|
var fileview = document.getElementById("file-view");
|
|
fetch('/api/download/' + hash)
|
|
.then(
|
|
response => response.json()
|
|
).then(jsonResponse => {
|
|
console.log(jsonResponse);
|
|
|
|
if (jsonResponse.code == 200) {
|
|
table = "<table>";
|
|
var i = 0
|
|
jsonResponse.result.files.forEach(file => {
|
|
table += "<tr><td>"+file.filename+"</td><td><a target=\”_blank\” href='"+document.location.protocol+"//"+document.location.host+"/download/"+hash+"/index/"+i+"'>Download</a></td></tr>";
|
|
i++;
|
|
});
|
|
table += "</table>";
|
|
fileview.innerHTML = table;
|
|
} else {
|
|
fileview.innerHTML = "<h1>Not Found</h1>";
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |