- `
-
- table.appendChild(tr)
- }
}
-page.editAlbum = async id => {
- const album = page.albums.get(id)
+page.editAlbum = function (id) {
+ var album = page.albums[id]
if (!album) { return }
- const div = document.createElement('div')
+ var div = document.createElement('div')
div.innerHTML = `
@@ -898,7 +936,7 @@ page.editAlbum = async id => {
`
- const value = await swal({
+ swal({
title: 'Edit album',
icon: 'info',
content: div,
@@ -909,43 +947,47 @@ page.editAlbum = async id => {
}
}
})
- if (!value) { return }
+ .then(function (value) {
+ if (!value) { return }
- const response = await axios.post('api/albums/edit', {
- id,
- name: document.getElementById('_name').value,
- download: document.getElementById('_download').checked,
- public: document.getElementById('_public').checked,
- requestLink: document.getElementById('_requestLink').checked
- })
- .catch(error => {
- console.log(error)
- return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
+ axios.post('api/albums/edit', {
+ id,
+ name: document.getElementById('_name').value,
+ download: document.getElementById('_download').checked,
+ public: document.getElementById('_public').checked,
+ requestLink: document.getElementById('_requestLink').checked
+ })
+ .then(function (response) {
+ if (!response) { return }
+
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') {
+ return page.verifyToken(page.token)
+ } else {
+ return swal('An error occurred!', response.data.description, 'error')
+ }
+ }
+
+ if (response.data.identifier) {
+ swal('Success!', `Your album's new identifier is: ${response.data.identifier}.`, 'success')
+ } else if (response.data.name !== album.name) {
+ swal('Success!', `Your album was renamed to: ${response.data.name}.`, 'success')
+ } else {
+ swal('Success!', 'Your album was edited!', 'success')
+ }
+
+ page.getAlbumsSidebar()
+ page.getAlbums()
+ })
+ .catch(function (error) {
+ console.log(error)
+ return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
+ })
})
- if (!response) { return }
-
- if (response.data.success === false) {
- if (response.data.description === 'No token provided') {
- return page.verifyToken(page.token)
- } else {
- return swal('An error occurred!', response.data.description, 'error')
- }
- }
-
- if (response.data.identifier) {
- swal('Success!', `Your album's new identifier is: ${response.data.identifier}.`, 'success')
- } else if (response.data.name !== album.name) {
- swal('Success!', `Your album was renamed to: ${response.data.name}.`, 'success')
- } else {
- swal('Success!', 'Your album was edited!', 'success')
- }
-
- page.getAlbumsSidebar()
- page.getAlbums()
}
-page.deleteAlbum = async id => {
- const proceed = await swal({
+page.deleteAlbum = function (id) {
+ swal({
title: 'Are you sure?',
text: 'This won\'t delete your files, only the album!',
icon: 'warning',
@@ -964,250 +1006,260 @@ page.deleteAlbum = async id => {
}
}
})
- if (!proceed) { return }
+ .then(function (proceed) {
+ if (!proceed) { return }
- const response = await axios.post('api/albums/delete', {
- id,
- purge: proceed === 'purge'
- })
- .catch(error => {
- console.log(error)
- return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
+ axios.post('api/albums/delete', {
+ id,
+ purge: proceed === 'purge'
+ })
+ .then(function (response) {
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') {
+ return page.verifyToken(page.token)
+ } else {
+ return swal('An error occurred!', response.data.description, 'error')
+ }
+ }
+
+ swal('Deleted!', 'Your album has been deleted.', 'success')
+ page.getAlbumsSidebar()
+ page.getAlbums()
+ })
+ .catch(function (error) {
+ console.log(error)
+ return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
+ })
})
-
- if (response.data.success === false) {
- if (response.data.description === 'No token provided') {
- return page.verifyToken(page.token)
- } else {
- return swal('An error occurred!', response.data.description, 'error')
- }
- }
-
- swal('Deleted!', 'Your album has been deleted.', 'success')
- page.getAlbumsSidebar()
- page.getAlbums()
}
-page.submitAlbum = async element => {
+page.submitAlbum = function (element) {
page.isLoading(element, true)
- const response = await axios.post('api/albums', {
+ axios.post('api/albums', {
name: document.getElementById('albumName').value
})
- .catch(error => {
+ .then(function (response) {
+ if (!response) { return }
+
+ page.isLoading(element, false)
+
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') {
+ return page.verifyToken(page.token)
+ } else {
+ return swal('An error occurred!', response.data.description, 'error')
+ }
+ }
+
+ swal('Woohoo!', 'Album was created successfully', 'success')
+ page.getAlbumsSidebar()
+ page.getAlbums()
+ })
+ .catch(function (error) {
console.log(error)
page.isLoading(element, false)
return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
})
- if (!response) { return }
-
- page.isLoading(element, false)
-
- if (response.data.success === false) {
- if (response.data.description === 'No token provided') {
- return page.verifyToken(page.token)
- } else {
- return swal('An error occurred!', response.data.description, 'error')
- }
- }
-
- swal('Woohoo!', 'Album was created successfully', 'success')
- page.getAlbumsSidebar()
- page.getAlbums()
}
-page.getAlbumsSidebar = async () => {
- const response = await axios.get('api/albums/sidebar')
- .catch(error => {
+page.getAlbumsSidebar = function () {
+ axios.get('api/albums/sidebar')
+ .then(function (response) {
+ if (!response) { return }
+
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') {
+ return page.verifyToken(page.token)
+ } else {
+ return swal('An error occurred!', response.data.description, 'error')
+ }
+ }
+
+ var albumsContainer = document.getElementById('albumsContainer')
+ albumsContainer.innerHTML = ''
+
+ if (response.data.albums === undefined) { return }
+
+ for (var album of response.data.albums) {
+ var li = document.createElement('li')
+ var a = document.createElement('a')
+ a.id = album.id
+ a.innerHTML = album.name
+
+ a.addEventListener('click', function () {
+ page.getAlbum(this)
+ })
+
+ li.appendChild(a)
+ albumsContainer.appendChild(li)
+ }
+ })
+ .catch(function (error) {
console.log(error)
return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')
})
- if (!response) { return }
-
- if (response.data.success === false) {
- if (response.data.description === 'No token provided') {
- return page.verifyToken(page.token)
- } else {
- return swal('An error occurred!', response.data.description, 'error')
- }
- }
-
- const albumsContainer = document.getElementById('albumsContainer')
- albumsContainer.innerHTML = ''
-
- if (response.data.albums === undefined) { return }
-
- for (const album of response.data.albums) {
- const li = document.createElement('li')
- const a = document.createElement('a')
- a.id = album.id
- a.innerHTML = album.name
-
- a.addEventListener('click', function () {
- page.getAlbum(this)
- })
-
- li.appendChild(a)
- albumsContainer.appendChild(li)
- }
}
-page.getAlbum = album => {
+page.getAlbum = function (album) {
page.setActiveMenu(album)
page.getUploads(album.id)
}
-page.changeFileLength = async () => {
- const response = await axios.get('api/filelength/config')
- .catch(error => {
+page.changeFileLength = function () {
+ axios.get('api/filelength/config')
+ .then(function (response) {
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') {
+ return page.verifyToken(page.token)
+ } else {
+ return swal('An error occurred!', response.data.description, 'error')
+ }
+ }
+
+ page.dom.innerHTML = `
+
File name length
+
+
+
+
+
+
+
+
Default file name length is ${response.data.config.default} characters. ${response.data.config.userChangeable ? `Range allowed for user is ${response.data.config.min} to ${response.data.config.max} characters.` : 'Changing file name length is disabled at the moment.'}
Default file name length is ${response.data.config.default} characters. ${response.data.config.userChangeable ? `Range allowed for user is ${response.data.config.min} to ${response.data.config.max} characters.` : 'Changing file name length is disabled at the moment.'}