From c4b5457891fc05be8d44f036415acadb8ded3cde Mon Sep 17 00:00:00 2001 From: Pitu Date: Tue, 17 Jan 2017 18:55:35 -0300 Subject: Change from gallery to album --- public/js/panel.js | 133 ++++++++--------------------------------------------- 1 file changed, 18 insertions(+), 115 deletions(-) (limited to 'public') diff --git a/public/js/panel.js b/public/js/panel.js index 27af9f8..e008abd 100644 --- a/public/js/panel.js +++ b/public/js/panel.js @@ -106,126 +106,29 @@ panel.getUploads = function(){ xhr.send(null); } -window.onload = function () { - panel.preparePage(); -} - -/* - var page; - - if(!localStorage.admintoken) - return askForToken(); - - prepareDashboard(); - - function askForToken(){ - document.getElementById('tokenSubmit').addEventListener('click', function(){ - checkToken(); - }); - - function checkToken(){ - var xhr = new XMLHttpRequest(); - - xhr.onreadystatechange = function() { - if (xhr.readyState == XMLHttpRequest.DONE) { - try{ - - var json = JSON.parse(xhr.responseText); - if(json.success === false) - return alert(json.description); - - localStorage.admintoken = document.getElementById('token').value; - prepareDashboard(); - - }catch(e){ - console.log(e); - } +panel.getGalleries = function(){ + var xhr = new XMLHttpRequest(); - console.log(xhr.responseText); - // xhr.responseText - } - } - xhr.open('GET', '/api/token/verify', true); - xhr.setRequestHeader('type', 'admin'); - xhr.setRequestHeader('token', document.getElementById('token').value); - xhr.send(null); - } - } + xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + + var json = JSON.parse(xhr.responseText); + if(json.success === false) + return alert(json.description); - function prepareDashboard(){ - page = document.getElementById('page'); - document.getElementById('auth').style.display = 'none'; - document.getElementById('dashboard').style.display = 'block'; - document.getElementById('itemUploads').addEventListener('click', function(){ - getUploads(); - }); - document.getElementById('itemManageGallery').addEventListener('click', function(){ - getGalleries(); - }); - } + localStorage.admintoken = token; + panel.token = token; + return panel.prepareDashboard(); - function getUploads(){ - page.innerHTML = ''; - var xhr = new XMLHttpRequest(); - - xhr.onreadystatechange = function() { - if(xhr.readyState == XMLHttpRequest.DONE){ - - if(xhr.responseText === 'not-authorized') - return notAuthorized(); - - var json = JSON.parse(xhr.responseText); - - var container = document.createElement('div'); - container.innerHTML = ` - - - - - - - - - - -
FileGalleryDate
`; - page.appendChild(container); - - var table = document.getElementById('table'); - - for(var item of json){ - - var tr = document.createElement('tr'); - tr.innerHTML = ` - - ${item.file} - ${item.gallery} - ${item.date} - - `; - - table.appendChild(tr); - } - - } } - xhr.open('GET', '/api/uploads', true); - xhr.setRequestHeader('auth', localStorage.admintoken); - xhr.send(null); - } - - function getContent(item, value){ - let endpoint; - if(item === 'uploads') endpoint = '/api/uploads' - if(item === 'galleries') endpoint = '/api/uploads' - - } - - function notAuthorized() { - localStorage.removeItem("admintoken"); - location.reload(); } + xhr.open('GET', '/api/galleries', true); + xhr.setRequestHeader('auth', panel.token); + xhr.send(null); +} -*/ +window.onload = function () { + panel.preparePage(); +} -- cgit v1.2.3