index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>loli-safe - A self hosted upload service</title>
  5. <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.0/css/bulma.min.css">
  6. <link rel="stylesheet" type="text/css" href="/css/style.css">
  7. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js"></script>
  8. </head>
  9. <body>
  10. <section class="hero is-fullheight has-text-centered">
  11. <div class="hero-body">
  12. <div class="container">
  13. <p id="b">
  14. <img class='logo' src="/images/logo.png">
  15. </p>
  16. <h1 id="bulma" class="title">
  17. loli-safe
  18. </h1>
  19. <h2 id="modern-framework" class="subtitle">
  20. A <strong>modern</strong> self-hosted file upload <strong>service</strong>
  21. </h2>
  22. <div class="columns">
  23. <div class="column"></div>
  24. <div class="column">
  25. <a class="button is-danger is-outlined" id='btnGithub' href='https://github.com/kanadeko/loli-safe' target='_blank'>View on Github</a>
  26. <div id="dropzone">Click here or drag and drop files</div>
  27. </div>
  28. <div class="column"></div>
  29. </div>
  30. <div id="uploads">
  31. <div id="template" class="columns">
  32. <div class="column">
  33. <p data-dz-size></p>
  34. </div>
  35. <div class="column">
  36. <p data-dz-name></p>
  37. </div>
  38. <div class="column">
  39. <progress class="progress is-primary" value="100" max="100" data-dz-uploadprogress></progress>
  40. <p data-dz-errormessage></p>
  41. <p class="link"></p>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </section>
  48. <script type="text/javascript">
  49. var maxSize = '512';
  50. var urlPrefix = '';
  51. var xhr = new XMLHttpRequest();
  52. xhr.onreadystatechange = function() {
  53. if (xhr.readyState == XMLHttpRequest.DONE) {
  54. console.log(xhr.responseText)
  55. if(xhr.responseText !== 'not-authorized'){
  56. document.getElementById('btnGithub').style.display = 'none';
  57. document.getElementById('dropzone').style.display = 'flex';
  58. }
  59. if(xhr.responseText.maxFileSize)
  60. maxSize = xhr.responseText.maxFileSize;
  61. if(xhr.responseText.urlPrefix)
  62. urlPrefix = xhr.responseText.urlPrefix + '/';
  63. }
  64. }
  65. xhr.open('GET', '/api/info', true);
  66. xhr.send(null);
  67. window.onload = function () {
  68. var previewNode = document.querySelector("#template");
  69. previewNode.id = "";
  70. var previewTemplate = previewNode.parentNode.innerHTML;
  71. previewNode.parentNode.removeChild(previewNode);
  72. var dropzone = new Dropzone('div#dropzone', {
  73. url: '/api/upload',
  74. paramName: 'file',
  75. maxFilesize: maxSize,
  76. parallelUploads: 2,
  77. uploadMultiple: false,
  78. previewsContainer: 'div#uploads',
  79. previewTemplate: previewTemplate,
  80. createImageThumbnails: false,
  81. maxFiles: 1000,
  82. autoProcessQueue: true
  83. });
  84. // Update the total progress bar
  85. dropzone.on("uploadprogress", function(file, progress) {
  86. file.previewElement.querySelector(".progress").style.width = progress + "%";
  87. });
  88. dropzone.on("success", function(file, response) {
  89. // Handle the responseText here. For example, add the text to the preview element:
  90. a = document.createElement('a');
  91. a.href = window.location.origin + '/' + urlPrefix + response.filename;
  92. a.target = '_blank';
  93. a.innerHTML = response.filename;
  94. file.previewTemplate.querySelector(".progress").style.display = 'none';
  95. file.previewTemplate.querySelector(".link").appendChild(a);
  96. });
  97. };
  98. </script>
  99. </body>
  100. </html>