Updated dashboard.js and home.js

Continuation of the previous commit.
This commit is contained in:
Bobby Wibowo 2018-07-14 11:37:36 +07:00
parent 5e765f4935
commit fcdac004f3
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
2 changed files with 10 additions and 12 deletions

View File

@ -364,12 +364,12 @@ page.selectAllFiles = function (element) {
var table = document.getElementById('table')
var checkboxes = table.getElementsByClassName('file-checkbox')
for (var checkbox of checkboxes) {
var id = parseInt(checkbox.dataset.id)
for (var i = 0; i < checkboxes.length; i++) {
var id = parseInt(checkboxes[i].dataset.id)
if (isNaN(id)) { continue }
if (checkbox.checked !== element.checked) {
checkbox.checked = element.checked
if (checkbox.checked) {
if (checkboxes[i].checked !== element.checked) {
checkboxes[i].checked = element.checked
if (checkboxes[i].checked) {
page.selectedFiles.push(id)
} else {
page.selectedFiles.splice(page.selectedFiles.indexOf(id), 1)
@ -450,9 +450,9 @@ page.clearSelection = function () {
var table = document.getElementById('table')
var checkboxes = table.getElementsByClassName('file-checkbox')
for (var checkbox of checkboxes) {
if (checkbox.checked) {
checkbox.checked = false
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
checkboxes[i].checked = false
}
}

View File

@ -149,14 +149,12 @@ page.prepareAlbums = function () {
return swal('An error occurred!', response.data.description, 'error')
}
var albums = response.data.albums
// If the user doesn't have any albums we don't really need to display
// an album selection
if (albums.length === 0) { return }
if (!response.data.albums.length) { return }
// Loop through the albums and create an option for each album
for (var album of albums) {
for (var album of response.data.albums) {
var option = document.createElement('option')
option.value = album.id
option.innerHTML = album.name