filebrowser/_assets/_old/js/listing.js
Henrique Dias 23a352526b new file and dir (no buttons tho)
Former-commit-id: c47d326b86c3f829c7d9be560e2be259b46fd6e6 [formerly 4345eef3cd03012c898b8b96e0cb3a2a7215a206] [formerly 5afc1727a5a35c3b544f65fa518cd78e9155acb5 [formerly 6626398cdfaaa9eba8c127a9fd490bf39e790c7d]]
Former-commit-id: 7355b4d84fbebdb8d7af7f391d104e570183a84b [formerly c23033af68c62c775bfcbcc7daf43d0bc308cf79]
Former-commit-id: 704005d6b1b1f8702ac39cdef636eed6b2f973de
2017-06-29 18:55:16 +01:00

77 lines
1.6 KiB
JavaScript

'use strict'
listing.redefineDownloadURLs = function () {
let files = ''
for (let i = 0; i < selectedItems.length; i++) {
let url = document.getElementById(selectedItems[i]).dataset.url
files += url.replace(window.location.pathname, '') + ','
}
files = files.substring(0, files.length - 1)
files = encodeURIComponent(files)
let links = document.querySelectorAll('#download ul a')
Array.from(links).forEach(link => {
link.href = '?download=' + link.dataset.format + '&files=' + files
})
}
listing.newFilePrompt = function (event) {
event.preventDefault()
buttons.setLoading('new')
let name = event.currentTarget.querySelector('input').value
webdav.new(window.location.pathname + name)
.then(() => {
buttons.setDone('new')
listing.reload()
})
.catch(e => {
console.log(e)
buttons.setDone('new', false)
})
closePrompt(event)
return false
}
listing.addDoubleTapEvent = function () {
let items = document.getElementsByClassName('item'),
touches = {
id: '',
count: 0
}
Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => {
if (touches.id != file.id) {
touches.id = file.id
touches.count = 1
setTimeout(() => {
touches.count = 0
}, 300)
return
}
touches.count++
if (touches.count > 1) {
window.location = file.dataset.url
}
})
})
}
document.addEventListener('DOMContentLoaded', event => {
listing.addDoubleTapEvent()
if (user.AllowNew) {
buttons.new.addEventListener('click', listing.newFileButton)
}
})