aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorkanadeko <[email protected]>2017-01-15 03:15:08 -0300
committerkanadeko <[email protected]>2017-01-15 03:15:08 -0300
commit0c6912d2c344253dc116d17a78ae364c53cb1eaa (patch)
tree67abef98a870cab5707a546b87b287b6b3205c13 /public
parentMerge branch 'master' of https://github.com/WeebDev/loli-safe (diff)
downloadhost.fuwn.me-0c6912d2c344253dc116d17a78ae364c53cb1eaa.tar.xz
host.fuwn.me-0c6912d2c344253dc116d17a78ae364c53cb1eaa.zip
stuff
Diffstat (limited to 'public')
-rw-r--r--public/css/style.css2
-rw-r--r--public/js/.DS_Storebin0 -> 6148 bytes
-rw-r--r--public/js/panel.js0
-rw-r--r--public/js/upload.js43
4 files changed, 34 insertions, 11 deletions
diff --git a/public/css/style.css b/public/css/style.css
index 324bb9d..fcd4923 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -50,7 +50,7 @@ div#dropzone:hover {
color: #fff;
}
-div#uploads, p#tokenContainer { display: none; }
+div#uploads, p#tokenContainer, a#panel { display: none; }
img.logo { height: 200px; margin-top: 20px; }
.dz-preview .dz-details { display: flex; }
diff --git a/public/js/.DS_Store b/public/js/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/public/js/.DS_Store
Binary files differ
diff --git a/public/js/panel.js b/public/js/panel.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/public/js/panel.js
diff --git a/public/js/upload.js b/public/js/upload.js
index 488ca3a..be15ace 100644
--- a/public/js/upload.js
+++ b/public/js/upload.js
@@ -1,15 +1,33 @@
window.onload = function () {
+ var USINGTOKEN;
var maxSize = '512';
- if(!localStorage.token){
- document.getElementById('tokenContainer').style.display = 'flex'
- document.getElementById("tokenSubmit").addEventListener("click", function(){
- getInfo(document.getElementById("token").value)
- });
- }else{
- getInfo(localStorage.token);
+ // First check to see if the service is using token or not
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == XMLHttpRequest.DONE) {
+ USINGTOKEN = JSON.parse(xhr.responseText).token;
+ prepareTokenThing();
+ }
+ }
+ xhr.open('GET', '/api/check', true);
+ xhr.send(null);
+
+ function prepareTokenThing(){
+
+ if(!USINGTOKEN) return getInfo();
+
+ if(!localStorage.token){
+ document.getElementById('tokenContainer').style.display = 'flex'
+ document.getElementById("tokenSubmit").addEventListener("click", function(){
+ getInfo(document.getElementById("token").value)
+ });
+ }else{
+ getInfo(localStorage.token);
+ }
+
}
function prepareDropzone(){
@@ -73,15 +91,20 @@ window.onload = function () {
document.getElementById('btnGithub').style.display = 'none';
document.getElementById('tokenContainer').style.display = 'none';
document.getElementById('uploadContainer').appendChild(div);
-
- if(xhr.responseText.maxFileSize) maxSize = xhr.responseText.maxFileSize;
+ document.getElementById('panel').style.display = 'block';
+
+ if(xhr.responseText.maxFileSize) maxSize = JSON.parse(xhr.responseText).maxFileSize;
if(token) localStorage.token = token;
+
prepareDropzone();
}
}
}
xhr.open('GET', '/api/info', true);
- xhr.setRequestHeader('auth', token);
+
+ if(token !== undefined)
+ xhr.setRequestHeader('auth', token);
+
xhr.send(null);
}
}; \ No newline at end of file