73 lines
2.3 KiB
HTML
73 lines
2.3 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="loadUpload()">Submit</button>
|
|
<p id="status"></p>
|
|
</div>
|
|
<div id="file-view" class="container vertical" style="display:none">
|
|
<input id="code" type="text" placeholder="Enter code">
|
|
<button onclick="loadUpload()">Submit</button>
|
|
<p id="status"></p>
|
|
</div>
|
|
<div id="admin-file-view" class="container vertical" style="display:none">
|
|
<input id="code" type="text" placeholder="Enter code">
|
|
<button onclick="loadUpload()">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].length > 10 && path[2] === path[2].toUpperCase()) {
|
|
hash = path[2];
|
|
if(path[3].length == 10 && path[3] === path[3].toUpperCase()) {
|
|
adminHash = path[3];
|
|
}
|
|
} else {
|
|
document.getElementById("code-view").style = "";
|
|
}
|
|
}
|
|
codeInput = document.getElementById("code");
|
|
statusText = document.getElementById("status");
|
|
function loadUpload() {
|
|
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';
|
|
} else {
|
|
statusText.innerHTML = 'Error';
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
</body>
|
|
|
|
</html> |