mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-07 12:21:33 +00:00
116 lines
3.5 KiB
HTML
116 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>loli-safe - A self hosted upload service</title>
|
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
|
|
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<section class="hero is-fullheight has-text-centered">
|
|
<div class="hero-body">
|
|
<div class="container">
|
|
<p id="b">
|
|
<img class='logo' src="/images/logo.png">
|
|
</p>
|
|
<h1 id="bulma" class="title">
|
|
loli-safe
|
|
</h1>
|
|
<h2 id="modern-framework" class="subtitle">
|
|
A <strong>modern</strong> self-hosted file upload <strong>service</strong>
|
|
</h2>
|
|
|
|
<div class="columns">
|
|
<div class="column"></div>
|
|
<div class="column">
|
|
<a class="button is-danger is-outlined" id='btnGithub' href='https://github.com/kanadeko/loli-safe' target='_blank'>View on Github</a>
|
|
<div id="dropzone">Click here or drag and drop files</div>
|
|
</div>
|
|
<div class="column"></div>
|
|
</div>
|
|
|
|
<div id="uploads">
|
|
<div id="template" class="columns">
|
|
<div class="column">
|
|
<p data-dz-size></p>
|
|
</div>
|
|
<div class="column">
|
|
<p data-dz-name></p>
|
|
</div>
|
|
<div class="column">
|
|
<progress class="progress is-primary" value="100" max="100" data-dz-uploadprogress></progress>
|
|
<p data-dz-errormessage></p>
|
|
<p class="link"></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var maxSize = '512';
|
|
var urlPrefix = '';
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState == XMLHttpRequest.DONE) {
|
|
console.log(xhr.responseText)
|
|
if(xhr.responseText !== 'not-authorized'){
|
|
document.getElementById('btnGithub').style.display = 'none';
|
|
document.getElementById('dropzone').style.display = 'flex';
|
|
}
|
|
if(xhr.responseText.maxFileSize)
|
|
maxSize = xhr.responseText.maxFileSize;
|
|
if(xhr.responseText.urlPrefix)
|
|
urlPrefix = xhr.responseText.urlPrefix + '/';
|
|
}
|
|
}
|
|
xhr.open('GET', '/api/info', true);
|
|
xhr.send(null);
|
|
|
|
window.onload = function () {
|
|
|
|
|
|
var previewNode = document.querySelector("#template");
|
|
previewNode.id = "";
|
|
var previewTemplate = previewNode.parentNode.innerHTML;
|
|
previewNode.parentNode.removeChild(previewNode);
|
|
|
|
var dropzone = new Dropzone('div#dropzone', {
|
|
url: '/api/upload',
|
|
paramName: 'file',
|
|
maxFilesize: maxSize,
|
|
parallelUploads: 2,
|
|
uploadMultiple: false,
|
|
previewsContainer: 'div#uploads',
|
|
previewTemplate: previewTemplate,
|
|
createImageThumbnails: false,
|
|
maxFiles: 1000,
|
|
autoProcessQueue: true
|
|
});
|
|
|
|
// Update the total progress bar
|
|
dropzone.on("uploadprogress", function(file, progress) {
|
|
file.previewElement.querySelector(".progress").style.width = progress + "%";
|
|
});
|
|
|
|
dropzone.on("success", function(file, response) {
|
|
// Handle the responseText here. For example, add the text to the preview element:
|
|
a = document.createElement('a');
|
|
a.href = window.location.origin + '/' + urlPrefix + response.filename;
|
|
a.target = '_blank';
|
|
a.innerHTML = response.filename;
|
|
|
|
file.previewTemplate.querySelector(".progress").style.display = 'none';
|
|
file.previewTemplate.querySelector(".link").appendChild(a);
|
|
});
|
|
|
|
};
|
|
</script>
|
|
|
|
</body>
|
|
</html> |