diff --git a/pages/dashboard.html b/pages/dashboard.html
index ac9870d..ef3f0e6 100644
--- a/pages/dashboard.html
+++ b/pages/dashboard.html
@@ -17,7 +17,7 @@
-
+
diff --git a/public/js/dashboard.js b/public/js/dashboard.js
index 2de7a47..6019c88 100644
--- a/public/js/dashboard.js
+++ b/public/js/dashboard.js
@@ -8,7 +8,9 @@ const panel = {
filesView: localStorage.filesView,
clipboardJS: undefined,
selectedFiles: [],
- selectAlbumContainer: undefined
+ selectAlbumContainer: undefined,
+ checkboxes: undefined,
+ lastSelected: undefined
}
panel.preparePage = () => {
@@ -199,7 +201,7 @@ panel.getUploads = (album, page, element) => {
div.innerHTML = `.${file.file.split('.').pop()}
`
}
div.innerHTML += `
-
+
`
table.appendChild(div)
+ panel.checkboxes = Array.from(table.getElementsByClassName('file-checkbox'))
}
} else {
let albumOrUser = 'Album'
@@ -267,7 +270,7 @@ panel.getUploads = (album, page, element) => {
tr.innerHTML = `
- |
+ |
${file.name} |
${displayAlbumOrUser} |
${file.size} |
@@ -298,6 +301,7 @@ panel.getUploads = (album, page, element) => {
`
table.appendChild(tr)
+ panel.checkboxes = Array.from(table.getElementsByClassName('file-checkbox'))
}
}
@@ -349,7 +353,35 @@ panel.selectAllFiles = element => {
element.title = element.checked ? 'Unselect all files' : 'Select all files'
}
-panel.selectFile = element => {
+panel.selectInBetween = (element, lastElement) => {
+ if (!element || !lastElement) { return }
+ if (element === lastElement) { return }
+ if (!panel.checkboxes || !panel.checkboxes.length) { return }
+
+ let thisIndex = panel.checkboxes.indexOf(element)
+ let lastIndex = panel.checkboxes.indexOf(lastElement)
+
+ const distance = thisIndex - lastIndex
+ if (distance >= -1 && distance <= 1) { return }
+
+ for (let i = 0; i < panel.checkboxes.length; i++) {
+ if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||
+ (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {
+ panel.checkboxes[i].checked = true
+ panel.selectedFiles.push(parseInt(panel.checkboxes[i].dataset.id))
+ }
+ }
+
+ localStorage.selectedFiles = JSON.stringify(panel.selectedFiles)
+}
+
+panel.selectFile = (element, event) => {
+ if (event.shiftKey && panel.lastSelected) {
+ panel.selectInBetween(element, panel.lastSelected)
+ } else {
+ panel.lastSelected = element
+ }
+
const id = parseInt(element.dataset.id)
if (isNaN(id)) { return }