diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 9067f0b..1c607a3 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -16,8 +16,8 @@ const uploadsDir = path.join(__dirname, '..', config.uploads.folder) const chunkedUploads = Boolean(config.uploads.chunkSize) const chunksDir = path.join(uploadsDir, 'chunks') const maxSize = config.uploads.maxSize -const maxSizeBytes = parseInt(maxSize) * 1000 * 1000 -const urlMaxSizeBytes = parseInt(config.uploads.urlMaxSize) * 1000 * 1000 +const maxSizeBytes = parseInt(maxSize) * 1e6 +const urlMaxSizeBytes = parseInt(config.uploads.urlMaxSize) * 1e6 const storage = multer.diskStorage({ destination (req, file, cb) { @@ -181,11 +181,12 @@ uploadsController.actuallyUpload = async (req, res, user, albumid) => { upload(req, res, async error => { if (error) { - const expected = [ + // Suppress error logging for errors with these codes + const suppress = [ 'LIMIT_FILE_SIZE', 'LIMIT_UNEXPECTED_FILE' ] - if (expected.includes(error.code)) return erred(error.toString()) + if (error.code && suppress.includes(error.code)) return erred(error.toString()) return erred(error) } @@ -597,7 +598,7 @@ uploadsController.scanFiles = (req, infoMap) => { return `Threat found: ${result.virus}${result.lastIteration ? '' : ', and maybe more'}.` }).catch(error => { console.error(`ClamAV: ${error.toString()}.`) - return `ClamAV: ${error.code !== undefined ? `${error.code} , p` : 'P'}lease contact the site owner.` + return `ClamAV: ${error.code !== undefined ? `${error.code}, p` : 'P'}lease contact the site owner.` }) } diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 79eb264..44df6f4 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -298,71 +298,70 @@ utilsController.bulkDeleteFiles = async (field, values, user, set) => { const failed = [] const ismoderator = perms.is(user, 'moderator') await Promise.all(chunks.map((chunk, index) => { - // It's much too dirty to code the function below without async function - // eslint-disable-next-line no-async-promise-executor - return new Promise(async (resolve, reject) => { - const files = await db.table('files') - .whereIn(field, chunk) - .where(function () { - if (!ismoderator) - this.where('userid', user.id) - }) - .catch(reject) - - // Push files that could not be found in DB - failed.push.apply(failed, chunk.filter(v => !files.find(file => file[field] === v))) - - // Delete all found files physically - const deletedFiles = [] - await Promise.all(files.map(file => - utilsController.deleteFile(file.name) - .then(() => deletedFiles.push(file)) - .catch(error => { - failed.push(file[field]) - console.error(error) + const job = async () => { + try { + const files = await db.table('files') + .whereIn(field, chunk) + .where(function () { + if (!ismoderator) + this.where('userid', user.id) }) - )) - if (!deletedFiles.length) - return resolve() + // Push files that could not be found in DB + failed.push.apply(failed, chunk.filter(v => !files.find(file => file[field] === v))) - // Delete all found files from database - const deletedFromDb = await db.table('files') - .whereIn('id', deletedFiles.map(file => file.id)) - .del() - .catch(reject) + // Delete all found files physically + const deletedFiles = [] + await Promise.all(files.map(file => + utilsController.deleteFile(file.name) + .then(() => deletedFiles.push(file)) + .catch(error => { + failed.push(file[field]) + console.error(error) + }) + )) - if (set) - deletedFiles.forEach(file => { - const identifier = file.name.split('.')[0] - set.delete(identifier) - // console.log(`Removed ${identifier} from identifiers cache (bulkDeleteFiles)`) - }) + if (!deletedFiles.length) + return true - // Update albums if necessary - if (deletedFromDb) { - const albumids = [] - deletedFiles.forEach(file => { - if (file.albumid && !albumids.includes(file.albumid)) - albumids.push(file.albumid) - }) - await db.table('albums') - .whereIn('id', albumids) - .update('editedAt', Math.floor(Date.now() / 1000)) - .catch(console.error) + // Delete all found files from database + const deletedFromDb = await db.table('files') + .whereIn('id', deletedFiles.map(file => file.id)) + .del() + + if (set) + deletedFiles.forEach(file => { + const identifier = file.name.split('.')[0] + set.delete(identifier) + // console.log(`Removed ${identifier} from identifiers cache (bulkDeleteFiles)`) + }) + + // Update albums if necessary + if (deletedFromDb) { + const albumids = [] + deletedFiles.forEach(file => { + if (file.albumid && !albumids.includes(file.albumid)) + albumids.push(file.albumid) + }) + await db.table('albums') + .whereIn('id', albumids) + .update('editedAt', Math.floor(Date.now() / 1000)) + .catch(console.error) + } + + // Purge Cloudflare's cache if necessary + if (config.cloudflare.purgeCache) + utilsController.purgeCloudflareCache(deletedFiles.map(file => file.name), true, true) + .then(results => { + for (const result of results) + if (result.errors.length) + result.errors.forEach(error => console.error(`CF: ${error}`)) + }) + } catch (error) { + console.error(error) } - - // Purge Cloudflare's cache if necessary - if (config.cloudflare.purgeCache) - utilsController.purgeCloudflareCache(deletedFiles.map(file => file.name), true, true) - .then(results => { - for (const result of results) - if (result.errors.length) - result.errors.forEach(error => console.error(`CF: ${error}`)) - }) - - return resolve() - }).catch(console.error) + } + return new Promise(resolve => job().then(() => resolve())) })) return failed } diff --git a/lolisafe.js b/lolisafe.js index aa65b1d..8144281 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -166,22 +166,23 @@ const start = async () => { const scan = config.uploads.scan if (scan && scan.enabled) { - const created = await new Promise(async (resolve, reject) => { - if (!scan.ip || !scan.port) - return reject(new Error('clamd IP or port is missing')) + const createScanner = async () => { + try { + if (!scan.ip || !scan.port) + throw new Error('clamd IP or port is missing') - const ping = await clamd.ping(scan.ip, scan.port).catch(reject) - if (!ping) - return reject(new Error('Could not ping clamd')) + const version = await clamd.version(scan.ip, scan.port) + console.log(`${scan.ip}:${scan.port} ${version}`) - const version = await clamd.version(scan.ip, scan.port).catch(reject) - console.log(`${scan.ip}:${scan.port} ${version}`) - - const scanner = clamd.createScanner(scan.ip, scan.port) - safe.set('clam-scanner', scanner) - return resolve(true) - }).catch(error => console.error(error.toString())) - if (!created) return process.exit(1) + const scanner = clamd.createScanner(scan.ip, scan.port) + safe.set('clam-scanner', scanner) + return true + } catch (error) { + console.error(`ClamAV: ${error.toString()}`) + return false + } + } + if (!await createScanner()) return process.exit(1) } if (config.uploads.cacheFileIdentifiers) { diff --git a/public/css/home.css b/public/css/home.css index ec31346..967c40d 100644 --- a/public/css/home.css +++ b/public/css/home.css @@ -33,7 +33,7 @@ display: none; } -#maxFileSize { +#maxSize { font-size: 1rem; } diff --git a/public/js/album.js b/public/js/album.js index 4cd9eeb..673edb9 100644 --- a/public/js/album.js +++ b/public/js/album.js @@ -21,7 +21,7 @@ page.getPrettyBytes = function (num, si) { } window.onload = function () { - const elements = document.getElementsByClassName('file-size') + const elements = document.querySelectorAll('.file-size') for (let i = 0; i < elements.length; i++) elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\s*B$/i, ''))) diff --git a/public/js/auth.js b/public/js/auth.js index c248e19..44085de 100644 --- a/public/js/auth.js +++ b/public/js/auth.js @@ -56,19 +56,19 @@ page.verify = function () { window.onload = function () { page.verify() - page.user = document.getElementById('user') - page.pass = document.getElementById('pass') + page.user = document.querySelector('#user') + page.pass = document.querySelector('#pass') // Prevent default form's submit action - document.getElementById('authForm').addEventListener('submit', function (event) { + document.querySelector('#authForm').addEventListener('submit', function (event) { event.preventDefault() }) - document.getElementById('loginBtn').addEventListener('click', function () { + document.querySelector('#loginBtn').addEventListener('click', function () { page.do('login') }) - document.getElementById('registerBtn').addEventListener('click', function () { + document.querySelector('#registerBtn').addEventListener('click', function () { page.do('register') }) } diff --git a/public/js/dashboard.js b/public/js/dashboard.js index 8e7c4b7..f8ccfae 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -115,14 +115,13 @@ page.verifyToken = function (token, reloadOnError) { } page.prepareDashboard = function () { - page.dom = document.getElementById('page') + page.dom = document.querySelector('#page') page.dom.addEventListener('click', page.domClick, true) - // document.getElementById('auth').style.display = 'none' - document.getElementById('dashboard').style.display = 'block' + document.querySelector('#dashboard').style.display = 'block' if (page.permissions.moderator) { - const itemManageUploads = document.getElementById('itemManageUploads') + const itemManageUploads = document.querySelector('#itemManageUploads') itemManageUploads.removeAttribute('disabled') itemManageUploads.addEventListener('click', function () { page.setActiveMenu(this) @@ -131,14 +130,14 @@ page.prepareDashboard = function () { } if (page.permissions.admin) { - const itemServerStats = document.getElementById('itemServerStats') + const itemServerStats = document.querySelector('#itemServerStats') itemServerStats.removeAttribute('disabled') itemServerStats.addEventListener('click', function () { page.setActiveMenu(this) page.getServerStats() }) - const itemManageUsers = document.getElementById('itemManageUsers') + const itemManageUsers = document.querySelector('#itemManageUsers') itemManageUsers.removeAttribute('disabled') itemManageUsers.addEventListener('click', function () { page.setActiveMenu(this) @@ -146,37 +145,37 @@ page.prepareDashboard = function () { }) } - document.getElementById('itemUploads').addEventListener('click', function () { + document.querySelector('#itemUploads').addEventListener('click', function () { page.setActiveMenu(this) page.getUploads({ all: false }) }) - document.getElementById('itemDeleteByNames').addEventListener('click', function () { + document.querySelector('#itemDeleteByNames').addEventListener('click', function () { page.setActiveMenu(this) page.deleteByNames() }) - document.getElementById('itemManageGallery').addEventListener('click', function () { + document.querySelector('#itemManageGallery').addEventListener('click', function () { page.setActiveMenu(this) page.getAlbums() }) - document.getElementById('itemFileLength').addEventListener('click', function () { + document.querySelector('#itemFileLength').addEventListener('click', function () { page.setActiveMenu(this) page.changeFileLength() }) - document.getElementById('itemTokens').addEventListener('click', function () { + document.querySelector('#itemTokens').addEventListener('click', function () { page.setActiveMenu(this) page.changeToken() }) - document.getElementById('itemPassword').addEventListener('click', function () { + document.querySelector('#itemPassword').addEventListener('click', function () { page.setActiveMenu(this) page.changePassword() }) - const logoutBtn = document.getElementById('itemLogout') + const logoutBtn = document.querySelector('#itemLogout') logoutBtn.addEventListener('click', function () { page.logout() }) @@ -315,11 +314,12 @@ page.switchPage = function (action, element) { case 'page-goto': views.pageNum = parseInt(element.dataset.goto) return func(views, element) - case 'jump-to-page': - const jumpToPage = parseInt(document.getElementById('jumpToPage').value) + case 'jump-to-page': { + const jumpToPage = parseInt(document.querySelector('#jumpToPage').value) views.pageNum = isNaN(jumpToPage) ? 0 : (jumpToPage - 1) if (views.pageNum < 0) views.pageNum = 0 return func(views, element) + } } } @@ -480,7 +480,7 @@ page.getUploads = function ({ pageNum, album, all, filters } = {}, element) { ` page.fadeIn() - const table = document.getElementById('table') + const table = document.querySelector('#table') for (let i = 0; i < files.length; i++) { const upload = files[i] @@ -553,7 +553,7 @@ page.getUploads = function ({ pageNum, album, all, filters } = {}, element) { ` page.fadeIn() - const table = document.getElementById('table') + const table = document.querySelector('#table') for (let i = 0; i < files.length; i++) { const upload = files[i] @@ -597,7 +597,7 @@ page.getUploads = function ({ pageNum, album, all, filters } = {}, element) { } if (allSelected && files.length) { - const selectAll = document.getElementById('selectAll') + const selectAll = document.querySelector('#selectAll') if (selectAll) selectAll.checked = true } @@ -771,7 +771,7 @@ page.clearSelection = function () { localStorage[lsKeys.selected[page.currentView]] = '[]' page.selected[page.currentView] = [] - const selectAll = document.getElementById('selectAll') + const selectAll = document.querySelector('#selectAll') if (selectAll) selectAll.checked = false return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success') @@ -809,14 +809,14 @@ page.filtersHelp = function (element) { } page.filterUploads = function (element) { - const filters = document.getElementById('filters').value + const filters = document.querySelector('#filters').value page.getUploads({ all: true, filters }, element) } page.viewUserUploads = function (id) { const user = page.cache.users[id] if (!user) return - page.setActiveMenu(document.getElementById('itemManageUploads')) + page.setActiveMenu(document.querySelector('#itemManageUploads')) page.getUploads({ all: true, filters: `user:${user.username.replace(/ /g, '\\ ')}` }) } @@ -944,7 +944,7 @@ page.deleteByNames = function () { } page.deleteFileByNames = function () { - const names = document.getElementById('names').value + const names = document.querySelector('#names').value .split(/\r?\n/) .filter(function (n) { return n.trim().length @@ -986,7 +986,7 @@ page.deleteFileByNames = function () { if (bulkdelete.data.failed && bulkdelete.data.failed.length) deleted -= bulkdelete.data.failed.length - document.getElementById('names').value = bulkdelete.data.failed.join('\n') + document.querySelector('#names').value = bulkdelete.data.failed.join('\n') swal('Deleted!', `${deleted} file${deleted === 1 ? ' has' : 's have'} been deleted.`, 'success') }).catch(function (error) { console.log(error) @@ -1058,7 +1058,7 @@ page.addFilesToAlbum = function (ids, callback) { }).then(function (choose) { if (!choose) return - const albumid = parseInt(document.getElementById('swalAlbum').value) + const albumid = parseInt(document.querySelector('#swalAlbum').value) if (isNaN(albumid)) return swal('An error occurred!', 'You did not choose an album.', 'error') @@ -1107,7 +1107,7 @@ page.addFilesToAlbum = function (ids, callback) { return } - const select = document.getElementById('swalAlbum') + const select = document.querySelector('#swalAlbum') // If the prompt was replaced, the container would be missing if (!select) return select.innerHTML += list.data.albums @@ -1180,7 +1180,7 @@ page.getAlbums = function () { page.fadeIn() const homeDomain = response.data.homeDomain - const table = document.getElementById('table') + const table = document.querySelector('#table') for (let i = 0; i < response.data.albums.length; i++) { const album = response.data.albums[i] @@ -1292,11 +1292,11 @@ page.editAlbum = function (id) { axios.post('api/albums/edit', { id, - name: document.getElementById('swalName').value, - description: document.getElementById('swalDescription').value, - download: document.getElementById('swalDownload').checked, - public: document.getElementById('swalPublic').checked, - requestLink: document.getElementById('swalRequestLink').checked + name: document.querySelector('#swalName').value, + description: document.querySelector('#swalDescription').value, + download: document.querySelector('#swalDownload').checked, + public: document.querySelector('#swalPublic').checked, + requestLink: document.querySelector('#swalRequestLink').checked }).then(function (response) { if (!response) return @@ -1370,8 +1370,8 @@ page.submitAlbum = function (element) { page.isLoading(element, true) axios.post('api/albums', { - name: document.getElementById('albumName').value, - description: document.getElementById('albumDescription').value + name: document.querySelector('#albumName').value, + description: document.querySelector('#albumDescription').value }).then(function (response) { if (!response) return @@ -1405,7 +1405,7 @@ page.getAlbumsSidebar = function () { return swal('An error occurred!', response.data.description, 'error') } - const albumsContainer = document.getElementById('albumsContainer') + const albumsContainer = document.querySelector('#albumsContainer') albumsContainer.innerHTML = '' if (response.data.albums === undefined) return @@ -1473,8 +1473,8 @@ page.changeFileLength = function () { ` page.fadeIn() - document.getElementById('setFileLength').addEventListener('click', function () { - page.setFileLength(document.getElementById('fileLength').value, this) + document.querySelector('#setFileLength').addEventListener('click', function () { + page.setFileLength(document.querySelector('#fileLength').value, this) }) }).catch(function (error) { console.log(error) @@ -1604,9 +1604,9 @@ page.changePassword = function () { ` page.fadeIn() - document.getElementById('sendChangePassword').addEventListener('click', function () { - if (document.getElementById('password').value === document.getElementById('passwordConfirm').value) - page.sendNewPassword(document.getElementById('password').value, this) + document.querySelector('#sendChangePassword').addEventListener('click', function () { + if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value) + page.sendNewPassword(document.querySelector('#password').value, this) else swal({ title: 'Password mismatch!', @@ -1644,7 +1644,7 @@ page.sendNewPassword = function (pass, element) { } page.setActiveMenu = function (activeItem) { - const menu = document.getElementById('menu') + const menu = document.querySelector('#menu') const items = menu.getElementsByTagName('a') for (let i = 0; i < items.length; i++) items[i].classList.remove('is-active') @@ -1753,7 +1753,7 @@ page.getUsers = function ({ pageNum } = {}, element) { ` page.fadeIn() - const table = document.getElementById('table') + const table = document.querySelector('#table') for (let i = 0; i < response.data.users.length; i++) { const user = response.data.users[i] @@ -1810,12 +1810,11 @@ page.getUsers = function ({ pageNum } = {}, element) { ` table.appendChild(tr) - // page.checkboxes.users = Array.from(table.getElementsByClassName('checkbox')) page.checkboxes.users = Array.from(table.querySelectorAll('.checkbox[data-action="select"]')) } if (allSelected && response.data.users.length) { - const selectAll = document.getElementById('selectAll') + const selectAll = document.querySelector('#selectAll') if (selectAll) selectAll.checked = true } @@ -1888,10 +1887,10 @@ page.editUser = function (id) { axios.post('api/users/edit', { id, - username: document.getElementById('swalUsername').value, - group: document.getElementById('swalGroup').value, - enabled: document.getElementById('swalEnabled').checked, - resetPassword: document.getElementById('swalResetPassword').checked + username: document.querySelector('#swalUsername').value, + group: document.querySelector('#swalGroup').value, + enabled: document.querySelector('#swalEnabled').checked, + resetPassword: document.querySelector('#swalResetPassword').checked }).then(function (response) { if (!response) return diff --git a/public/js/home.js b/public/js/home.js index 90cb733..98300fb 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -7,7 +7,7 @@ const page = { // configs from api/check private: null, enableUserAccounts: null, - maxFileSize: null, + maxSize: null, chunkSize: null, // store album id that will be used with upload requests @@ -27,12 +27,12 @@ page.checkIfPublic = function () { axios.get('api/check').then(function (response) { page.private = response.data.private page.enableUserAccounts = response.data.enableUserAccounts - page.maxFileSize = response.data.maxFileSize + page.maxSize = response.data.maxSize page.chunkSize = response.data.chunkSize page.preparePage() }).catch(function (error) { console.log(error) - const button = document.getElementById('loginToUpload') + const button = document.querySelector('#loginToUpload') button.classList.remove('is-loading') button.innerText = 'Error occurred. Reload the page?' return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error') @@ -44,7 +44,7 @@ page.preparePage = function () { if (page.token) { return page.verifyToken(page.token, true) } else { - const button = document.getElementById('loginToUpload') + const button = document.querySelector('#loginToUpload') button.href = 'auth' button.classList.remove('is-loading') @@ -84,7 +84,7 @@ page.verifyToken = function (token, reloadOnError) { page.prepareUpload = function () { // I think this fits best here because we need to check for a valid token before we can get the albums if (page.token) { - page.albumSelect = document.getElementById('albumSelect') + page.albumSelect = document.querySelector('#albumSelect') page.albumSelect.addEventListener('change', function () { page.album = parseInt(page.albumSelect.value) @@ -93,14 +93,14 @@ page.prepareUpload = function () { page.prepareAlbums() // Display the album selection - document.getElementById('albumDiv').style.display = 'flex' + document.querySelector('#albumDiv').style.display = 'flex' } - document.getElementById('maxFileSize').innerHTML = `Maximum upload size per file is ${page.maxFileSize}` - document.getElementById('loginToUpload').style.display = 'none' + document.querySelector('#maxSize').innerHTML = `Maximum upload size per file is ${page.maxSize}` + document.querySelector('#loginToUpload').style.display = 'none' if (!page.token && page.enableUserAccounts) - document.getElementById('loginLinkText').innerHTML = 'Create an account and keep track of your uploads' + document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads' const previewNode = document.querySelector('#tpl') page.previewTemplate = previewNode.innerHTML @@ -108,7 +108,7 @@ page.prepareUpload = function () { page.prepareDropzone() - const tabs = document.getElementById('tabs') + const tabs = document.querySelector('#tabs') if (tabs) { tabs.style.display = 'flex' const items = tabs.getElementsByTagName('li') @@ -117,12 +117,12 @@ page.prepareUpload = function () { page.setActiveTab(this.dataset.id) }) - document.getElementById('uploadUrls').addEventListener('click', function () { + document.querySelector('#uploadUrls').addEventListener('click', function () { page.uploadUrls(this) }) page.setActiveTab('tab-files') } else { - document.getElementById('tab-files').style.display = 'block' + document.querySelector('#tab-files').style.display = 'block' } } @@ -130,7 +130,6 @@ page.prepareAlbums = function () { const option = document.createElement('option') option.value = '' option.innerHTML = 'Upload to album' - option.disabled = true option.selected = true page.albumSelect.appendChild(option) @@ -164,7 +163,7 @@ page.prepareAlbums = function () { } page.setActiveTab = function (activeId) { - const items = document.getElementById('tabs').getElementsByTagName('li') + const items = document.querySelector('#tabs').getElementsByTagName('li') for (let i = 0; i < items.length; i++) { const tabId = items[i].dataset.id if (tabId === activeId) { @@ -178,7 +177,7 @@ page.setActiveTab = function (activeId) { } page.prepareDropzone = function () { - const tabDiv = document.getElementById('tab-files') + const tabDiv = document.querySelector('#tab-files') const div = document.createElement('div') div.className = 'control is-expanded' div.innerHTML = ` @@ -191,28 +190,31 @@ page.prepareDropzone = function () { ` tabDiv.querySelector('.dz-container').appendChild(div) + const maxSize = parseInt(page.maxSize) + const maxSizeBytes = maxSize * 1e6 + const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads') + page.dropzone = new Dropzone('#dropzone', { url: 'api/upload', paramName: 'files[]', - maxFilesize: parseInt(page.maxFileSize), + maxFilesize: maxSizeBytes / 1024 / 1024, // this option expects MiB parallelUploads: 2, uploadMultiple: false, previewsContainer, previewTemplate: page.previewTemplate, createImageThumbnails: false, - maxFiles: 1000, autoProcessQueue: true, headers: { token: page.token }, chunking: Boolean(page.chunkSize), - chunkSize: parseInt(page.chunkSize) * 1000000, // 1000000 B = 1 MB, - parallelChunkUploads: false, // when set to true, sometimes it often hangs with hundreds of parallel uploads + chunkSize: (parseInt(page.chunkSize) * 1e6), // the option below expects Bytes + parallelChunkUploads: false, // when set to true, it often hangs with hundreds of parallel uploads chunksUploaded (file, done) { file.previewElement.querySelector('.progress').setAttribute('value', 100) file.previewElement.querySelector('.progress').innerHTML = '100%' return axios.post('api/upload/finishchunks', { - // The API supports an array of multiple files + // This API supports an array of multiple files files: [{ uuid: file.upload.uuid, original: file.name, @@ -245,7 +247,7 @@ page.prepareDropzone = function () { }) page.dropzone.on('addedfile', function (file) { - tabDiv.getElementsByClassName('uploads')[0].style.display = 'block' + tabDiv.querySelector('.uploads').style.display = 'block' file.previewElement.querySelector('.name').innerHTML = file.name }) @@ -257,6 +259,8 @@ page.prepareDropzone = function () { // Update the total progress bar page.dropzone.on('uploadprogress', function (file, progress) { + // For some reason, chunked uploads fire 100% progress event + // for each chunk's successful uploads if (file.upload.chunked && progress === 100) return file.previewElement.querySelector('.progress').setAttribute('value', progress) file.previewElement.querySelector('.progress').innerHTML = `${progress}%` @@ -265,7 +269,6 @@ page.prepareDropzone = function () { page.dropzone.on('success', function (file, response) { if (!response) return file.previewElement.querySelector('.progress').style.display = 'none' - // file.previewElement.querySelector('.name').innerHTML = file.name if (response.success === false) file.previewElement.querySelector('.error').innerHTML = response.description @@ -275,6 +278,9 @@ page.prepareDropzone = function () { }) page.dropzone.on('error', function (file, error) { + if ((typeof error === 'string' && /^File is too big/.test(error)) || + error.description === 'MulterError: File too large') + error = `File too large (${(file.size / 1e6).toFixed(2)}MB).` page.updateTemplateIcon(file.previewElement, 'icon-block') file.previewElement.querySelector('.progress').style.display = 'none' file.previewElement.querySelector('.name').innerHTML = file.name @@ -285,7 +291,7 @@ page.prepareDropzone = function () { } page.uploadUrls = function (button) { - const tabDiv = document.getElementById('tab-urls') + const tabDiv = document.querySelector('#tab-urls') if (!tabDiv) return if (button.classList.contains('is-loading')) return @@ -298,19 +304,19 @@ page.uploadUrls = function (button) { function run () { const albumid = page.album - const previewsContainer = tabDiv.getElementsByClassName('uploads')[0] - const urls = document.getElementById('urls').value + const previewsContainer = tabDiv.querySelector('.uploads') + const urls = document.querySelector('#urls').value .split(/\r?\n/) .filter(function (url) { return url.trim().length }) - document.getElementById('urls').value = urls.join('\n') + document.querySelector('#urls').value = urls.join('\n') if (!urls.length) // eslint-disable-next-line prefer-promise-reject-errors return done('You have not entered any URLs.') - tabDiv.getElementsByClassName('uploads')[0].style.display = 'block' + tabDiv.querySelector('.uploads').style.display = 'block' const files = urls.map(function (url) { const previewTemplate = document.createElement('template') previewTemplate.innerHTML = page.previewTemplate.trim() @@ -373,14 +379,14 @@ page.updateTemplate = function (file, response) { const a = file.previewElement.querySelector('.link > a') const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js') - a.href = a.innerHTML = clipboard.dataset['clipboardText'] = response.url + a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url clipboard.parentElement.style.display = 'block' const exec = /.[\w]+(\?|$)/.exec(response.url) if (exec && exec[0] && page.imageExtensions.includes(exec[0].toLowerCase())) { const img = file.previewElement.querySelector('img') img.setAttribute('alt', response.name || '') - img.dataset['src'] = response.url + img.dataset.src = response.url img.style.display = '' img.onerror = function () { // Hide image elements that fail to load @@ -438,12 +444,12 @@ page.createAlbum = function () { }).then(function (value) { if (!value) return - const name = document.getElementById('swalName').value + const name = document.querySelector('#swalName').value axios.post('api/albums', { name, - description: document.getElementById('swalDescription').value, - download: document.getElementById('swalDownload').checked, - public: document.getElementById('swalPublic').checked + description: document.querySelector('#swalDescription').value, + download: document.querySelector('#swalDownload').checked, + public: document.querySelector('#swalPublic').checked }, { headers: { token: page.token @@ -453,9 +459,10 @@ page.createAlbum = function () { return swal('An error occurred!', response.data.description, 'error') const option = document.createElement('option') + page.albumSelect.appendChild(option) option.value = response.data.id option.innerHTML = name - page.albumSelect.appendChild(option) + option.selected = true swal('Woohoo!', 'Album was created successfully', 'success') }).catch(function (error) { @@ -497,7 +504,7 @@ window.onload = function () { elements_selector: '.field.uploads img' }) - document.getElementById('createAlbum').addEventListener('click', function () { + document.querySelector('#createAlbum').addEventListener('click', function () { page.createAlbum() }) } diff --git a/public/js/render.js b/public/js/render.js index 426d6ad..b325e61 100644 --- a/public/js/render.js +++ b/public/js/render.js @@ -93,7 +93,7 @@ page.doRenderSwal = function () { } page.getRenderVersion = function () { - const renderScript = document.getElementById('renderScript') + const renderScript = document.querySelector('#renderScript') if (renderScript && renderScript.dataset.version) return `?v=${renderScript.dataset.version}` return '' diff --git a/public/js/sharex.js b/public/js/sharex.js index a0bca36..7c4b53c 100644 --- a/public/js/sharex.js +++ b/public/js/sharex.js @@ -4,7 +4,7 @@ page.prepareShareX = function () { if (!page.token) return const origin = (location.hostname + location.pathname).replace(/\/(dashboard)?$/, '') const originClean = origin.replace(/\//g, '_') - const sharexElement = document.getElementById('ShareX') + const sharexElement = document.querySelector('#ShareX') const sharexFile = `{ "Name": "${originClean}", "DestinationType": "ImageUploader, FileUploader", diff --git a/public/libs/dropzone/dropzone.min.js b/public/libs/dropzone/dropzone.min.js index 3f667b0..f5a3c95 100644 --- a/public/libs/dropzone/dropzone.min.js +++ b/public/libs/dropzone/dropzone.min.js @@ -1,2 +1,2 @@ -/*! dropzone v5.4.0 | Copyright (c) 2012 Matias Meno */"use strict";function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function __guard__(e,t){return"undefined"!=typeof e&&null!==e?t(e):void 0}function __guardMethod__(e,t,i){return"undefined"!=typeof e&&null!==e&&"function"==typeof e[t]?i(e,t):void 0}var _createClass=function(){function e(e,t){for(var i=0;i1?i-1:0),r=1;r=o.length)break;s=o[l++]}else{if(l=o.next(),l.done)break;s=l.value}var u=s;u.apply(this,n)}}return this}},{key:"off",value:function(e,t){if(!this._callbacks||0===arguments.length)return this._callbacks={},this;var i=this._callbacks[e];if(!i)return this;if(1===arguments.length)return delete this._callbacks[e],this;for(var n=0;n=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;if(/(^| )dz-message($| )/.test(a.className)){e=a,a.className="dz-message";break}}e||(e=t.createElement('
'),this.element.appendChild(e));var l=e.getElementsByTagName("span")[0];return l&&(null!=l.textContent?l.textContent=this.options.dictFallbackMessage:null!=l.innerText&&(l.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize:function(e,t,i,n){var r={srcX:0,srcY:0,srcWidth:e.width,srcHeight:e.height},o=e.width/e.height;null==t&&null==i?(t=r.srcWidth,i=r.srcHeight):null==t?t=i*o:null==i&&(i=t/o),t=Math.min(t,r.srcWidth),i=Math.min(i,r.srcHeight);var a=t/i;if(r.srcWidth>t||r.srcHeight>i)if("crop"===n)o>a?(r.srcHeight=e.height,r.srcWidth=r.srcHeight*a):(r.srcWidth=e.width,r.srcHeight=r.srcWidth/a);else{if("contain"!==n)throw new Error("Unknown resizeMethod '"+n+"'");o>a?i=t/o:t=i*o}return r.srcX=(e.width-r.srcWidth)/2,r.srcY=(e.height-r.srcHeight)/2,r.trgWidth=t,r.trgHeight=i,r},transformFile:function(e,t){return(this.options.resizeWidth||this.options.resizeHeight)&&e.type.match(/image.*/)?this.resizeImage(e,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,t):t(e)},previewTemplate:'
\n
\n
\n
\n
\n
\n
\n
\n
\n \n Check\n \n \n \n \n \n
\n
\n \n Error\n \n \n \n \n \n \n \n
\n
',drop:function(e){return this.element.classList.remove("dz-drag-hover")},dragstart:function(e){},dragend:function(e){return this.element.classList.remove("dz-drag-hover")},dragenter:function(e){return this.element.classList.add("dz-drag-hover")},dragover:function(e){return this.element.classList.add("dz-drag-hover")},dragleave:function(e){return this.element.classList.remove("dz-drag-hover")},paste:function(e){},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(e){var i=this;if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer){e.previewElement=t.createElement(this.options.previewTemplate.trim()),e.previewTemplate=e.previewElement,this.previewsContainer.appendChild(e.previewElement);for(var n=e.previewElement.querySelectorAll("[data-dz-name]"),r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;l.textContent=e.name}for(var s=e.previewElement.querySelectorAll("[data-dz-size]"),u=!0,d=0,s=u?s:s[Symbol.iterator]();;){if(u){if(d>=s.length)break;l=s[d++]}else{if(d=s.next(),d.done)break;l=d.value}l.innerHTML=this.filesize(e.size)}this.options.addRemoveLinks&&(e._removeLink=t.createElement(''+this.options.dictRemoveFile+""),e.previewElement.appendChild(e._removeLink));for(var c=function(n){return n.preventDefault(),n.stopPropagation(),e.status===t.UPLOADING?t.confirm(i.options.dictCancelUploadConfirmation,function(){return i.removeFile(e)}):i.options.dictRemoveFileConfirmation?t.confirm(i.options.dictRemoveFileConfirmation,function(){return i.removeFile(e)}):i.removeFile(e)},p=e.previewElement.querySelectorAll("[data-dz-remove]"),h=!0,f=0,p=h?p:p[Symbol.iterator]();;){var v;if(h){if(f>=p.length)break;v=p[f++]}else{if(f=p.next(),f.done)break;v=f.value}var m=v;m.addEventListener("click",c)}}},removedfile:function(e){return null!=e.previewElement&&null!=e.previewElement.parentNode&&e.previewElement.parentNode.removeChild(e.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(e,t){if(e.previewElement){e.previewElement.classList.remove("dz-file-preview");for(var i=e.previewElement.querySelectorAll("[data-dz-thumbnail]"),n=!0,r=0,i=n?i:i[Symbol.iterator]();;){var o;if(n){if(r>=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;a.alt=e.name,a.src=t}return setTimeout(function(){return e.previewElement.classList.add("dz-image-preview")},1)}},error:function(e,t){if(e.previewElement){e.previewElement.classList.add("dz-error"),"String"!=typeof t&&t.error&&(t=t.error);for(var i=e.previewElement.querySelectorAll("[data-dz-errormessage]"),n=!0,r=0,i=n?i:i[Symbol.iterator]();;){var o;if(n){if(r>=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;a.textContent=t}}},errormultiple:function(){},processing:function(e){if(e.previewElement&&(e.previewElement.classList.add("dz-processing"),e._removeLink))return e._removeLink.textContent=this.options.dictCancelUpload},processingmultiple:function(){},uploadprogress:function(e,t,i){if(e.previewElement)for(var n=e.previewElement.querySelectorAll("[data-dz-uploadprogress]"),r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;"PROGRESS"===l.nodeName?l.value=t:l.style.width=t+"%"}},totaluploadprogress:function(){},sending:function(){},sendingmultiple:function(){},success:function(e){if(e.previewElement)return e.previewElement.classList.add("dz-success")},successmultiple:function(){},canceled:function(e){return this.emit("error",e,this.options.dictUploadCanceled)},canceledmultiple:function(){},complete:function(e){if(e._removeLink&&(e._removeLink.textContent=this.options.dictRemoveFile),e.previewElement)return e.previewElement.classList.add("dz-complete")},completemultiple:function(){},maxfilesexceeded:function(){},maxfilesreached:function(){},queuecomplete:function(){},addedfiles:function(){}},this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}},{key:"extend",value:function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),n=1;n=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;for(var u in s){var d=s[u];e[u]=d}}return e}}]),_createClass(t,[{key:"getAcceptedFiles",value:function(){return this.files.filter(function(e){return e.accepted}).map(function(e){return e})}},{key:"getRejectedFiles",value:function(){return this.files.filter(function(e){return!e.accepted}).map(function(e){return e})}},{key:"getFilesWithStatus",value:function(e){return this.files.filter(function(t){return t.status===e}).map(function(e){return e})}},{key:"getQueuedFiles",value:function(){return this.getFilesWithStatus(t.QUEUED)}},{key:"getUploadingFiles",value:function(){return this.getFilesWithStatus(t.UPLOADING)}},{key:"getAddedFiles",value:function(){return this.getFilesWithStatus(t.ADDED)}},{key:"getActiveFiles",value:function(){return this.files.filter(function(e){return e.status===t.UPLOADING||e.status===t.QUEUED}).map(function(e){return e})}},{key:"init",value:function(){var e=this;if("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(t.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length){var i=function t(){return e.hiddenFileInput&&e.hiddenFileInput.parentNode.removeChild(e.hiddenFileInput),e.hiddenFileInput=document.createElement("input"),e.hiddenFileInput.setAttribute("type","file"),(null===e.options.maxFiles||e.options.maxFiles>1)&&e.hiddenFileInput.setAttribute("multiple","multiple"),e.hiddenFileInput.className="dz-hidden-input",null!==e.options.acceptedFiles&&e.hiddenFileInput.setAttribute("accept",e.options.acceptedFiles),null!==e.options.capture&&e.hiddenFileInput.setAttribute("capture",e.options.capture),e.hiddenFileInput.style.visibility="hidden",e.hiddenFileInput.style.position="absolute",e.hiddenFileInput.style.top="0",e.hiddenFileInput.style.left="0",e.hiddenFileInput.style.height="0",e.hiddenFileInput.style.width="0",document.querySelector(e.options.hiddenInputContainer).appendChild(e.hiddenFileInput),e.hiddenFileInput.addEventListener("change",function(){var i=e.hiddenFileInput.files;if(i.length)for(var n=i,r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;e.addFile(l)}return e.emit("addedfiles",i),t()})};i()}this.URL=null!==window.URL?window.URL:window.webkitURL;for(var n=this.events,r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;this.on(l,this.options[l])}this.on("uploadprogress",function(){return e.updateTotalUploadProgress()}),this.on("removedfile",function(){return e.updateTotalUploadProgress()}),this.on("canceled",function(t){return e.emit("complete",t)}),this.on("complete",function(t){if(0===e.getAddedFiles().length&&0===e.getUploadingFiles().length&&0===e.getQueuedFiles().length)return setTimeout(function(){return e.emit("queuecomplete")},0)});var s=function(e){return e.stopPropagation(),e.preventDefault?e.preventDefault():e.returnValue=!1};return this.listeners=[{element:this.element,events:{dragstart:function(t){return e.emit("dragstart",t)},dragenter:function(t){return s(t),e.emit("dragenter",t)},dragover:function(t){var i=void 0;try{i=t.dataTransfer.effectAllowed}catch(e){}return t.dataTransfer.dropEffect="move"===i||"linkMove"===i?"move":"copy",s(t),e.emit("dragover",t)},dragleave:function(t){return e.emit("dragleave",t)},drop:function(t){return s(t),e.drop(t)},dragend:function(t){return e.emit("dragend",t)}}}],this.clickableElements.forEach(function(i){return e.listeners.push({element:i,events:{click:function(n){return(i!==e.element||n.target===e.element||t.elementInside(n.target,e.element.querySelector(".dz-message")))&&e.hiddenFileInput.click(),!0}}})}),this.enable(),this.options.init.call(this)}},{key:"destroy",value:function(){return this.disable(),this.removeAllFiles(!0),(null!=this.hiddenFileInput?this.hiddenFileInput.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,t.instances.splice(t.instances.indexOf(this),1)}},{key:"updateTotalUploadProgress",value:function(){var e=void 0,t=0,i=0,n=this.getActiveFiles();if(n.length){for(var r=this.getActiveFiles(),o=!0,a=0,r=o?r:r[Symbol.iterator]();;){var l;if(o){if(a>=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;t+=s.upload.bytesSent,i+=s.upload.total}e=100*t/i}else e=100;return this.emit("totaluploadprogress",e,i,t)}},{key:"_getParamName",value:function(e){return"function"==typeof this.options.paramName?this.options.paramName(e):""+this.options.paramName+(this.options.uploadMultiple?"["+e+"]":"")}},{key:"_renameFile",value:function(e){return"function"!=typeof this.options.renameFile?e.name:this.options.renameFile(e)}},{key:"getFallbackForm",value:function(){var e=void 0,i=void 0;if(e=this.getExistingFallback())return e;var n='
';this.options.dictFallbackText&&(n+="

"+this.options.dictFallbackText+"

"),n+='
';var r=t.createElement(n);return"FORM"!==this.element.tagName?(i=t.createElement('
'),i.appendChild(r)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=i?i:r}},{key:"getExistingFallback",value:function(){for(var e=function(e){for(var t=e,i=!0,n=0,t=i?t:t[Symbol.iterator]();;){var r;if(i){if(n>=t.length)break;r=t[n++]}else{if(n=t.next(),n.done)break;r=n.value}var o=r;if(/(^| )fallback($| )/.test(o.className))return o}},t=["div","form"],i=0;i0){for(var n=["tb","gb","mb","kb","b"],r=0;r=a){t=e/Math.pow(this.options.filesizeBase,4-r),i=o;break}}t=Math.round(10*t)/10}return""+t+" "+this.options.dictFileSizeUnits[i]}},{key:"_updateMaxFilesReachedClass",value:function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}},{key:"drop",value:function(e){if(e.dataTransfer){this.emit("drop",e);var t=e.dataTransfer.files;if(this.emit("addedfiles",t),t.length){var i=e.dataTransfer.items;i&&i.length&&null!=i[0].webkitGetAsEntry?this._addFilesFromItems(i):this.handleFiles(t)}}}},{key:"paste",value:function(e){if(null!=__guard__(null!=e?e.clipboardData:void 0,function(e){return e.items})){this.emit("paste",e);var t=e.clipboardData.items;return t.length?this._addFilesFromItems(t):void 0}}},{key:"handleFiles",value:function(e){for(var t=e,i=!0,n=0,t=i?t:t[Symbol.iterator]();;){var r;if(i){if(n>=t.length)break;r=t[n++]}else{if(n=t.next(),n.done)break;r=n.value}var o=r;this.addFile(o)}}},{key:"_addFilesFromItems",value:function(e){var t=this;return function(){for(var i=[],n=e,r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l,s=a;null!=s.webkitGetAsEntry&&(l=s.webkitGetAsEntry())?l.isFile?i.push(t.addFile(s.getAsFile())):l.isDirectory?i.push(t._addFilesFromDirectory(l,l.name)):i.push(void 0):null!=s.getAsFile&&(null==s.kind||"file"===s.kind)?i.push(t.addFile(s.getAsFile())):i.push(void 0)}return i}()}},{key:"_addFilesFromDirectory",value:function(e,t){var i=this,n=e.createReader(),r=function(e){return __guardMethod__(console,"log",function(t){return t.log(e)})},o=function e(){return n.readEntries(function(n){if(n.length>0){for(var r=n,o=!0,a=0,r=o?r:r[Symbol.iterator]();;){var l;if(o){if(a>=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;s.isFile?s.file(function(e){if(!i.options.ignoreHiddenFiles||"."!==e.name.substring(0,1))return e.fullPath=t+"/"+e.name,i.addFile(e)}):s.isDirectory&&i._addFilesFromDirectory(s,t+"/"+s.name)}e()}return null},r)};return o()}},{key:"accept",value:function(e,i){return e.size>1024*this.options.maxFilesize*1024?i(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(e.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):t.isValidFile(e,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(i(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",e)):this.options.accept.call(this,e,i):i(this.options.dictInvalidFileType)}},{key:"addFile",value:function(e){var i=this;return e.upload={uuid:t.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e),chunked:this.options.chunking&&(this.options.forceChunking||e.size>this.options.chunkSize),totalChunkCount:Math.ceil(e.size/this.options.chunkSize)},this.files.push(e),e.status=t.ADDED,this.emit("addedfile",e),this._enqueueThumbnail(e),this.accept(e,function(t){return t?(e.accepted=!1,i._errorProcessing([e],t)):(e.accepted=!0,i.options.autoQueue&&i.enqueueFile(e)),i._updateMaxFilesReachedClass()})}},{key:"enqueueFiles",value:function(e){for(var t=e,i=!0,n=0,t=i?t:t[Symbol.iterator]();;){var r;if(i){if(n>=t.length)break;r=t[n++]}else{if(n=t.next(),n.done)break;r=n.value}var o=r;this.enqueueFile(o)}return null}},{key:"enqueueFile",value:function(e){var i=this;if(e.status!==t.ADDED||e.accepted!==!0)throw new Error("This file can't be queued because it has already been processed or was rejected.");if(e.status=t.QUEUED,this.options.autoProcessQueue)return setTimeout(function(){return i.processQueue()},0)}},{key:"_enqueueThumbnail",value:function(e){var t=this;if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=1024*this.options.maxThumbnailFilesize*1024)return this._thumbnailQueue.push(e),setTimeout(function(){return t._processThumbnailQueue()},0)}},{key:"_processThumbnailQueue",value:function(){var e=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length){this._processingThumbnail=!0;var t=this._thumbnailQueue.shift();return this.createThumbnail(t,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,function(i){return e.emit("thumbnail",t,i),e._processingThumbnail=!1,e._processThumbnailQueue()})}}},{key:"removeFile",value:function(e){if(e.status===t.UPLOADING&&this.cancelUpload(e),this.files=without(this.files,e),this.emit("removedfile",e),0===this.files.length)return this.emit("reset")}},{key:"removeAllFiles",value:function(e){null==e&&(e=!1);for(var i=this.files.slice(),n=!0,r=0,i=n?i:i[Symbol.iterator]();;){var o;if(n){if(r>=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;(a.status!==t.UPLOADING||e)&&this.removeFile(a)}return null}},{key:"resizeImage",value:function(e,i,n,r,o){var a=this;return this.createThumbnail(e,i,n,r,!1,function(i,n){if(null==n)return o(e);var r=a.options.resizeMimeType;null==r&&(r=e.type);var l=n.toDataURL(r,a.options.resizeQuality);return"image/jpeg"!==r&&"image/jpg"!==r||(l=ExifRestore.restore(e.dataURL,l)),o(t.dataURItoBlob(l))})}},{key:"createThumbnail",value:function(e,t,i,n,r,o){var a=this,l=new FileReader;return l.onload=function(){return e.dataURL=l.result,"image/svg+xml"===e.type?void(null!=o&&o(l.result)):a.createThumbnailFromUrl(e,t,i,n,r,o)},l.readAsDataURL(e)}},{key:"createThumbnailFromUrl",value:function(e,t,i,n,r,o,a){var l=this,s=document.createElement("img");return a&&(s.crossOrigin=a),s.onload=function(){var a=function(e){return e(1)};return"undefined"!=typeof EXIF&&null!==EXIF&&r&&(a=function(e){return EXIF.getData(s,function(){return e(EXIF.getTag(this,"Orientation"))})}),a(function(r){e.width=s.width,e.height=s.height;var a=l.options.resize.call(l,e,t,i,n),u=document.createElement("canvas"),d=u.getContext("2d");switch(u.width=a.trgWidth,u.height=a.trgHeight,r>4&&(u.width=a.trgHeight,u.height=a.trgWidth),r){case 2:d.translate(u.width,0),d.scale(-1,1);break;case 3:d.translate(u.width,u.height),d.rotate(Math.PI);break;case 4:d.translate(0,u.height),d.scale(1,-1);break;case 5:d.rotate(.5*Math.PI),d.scale(1,-1);break;case 6:d.rotate(.5*Math.PI),d.translate(0,-u.height);break;case 7:d.rotate(.5*Math.PI),d.translate(u.width,-u.height),d.scale(-1,1);break;case 8:d.rotate(-.5*Math.PI),d.translate(-u.width,0)}drawImageIOSFix(d,s,null!=a.srcX?a.srcX:0,null!=a.srcY?a.srcY:0,a.srcWidth,a.srcHeight,null!=a.trgX?a.trgX:0,null!=a.trgY?a.trgY:0,a.trgWidth,a.trgHeight);var c=u.toDataURL("image/png");if(null!=o)return o(c,u)})},null!=o&&(s.onerror=o),s.src=e.dataURL}},{key:"processQueue",value:function(){var e=this.options.parallelUploads,t=this.getUploadingFiles().length,i=t;if(!(t>=e)){var n=this.getQueuedFiles();if(n.length>0){if(this.options.uploadMultiple)return this.processFiles(n.slice(0,e-t));for(;i=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;a.processing=!0,a.status=t.UPLOADING,this.emit("processing",a)}return this.options.uploadMultiple&&this.emit("processingmultiple",e),this.uploadFiles(e)}},{key:"_getFilesWithXhr",value:function(e){var t=void 0;return t=this.files.filter(function(t){return t.xhr===e}).map(function(e){return e})}},{key:"cancelUpload",value:function(e){if(e.status===t.UPLOADING){for(var i=this._getFilesWithXhr(e.xhr),n=i,r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;l.status=t.CANCELED}"undefined"!=typeof e.xhr&&e.xhr.abort();for(var s=i,u=!0,d=0,s=u?s:s[Symbol.iterator]();;){var c;if(u){if(d>=s.length)break;c=s[d++]}else{if(d=s.next(),d.done)break;c=d.value}var p=c;this.emit("canceled",p)}this.options.uploadMultiple&&this.emit("canceledmultiple",i)}else e.status!==t.ADDED&&e.status!==t.QUEUED||(e.status=t.CANCELED,this.emit("canceled",e),this.options.uploadMultiple&&this.emit("canceledmultiple",[e]));if(this.options.autoProcessQueue)return this.processQueue()}},{key:"resolveOption",value:function(e){if("function"==typeof e){for(var t=arguments.length,i=Array(t>1?t-1:0),n=1;n=r.upload.totalChunkCount)){a++;var l=n*i.options.chunkSize,s=Math.min(l+i.options.chunkSize,r.size),u={name:i._getParamName(0),data:o.webkitSlice?o.webkitSlice(l,s):o.slice(l,s),filename:r.upload.filename,chunkIndex:n};r.upload.chunks[n]={file:r,index:n,dataBlock:u,status:t.UPLOADING,progress:0,retries:0},i._uploadData(e,[u])}};if(r.upload.finishedChunkUpload=function(n){var o=!0;n.status=t.SUCCESS,n.dataBlock=null;for(var a=0;a=o.length)break;s=o[l++]}else{if(l=o.next(),l.done)break;s=l.value}var u=s;u.xhr=r}e[0].upload.chunked&&(e[0].upload.chunks[i[0].chunkIndex].xhr=r);var d=this.resolveOption(this.options.method,e),c=this.resolveOption(this.options.url,e);r.open(d,c,!0),r.timeout=this.resolveOption(this.options.timeout,e),r.withCredentials=!!this.options.withCredentials,r.onload=function(t){n._finishedUploading(e,r,t)},r.onerror=function(){n._handleUploadError(e,r)};var p=null!=r.upload?r.upload:r;p.onprogress=function(t){return n._updateFilesUploadProgress(e,r,t)};var h={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};this.options.headers&&t.extend(h,this.options.headers);for(var f in h){var v=h[f];v&&r.setRequestHeader(f,v)}var m=new FormData;if(this.options.params){var g=this.options.params;"function"==typeof g&&(g=g.call(this,e,r,e[0].upload.chunked?this._getChunk(e[0],r):null));for(var k in g){var b=g[k];m.append(k,b)}}for(var y=e,F=!0,w=0,y=F?y:y[Symbol.iterator]();;){var x;if(F){if(w>=y.length)break;x=y[w++]}else{if(w=y.next(),w.done)break;x=w.value}var E=x;this.emit("sending",E,r,m)}this.options.uploadMultiple&&this.emit("sendingmultiple",e,r,m),this._addFormElementData(m);for(var z=0;z=t.length)break;r=t[n++]}else{if(n=t.next(),n.done)break;r=n.value}var o=r,a=o.getAttribute("name"),l=o.getAttribute("type");if(l&&(l=l.toLowerCase()),"undefined"!=typeof a&&null!==a)if("SELECT"===o.tagName&&o.hasAttribute("multiple"))for(var s=o.options,u=!0,d=0,s=u?s:s[Symbol.iterator]();;){var c;if(u){if(d>=s.length)break;c=s[d++]}else{if(d=s.next(),d.done)break;c=d.value}var p=c;p.selected&&e.append(a,p.value)}else(!l||"checkbox"!==l&&"radio"!==l||o.checked)&&e.append(a,o.value)}}},{key:"_updateFilesUploadProgress",value:function(e,t,i){var n=void 0;if("undefined"!=typeof i){if(n=100*i.loaded/i.total,e[0].upload.chunked){var r=e[0],o=this._getChunk(r,t);o.progress=n,o.total=i.total,o.bytesSent=i.loaded;r.upload.progress=0,r.upload.total=0,r.upload.bytesSent=0;for(var a=0;a=l.length)break;d=l[u++]}else{if(u=l.next(),u.done)break;d=u.value}var c=d;c.upload.progress=n,c.upload.total=i.total,c.upload.bytesSent=i.loaded}for(var p=e,h=!0,f=0,p=h?p:p[Symbol.iterator]();;){var v;if(h){if(f>=p.length)break;v=p[f++]}else{if(f=p.next(),f.done)break;v=f.value}var m=v;this.emit("uploadprogress",m,m.upload.progress,m.upload.bytesSent)}}else{var g=!0;n=100;for(var k=e,b=!0,y=0,k=b?k:k[Symbol.iterator]();;){var F;if(b){if(y>=k.length)break;F=k[y++]}else{if(y=k.next(),y.done)break;F=y.value}var w=F;100===w.upload.progress&&w.upload.bytesSent===w.upload.total||(g=!1),w.upload.progress=n,w.upload.bytesSent=w.upload.total}if(g)return;for(var x=e,E=!0,z=0,x=E?x:x[Symbol.iterator]();;){var C;if(E){if(z>=x.length)break;C=x[z++]}else{if(z=x.next(),z.done)break;C=z.value}var S=C;this.emit("uploadprogress",S,n,S.upload.bytesSent)}}}},{key:"_finishedUploading",value:function(e,i,n){var r=void 0;if(e[0].status!==t.CANCELED&&4===i.readyState){if("arraybuffer"!==i.responseType&&"blob"!==i.responseType&&(r=i.responseText,i.getResponseHeader("content-type")&&~i.getResponseHeader("content-type").indexOf("application/json")))try{r=JSON.parse(r)}catch(e){n=e,r="Invalid JSON response from server."}this._updateFilesUploadProgress(e),200<=i.status&&i.status<300?e[0].upload.chunked?e[0].upload.finishedChunkUpload(this._getChunk(e[0],i)):this._finished(e,r,n):this._handleUploadError(e,i,r)}}},{key:"_handleUploadError",value:function(e,i,n){if(e[0].status!==t.CANCELED){if(e[0].upload.chunked&&this.options.retryChunks){var r=this._getChunk(e[0],i);if(r.retries++=o.length)break;s=o[l++]}else{if(l=o.next(),l.done)break;s=l.value}this._errorProcessing(e,n||this.options.dictResponseError.replace("{{statusCode}}",i.status),i)}}}},{key:"submitRequest",value:function(e,t,i){e.send(t)}},{key:"_finished",value:function(e,i,n){for(var r=e,o=!0,a=0,r=o?r:r[Symbol.iterator]();;){var l;if(o){if(a>=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;s.status=t.SUCCESS,this.emit("success",s,i,n),this.emit("complete",s)}if(this.options.uploadMultiple&&(this.emit("successmultiple",e,i,n),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}},{key:"_errorProcessing",value:function(e,i,n){for(var r=e,o=!0,a=0,r=o?r:r[Symbol.iterator]();;){var l;if(o){if(a>=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;s.status=t.ERROR,this.emit("error",s,i,n),this.emit("complete",s)}if(this.options.uploadMultiple&&(this.emit("errormultiple",e,i,n),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}}],[{key:"uuidv4",value:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,i="x"===e?t:3&t|8;return i.toString(16)})}}]),t}(Emitter);Dropzone.initClass(),Dropzone.version="5.3.1",Dropzone.options={},Dropzone.optionsForElement=function(e){return e.getAttribute("id")?Dropzone.options[camelize(e.getAttribute("id"))]:void 0},Dropzone.instances=[],Dropzone.forElement=function(e){if("string"==typeof e&&(e=document.querySelector(e)),null==(null!=e?e.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return e.dropzone},Dropzone.autoDiscover=!0,Dropzone.discover=function(){var e=void 0;if(document.querySelectorAll)e=document.querySelectorAll(".dropzone");else{e=[];var t=function(t){return function(){for(var i=[],n=t,r=!0,o=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var l=a;/(^| )dropzone($| )/.test(l.className)?i.push(e.push(l)):i.push(void 0)}return i}()};t(document.getElementsByTagName("div")),t(document.getElementsByTagName("form"))}return function(){for(var t=[],i=e,n=!0,r=0,i=n?i:i[Symbol.iterator]();;){var o;if(n){if(r>=i.length)break;o=i[r++]}else{if(r=i.next(),r.done)break;o=r.value}var a=o;Dropzone.optionsForElement(a)!==!1?t.push(new Dropzone(a)):t.push(void 0)}return t}()},Dropzone.blacklistedBrowsers=[/opera.*(Macintosh|Windows Phone).*version\/12/i],Dropzone.isBrowserSupported=function(){var e=!0;if(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(var t=Dropzone.blacklistedBrowsers,i=!0,n=0,t=i?t:t[Symbol.iterator]();;){var r;if(i){if(n>=t.length)break;r=t[n++]}else{if(n=t.next(),n.done)break;r=n.value}var o=r;o.test(navigator.userAgent)&&(e=!1)}else e=!1;else e=!1;return e},Dropzone.dataURItoBlob=function(e){for(var t=atob(e.split(",")[1]),i=e.split(",")[0].split(":")[1].split(";")[0],n=new ArrayBuffer(t.length),r=new Uint8Array(n),o=0,a=t.length,l=0<=a;l?o<=a:o>=a;l?o++:o--)r[o]=t.charCodeAt(o);return new Blob([n],{type:i})};var without=function(e,t){return e.filter(function(e){return e!==t}).map(function(e){return e})},camelize=function(e){return e.replace(/[\-_](\w)/g,function(e){return e.charAt(1).toUpperCase()})};Dropzone.createElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes[0]},Dropzone.elementInside=function(e,t){if(e===t)return!0;for(;e=e.parentNode;)if(e===t)return!0;return!1},Dropzone.getElement=function(e,t){var i=void 0;if("string"==typeof e?i=document.querySelector(e):null!=e.nodeType&&(i=e),null==i)throw new Error("Invalid `"+t+"` option provided. Please provide a CSS selector or a plain HTML element.");return i},Dropzone.getElements=function(e,t){var i=void 0,n=void 0;if(e instanceof Array){n=[];try{for(var r=e,o=!0,a=0,r=o?r:r[Symbol.iterator]();;){if(o){if(a>=r.length)break;i=r[a++]}else{if(a=r.next(),a.done)break;i=a.value}n.push(this.getElement(i,t))}}catch(e){n=null}}else if("string"==typeof e){n=[];for(var l=document.querySelectorAll(e),s=!0,u=0,l=s?l:l[Symbol.iterator]();;){if(s){if(u>=l.length)break;i=l[u++]}else{if(u=l.next(),u.done)break;i=u.value}n.push(i)}}else null!=e.nodeType&&(n=[e]);if(null==n||!n.length)throw new Error("Invalid `"+t+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return n},Dropzone.confirm=function(e,t,i){return window.confirm(e)?t():null!=i?i():void 0},Dropzone.isValidFile=function(e,t){if(!t)return!0;t=t.split(",");for(var i=e.type,n=i.replace(/\/.*$/,""),r=t,o=!0,a=0,r=o?r:r[Symbol.iterator]();;){var l;if(o){if(a>=r.length)break;l=r[a++]}else{if(a=r.next(),a.done)break;l=a.value}var s=l;if(s=s.trim(),"."===s.charAt(0)){if(e.name.toLowerCase().indexOf(s.toLowerCase(),e.name.length-s.length)!==-1)return!0}else if(/\/\*$/.test(s)){if(n===s.replace(/\/.*$/,""))return!0}else if(i===s)return!0}return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(e){return this.each(function(){return new Dropzone(this,e)})}),"undefined"!=typeof module&&null!==module?module.exports=Dropzone:window.Dropzone=Dropzone,Dropzone.ADDED="added",Dropzone.QUEUED="queued",Dropzone.ACCEPTED=Dropzone.QUEUED,Dropzone.UPLOADING="uploading",Dropzone.PROCESSING=Dropzone.UPLOADING,Dropzone.CANCELED="canceled",Dropzone.ERROR="error",Dropzone.SUCCESS="success";var detectVerticalSquash=function(e){var t=(e.naturalWidth,e.naturalHeight),i=document.createElement("canvas");i.width=1,i.height=t;var n=i.getContext("2d");n.drawImage(e,0,0);for(var r=n.getImageData(1,0,1,t),o=r.data,a=0,l=t,s=t;s>a;){var u=o[4*(s-1)+3];0===u?l=s:a=s,s=l+a>>1}var d=s/t;return 0===d?1:d},drawImageIOSFix=function(e,t,i,n,r,o,a,l,s,u){var d=detectVerticalSquash(t);return e.drawImage(t,i,n,r,o,a,l,s,u/d)},ExifRestore=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"initClass",value:function(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function(e){for(var t="",i=void 0,n=void 0,r="",o=void 0,a=void 0,l=void 0,s="",u=0;;)if(i=e[u++],n=e[u++],r=e[u++],o=i>>2,a=(3&i)<<4|n>>4,l=(15&n)<<2|r>>6,s=63&r,isNaN(n)?l=s=64:isNaN(r)&&(s=64),t=t+this.KEY_STR.charAt(o)+this.KEY_STR.charAt(a)+this.KEY_STR.charAt(l)+this.KEY_STR.charAt(s),i=n=r="",o=a=l=s="",!(ue.length)break}return i}},{key:"decode64",value:function(e){var t=void 0,i=void 0,n="",r=void 0,o=void 0,a=void 0,l="",s=0,u=[],d=/[^A-Za-z0-9\+\/\=]/g;for(d.exec(e)&&console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding."),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");;)if(r=this.KEY_STR.indexOf(e.charAt(s++)),o=this.KEY_STR.indexOf(e.charAt(s++)),a=this.KEY_STR.indexOf(e.charAt(s++)),l=this.KEY_STR.indexOf(e.charAt(s++)),t=r<<2|o>>4,i=(15&o)<<4|a>>2,n=(3&a)<<6|l,u.push(t),64!==a&&u.push(i),64!==l&&u.push(n),t=i=n="",r=o=a=l="",!(s1?c-1:0),e=1;e=f.length)break;h=f[g++];h.apply(this,d)}}return this}},{key:"off",value:function(a,b){if(!this._callbacks||0===arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1===arguments.length)return delete this._callbacks[a],this;for(var d=0;d=c.length)break;e=c[d++];var f=e;if(/(^| )dz-message($| )/.test(f.className)){a=f,f.className="dz-message";break}}a||(a=b.createElement('
'),this.element.appendChild(a));var g=a.getElementsByTagName("span")[0];return g&&(null!=g.textContent?g.textContent=this.options.dictFallbackMessage:null!=g.innerText&&(g.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize:function(a,b,c,d){var e={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},f=a.width/a.height;null==b&&null==c?(b=e.srcWidth,c=e.srcHeight):null==b?b=c*f:null==c&&(c=b/f),b=Math.min(b,e.srcWidth),c=Math.min(c,e.srcHeight);var g=b/c;if(e.srcWidth>b||e.srcHeight>c)if("crop"===d)f>g?(e.srcHeight=a.height,e.srcWidth=e.srcHeight*g):(e.srcWidth=a.width,e.srcHeight=e.srcWidth/g);else{if("contain"!==d)throw new Error("Unknown resizeMethod '"+d+"'");f>g?c=b/f:b=c*f}return e.srcX=(a.width-e.srcWidth)/2,e.srcY=(a.height-e.srcHeight)/2,e.trgWidth=b,e.trgHeight=c,e},transformFile:function(a,b){return(this.options.resizeWidth||this.options.resizeHeight)&&a.type.match(/image.*/)?this.resizeImage(a,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,b):b(a)},previewTemplate:'
\n
\n
\n
\n
\n
\n
\n
\n
\n \n Check\n \n \n \n \n \n
\n
\n \n Error\n \n \n \n \n \n \n \n
\n
',drop:function(a){return this.element.classList.remove("dz-drag-hover")},dragstart:function(a){},dragend:function(a){return this.element.classList.remove("dz-drag-hover")},dragenter:function(a){return this.element.classList.add("dz-drag-hover")},dragover:function(a){return this.element.classList.add("dz-drag-hover")},dragleave:function(a){return this.element.classList.remove("dz-drag-hover")},paste:function(a){},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){var c=this;if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer){a.previewElement=b.createElement(this.options.previewTemplate.trim()),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement);for(var d=a.previewElement.querySelectorAll("[data-dz-name]"),e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g=f;g.textContent=a.name}for(var h=a.previewElement.querySelectorAll("[data-dz-size]"),i=0,h=h;!(i>=h.length);)g=h[i++],g.innerHTML=this.filesize(a.size);this.options.addRemoveLinks&&(a._removeLink=b.createElement(''+this.options.dictRemoveFile+""),a.previewElement.appendChild(a._removeLink));for(var j=function(d){return d.preventDefault(),d.stopPropagation(),a.status===b.UPLOADING?b.confirm(c.options.dictCancelUploadConfirmation,function(){return c.removeFile(a)}):c.options.dictRemoveFileConfirmation?b.confirm(c.options.dictRemoveFileConfirmation,function(){return c.removeFile(a)}):c.removeFile(a)},k=a.previewElement.querySelectorAll("[data-dz-remove]"),l=0,k=k;;){var m;if(l>=k.length)break;m=k[l++];m.addEventListener("click",j)}}},removedfile:function(a){return null!=a.previewElement&&null!=a.previewElement.parentNode&&a.previewElement.parentNode.removeChild(a.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(a,b){if(a.previewElement){a.previewElement.classList.remove("dz-file-preview");for(var c=a.previewElement.querySelectorAll("[data-dz-thumbnail]"),d=0,c=c;;){var e;if(d>=c.length)break;e=c[d++];var f=e;f.alt=a.name,f.src=b}return setTimeout(function(){return a.previewElement.classList.add("dz-image-preview")},1)}},error:function(a,b){if(a.previewElement){a.previewElement.classList.add("dz-error"),"String"!=typeof b&&b.error&&(b=b.error);for(var c=a.previewElement.querySelectorAll("[data-dz-errormessage]"),d=0,c=c;;){var e;if(d>=c.length)break;e=c[d++];e.textContent=b}}},errormultiple:function(){},processing:function(a){if(a.previewElement&&(a.previewElement.classList.add("dz-processing"),a._removeLink))return a._removeLink.innerHTML=this.options.dictCancelUpload},processingmultiple:function(){},uploadprogress:function(a,b,c){if(a.previewElement)for(var d=a.previewElement.querySelectorAll("[data-dz-uploadprogress]"),e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g=f;"PROGRESS"===g.nodeName?g.value=b:g.style.width=b+"%"}},totaluploadprogress:function(){},sending:function(){},sendingmultiple:function(){},success:function(a){if(a.previewElement)return a.previewElement.classList.add("dz-success")},successmultiple:function(){},canceled:function(a){return this.emit("error",a,this.options.dictUploadCanceled)},canceledmultiple:function(){},complete:function(a){if(a._removeLink&&(a._removeLink.innerHTML=this.options.dictRemoveFile),a.previewElement)return a.previewElement.classList.add("dz-complete")},completemultiple:function(){},maxfilesexceeded:function(){},maxfilesreached:function(){},queuecomplete:function(){},addedfiles:function(){}},this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}},{key:"extend",value:function(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d=e.length)break;g=e[f++];var h=g;for(var i in h){var j=h[i];a[i]=j}}return a}}]),_createClass(b,[{key:"getAcceptedFiles",value:function(){return this.files.filter(function(a){return a.accepted}).map(function(a){return a})}},{key:"getRejectedFiles",value:function(){return this.files.filter(function(a){return!a.accepted}).map(function(a){return a})}},{key:"getFilesWithStatus",value:function(a){return this.files.filter(function(b){return b.status===a}).map(function(a){return a})}},{key:"getQueuedFiles",value:function(){return this.getFilesWithStatus(b.QUEUED)}},{key:"getUploadingFiles",value:function(){return this.getFilesWithStatus(b.UPLOADING)}},{key:"getAddedFiles",value:function(){return this.getFilesWithStatus(b.ADDED)}},{key:"getActiveFiles",value:function(){return this.files.filter(function(a){return a.status===b.UPLOADING||a.status===b.QUEUED}).map(function(a){return a})}},{key:"init",value:function(){var a=this;if("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length){!function c(){return a.hiddenFileInput&&a.hiddenFileInput.parentNode.removeChild(a.hiddenFileInput),a.hiddenFileInput=document.createElement("input"),a.hiddenFileInput.setAttribute("type","file"),(null===a.options.maxFiles||a.options.maxFiles>1)&&a.hiddenFileInput.setAttribute("multiple","multiple"),a.hiddenFileInput.className="dz-hidden-input",null!==a.options.acceptedFiles&&a.hiddenFileInput.setAttribute("accept",a.options.acceptedFiles),null!==a.options.capture&&a.hiddenFileInput.setAttribute("capture",a.options.capture),a.hiddenFileInput.style.visibility="hidden",a.hiddenFileInput.style.position="absolute",a.hiddenFileInput.style.top="0",a.hiddenFileInput.style.left="0",a.hiddenFileInput.style.height="0",a.hiddenFileInput.style.width="0",b.getElement(a.options.hiddenInputContainer,"hiddenInputContainer").appendChild(a.hiddenFileInput),a.hiddenFileInput.addEventListener("change",function(){var b=a.hiddenFileInput.files;if(b.length)for(var d=b,e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g=f;a.addFile(g)}return a.emit("addedfiles",b),c()})}()}this.URL=null!==window.URL?window.URL:window.webkitURL;for(var c=this.events,d=0,c=c;;){var e;if(d>=c.length)break;e=c[d++];var f=e;this.on(f,this.options[f])}this.on("uploadprogress",function(){return a.updateTotalUploadProgress()}),this.on("removedfile",function(){return a.updateTotalUploadProgress()}),this.on("canceled",function(b){return a.emit("complete",b)}),this.on("complete",function(b){if(0===a.getAddedFiles().length&&0===a.getUploadingFiles().length&&0===a.getQueuedFiles().length)return setTimeout(function(){return a.emit("queuecomplete")},0)});var g=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1};return this.listeners=[{element:this.element,events:{dragstart:function(b){return a.emit("dragstart",b)},dragenter:function(b){return g(b),a.emit("dragenter",b)},dragover:function(b){var c=void 0;try{c=b.dataTransfer.effectAllowed}catch(a){}return b.dataTransfer.dropEffect="move"===c||"linkMove"===c?"move":"copy",g(b),a.emit("dragover",b)},dragleave:function(b){return a.emit("dragleave",b)},drop:function(b){return g(b),a.drop(b)},dragend:function(b){return a.emit("dragend",b)}}}],this.clickableElements.forEach(function(c){return a.listeners.push({element:c,events:{click:function(d){return(c!==a.element||d.target===a.element||b.elementInside(d.target,a.element.querySelector(".dz-message")))&&a.hiddenFileInput.click(),!0}}})}),this.enable(),this.options.init.call(this)}},{key:"destroy",value:function(){return this.disable(),this.removeAllFiles(!0),(null!=this.hiddenFileInput?this.hiddenFileInput.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,b.instances.splice(b.instances.indexOf(this),1)}},{key:"updateTotalUploadProgress",value:function(){var a=void 0,b=0,c=0;if(this.getActiveFiles().length){for(var d=this.getActiveFiles(),e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g=f;b+=g.upload.bytesSent,c+=g.upload.total}a=100*b/c}else a=100;return this.emit("totaluploadprogress",a,c,b)}},{key:"_getParamName",value:function(a){return"function"==typeof this.options.paramName?this.options.paramName(a):this.options.paramName+(this.options.uploadMultiple?"["+a+"]":"")}},{key:"_renameFile",value:function(a){return"function"!=typeof this.options.renameFile?a.name:this.options.renameFile(a)}},{key:"getFallbackForm",value:function(){var a=void 0,c=void 0;if(a=this.getExistingFallback())return a;var d='
';this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
';var e=b.createElement(d);return"FORM"!==this.element.tagName?(c=b.createElement('
'),c.appendChild(e)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=c?c:e}},{key:"getExistingFallback",value:function(){for(var a=["div","form"],b=0;b=b.length)break;d=b[c++];var e=d;if(/(^| )fallback($| )/.test(e.className))return e}}(this.element.getElementsByTagName(d)))return c}}},{key:"setupEventListeners",value:function(){return this.listeners.map(function(a){return function(){var b=[];for(var c in a.events){var d=a.events[c];b.push(a.element.addEventListener(c,d,!1))}return b}()})}},{key:"removeEventListeners",value:function(){return this.listeners.map(function(a){return function(){var b=[];for(var c in a.events){var d=a.events[c];b.push(a.element.removeEventListener(c,d,!1))}return b}()})}},{key:"disable",value:function(){var a=this;return this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),this.disabled=!0,this.files.map(function(b){return a.cancelUpload(b)})}},{key:"enable",value:function(){return delete this.disabled,this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()}},{key:"filesize",value:function(a){var b=0,c="b";if(a>0){for(var d=["tb","gb","mb","kb","b"],e=0;e=Math.pow(this.options.filesizeBase,4-e)/10){b=a/Math.pow(this.options.filesizeBase,4-e),c=f;break}}b=Math.round(10*b)/10}return""+b+" "+this.options.dictFileSizeUnits[c]}},{key:"_updateMaxFilesReachedClass",value:function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}},{key:"drop",value:function(a){if(a.dataTransfer){this.emit("drop",a);for(var b=[],c=0;c=b.length)break;d=b[c++];var e=d;this.addFile(e)}}},{key:"_addFilesFromItems",value:function(a){var b=this;return function(){for(var c=[],d=a,e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g,h=f;null!=h.webkitGetAsEntry&&(g=h.webkitGetAsEntry())?g.isFile?c.push(b.addFile(h.getAsFile())):g.isDirectory?c.push(b._addFilesFromDirectory(g,g.name)):c.push(void 0):null!=h.getAsFile&&(null==h.kind||"file"===h.kind)?c.push(b.addFile(h.getAsFile())):c.push(void 0)}return c}()}},{key:"_addFilesFromDirectory",value:function(a,b){var c=this,d=a.createReader(),e=function(a){return __guardMethod__(console,"log",function(b){return b.log(a)})};return function a(){return d.readEntries(function(d){if(d.length>0){for(var e=d,f=0,e=e;;){var g;if(f>=e.length)break;g=e[f++];var h=g;h.isFile?h.file(function(a){if(!c.options.ignoreHiddenFiles||"."!==a.name.substring(0,1))return a.fullPath=b+"/"+a.name,c.addFile(a)}):h.isDirectory&&c._addFilesFromDirectory(h,b+"/"+h.name)}a()}return null},e)}()}},{key:"accept",value:function(a,c){return this.options.maxFilesize&&a.size>1024*this.options.maxFilesize*1024?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidFile(a,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(c(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",a)):this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)}},{key:"addFile",value:function(a){var c=this;return a.upload={uuid:b.uuidv4(),progress:0,total:a.size,bytesSent:0,filename:this._renameFile(a),chunked:this.options.chunking&&(this.options.forceChunking||a.size>this.options.chunkSize),totalChunkCount:Math.ceil(a.size/this.options.chunkSize)},this.files.push(a),a.status=b.ADDED,this.emit("addedfile",a),this._enqueueThumbnail(a),this.accept(a,function(b){return b?(a.accepted=!1,c._errorProcessing([a],b)):(a.accepted=!0,c.options.autoQueue&&c.enqueueFile(a)),c._updateMaxFilesReachedClass()})}},{key:"enqueueFiles",value:function(a){for(var b=a,c=0,b=b;;){var d;if(c>=b.length)break;d=b[c++];var e=d;this.enqueueFile(e)}return null}},{key:"enqueueFile",value:function(a){var c=this;if(a.status!==b.ADDED||!0!==a.accepted)throw new Error("This file can't be queued because it has already been processed or was rejected.");if(a.status=b.QUEUED,this.options.autoProcessQueue)return setTimeout(function(){return c.processQueue()},0)}},{key:"_enqueueThumbnail",value:function(a){var b=this;if(this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*this.options.maxThumbnailFilesize*1024)return this._thumbnailQueue.push(a),setTimeout(function(){return b._processThumbnailQueue()},0)}},{key:"_processThumbnailQueue",value:function(){var a=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length){this._processingThumbnail=!0;var b=this._thumbnailQueue.shift();return this.createThumbnail(b,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,function(c){return a.emit("thumbnail",b,c),a._processingThumbnail=!1,a._processThumbnailQueue()})}}},{key:"removeFile",value:function(a){if(a.status===b.UPLOADING&&this.cancelUpload(a),this.files=without(this.files,a),this.emit("removedfile",a),0===this.files.length)return this.emit("reset")}},{key:"removeAllFiles",value:function(a){null==a&&(a=!1);for(var c=this.files.slice(),d=0,c=c;;){var e;if(d>=c.length)break;e=c[d++];var f=e;(f.status!==b.UPLOADING||a)&&this.removeFile(f)}return null}},{key:"resizeImage",value:function(a,c,d,e,f){var g=this;return this.createThumbnail(a,c,d,e,!0,function(c,d){if(null==d)return f(a);var e=g.options.resizeMimeType;null==e&&(e=a.type);var h=d.toDataURL(e,g.options.resizeQuality);return"image/jpeg"!==e&&"image/jpg"!==e||(h=ExifRestore.restore(a.dataURL,h)),f(b.dataURItoBlob(h))})}},{key:"createThumbnail",value:function(a,b,c,d,e,f){var g=this,h=new FileReader;return h.onload=function(){return a.dataURL=h.result,"image/svg+xml"===a.type?void(null!=f&&f(h.result)):g.createThumbnailFromUrl(a,b,c,d,e,f)},h.readAsDataURL(a)}},{key:"createThumbnailFromUrl",value:function(a,b,c,d,e,f,g){var h=this,i=document.createElement("img");return g&&(i.crossOrigin=g),i.onload=function(){var g=function(a){return a(1)};return"undefined"!=typeof EXIF&&null!==EXIF&&e&&(g=function(a){return EXIF.getData(i,function(){return a(EXIF.getTag(this,"Orientation"))})}),g(function(e){a.width=i.width,a.height=i.height;var g=h.options.resize.call(h,a,b,c,d),j=document.createElement("canvas"),k=j.getContext("2d");switch(j.width=g.trgWidth,j.height=g.trgHeight,e>4&&(j.width=g.trgHeight,j.height=g.trgWidth),e){case 2:k.translate(j.width,0),k.scale(-1,1);break;case 3:k.translate(j.width,j.height),k.rotate(Math.PI);break;case 4:k.translate(0,j.height),k.scale(1,-1);break;case 5:k.rotate(.5*Math.PI),k.scale(1,-1);break;case 6:k.rotate(.5*Math.PI),k.translate(0,-j.width);break;case 7:k.rotate(.5*Math.PI),k.translate(j.height,-j.width),k.scale(-1,1);break;case 8:k.rotate(-.5*Math.PI),k.translate(-j.height,0)}drawImageIOSFix(k,i,null!=g.srcX?g.srcX:0,null!=g.srcY?g.srcY:0,g.srcWidth,g.srcHeight,null!=g.trgX?g.trgX:0,null!=g.trgY?g.trgY:0,g.trgWidth,g.trgHeight);var l=j.toDataURL("image/png");if(null!=f)return f(l,j)})},null!=f&&(i.onerror=f),i.src=a.dataURL}},{key:"processQueue",value:function(){var a=this.options.parallelUploads,b=this.getUploadingFiles().length,c=b;if(!(b>=a)){var d=this.getQueuedFiles();if(d.length>0){if(this.options.uploadMultiple)return this.processFiles(d.slice(0,a-b));for(;c=c.length)break;e=c[d++];var f=e;f.processing=!0,f.status=b.UPLOADING,this.emit("processing",f)}return this.options.uploadMultiple&&this.emit("processingmultiple",a),this.uploadFiles(a)}},{key:"_getFilesWithXhr",value:function(a){return this.files.filter(function(b){return b.xhr===a}).map(function(a){return a})}},{key:"cancelUpload",value:function(a){if(a.status===b.UPLOADING){for(var c=this._getFilesWithXhr(a.xhr),d=c,e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];f.status=b.CANCELED}void 0!==a.xhr&&a.xhr.abort();for(var g=c,h=0,g=g;;){var i;if(h>=g.length)break;i=g[h++];var j=i;this.emit("canceled",j)}this.options.uploadMultiple&&this.emit("canceledmultiple",c)}else a.status!==b.ADDED&&a.status!==b.QUEUED||(a.status=b.CANCELED,this.emit("canceled",a),this.options.uploadMultiple&&this.emit("canceledmultiple",[a]));if(this.options.autoProcessQueue)return this.processQueue()}},{key:"resolveOption",value:function(a){if("function"==typeof a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d=e.upload.totalChunkCount)){g++;var h=d*c.options.chunkSize,i=Math.min(h+c.options.chunkSize,e.size),j={name:c._getParamName(0),data:f.webkitSlice?f.webkitSlice(h,i):f.slice(h,i),filename:e.upload.filename,chunkIndex:d};e.upload.chunks[d]={file:e,index:d,dataBlock:j,status:b.UPLOADING,progress:0,retries:0},c._uploadData(a,[j])}};if(e.upload.finishedChunkUpload=function(d){var f=!0;d.status=b.SUCCESS,d.dataBlock=null,d.xhr=null;for(var g=0;g=f.length)break;h=f[g++];h.xhr=e}a[0].upload.chunked&&(a[0].upload.chunks[c[0].chunkIndex].xhr=e);var i=this.resolveOption(this.options.method,a),j=this.resolveOption(this.options.url,a);e.open(i,j,!0),e.timeout=this.resolveOption(this.options.timeout,a),e.withCredentials=!!this.options.withCredentials,e.onload=function(b){d._finishedUploading(a,e,b)},e.onerror=function(){d._handleUploadError(a,e)},(null!=e.upload?e.upload:e).onprogress=function(b){return d._updateFilesUploadProgress(a,e,b)};var k={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};this.options.headers&&b.extend(k,this.options.headers);for(var l in k){var m=k[l];m&&e.setRequestHeader(l,m)}var n=new FormData;if(this.options.params){var o=this.options.params;"function"==typeof o&&(o=o.call(this,a,e,a[0].upload.chunked?this._getChunk(a[0],e):null));for(var p in o){var q=o[p];n.append(p,q)}}for(var r=a,s=0,r=r;;){var t;if(s>=r.length)break;t=r[s++];var u=t;this.emit("sending",u,e,n)}this.options.uploadMultiple&&this.emit("sendingmultiple",a,e,n),this._addFormElementData(n);for(var v=0;v=b.length)break;d=b[c++];var e=d,f=e.getAttribute("name"),g=e.getAttribute("type");if(g&&(g=g.toLowerCase()),void 0!==f&&null!==f)if("SELECT"===e.tagName&&e.hasAttribute("multiple"))for(var h=e.options,i=0,h=h;;){var j;if(i>=h.length)break;j=h[i++];var k=j;k.selected&&a.append(f,k.value)}else(!g||"checkbox"!==g&&"radio"!==g||e.checked)&&a.append(f,e.value)}}},{key:"_updateFilesUploadProgress",value:function(a,b,c){var d=void 0;if(void 0!==c){if(d=100*c.loaded/c.total,a[0].upload.chunked){var e=a[0],f=this._getChunk(e,b);f.progress=d,f.total=c.total,f.bytesSent=c.loaded;e.upload.progress=0,e.upload.total=0,e.upload.bytesSent=0;for(var g=0;g=h.length)break;j=h[i++];var k=j;k.upload.progress=d,k.upload.total=c.total,k.upload.bytesSent=c.loaded}for(var l=a,m=0,l=l;;){var n;if(m>=l.length)break;n=l[m++];var o=n;this.emit("uploadprogress",o,o.upload.progress,o.upload.bytesSent)}}else{var p=!0;d=100;for(var q=a,r=0,q=q;;){var s;if(r>=q.length)break;s=q[r++];var t=s;100===t.upload.progress&&t.upload.bytesSent===t.upload.total||(p=!1),t.upload.progress=d,t.upload.bytesSent=t.upload.total}if(p)return;for(var u=a,v=0,u=u;;){var w;if(v>=u.length)break;w=u[v++];var x=w;this.emit("uploadprogress",x,d,x.upload.bytesSent)}}}},{key:"_finishedUploading",value:function(a,c,d){var e=void 0;if(a[0].status!==b.CANCELED&&4===c.readyState){if("arraybuffer"!==c.responseType&&"blob"!==c.responseType&&(e=c.responseText,c.getResponseHeader("content-type")&&~c.getResponseHeader("content-type").indexOf("application/json")))try{e=JSON.parse(e)}catch(a){d=a,e="Invalid JSON response from server."}this._updateFilesUploadProgress(a),200<=c.status&&c.status<300?a[0].upload.chunked?a[0].upload.finishedChunkUpload(this._getChunk(a[0],c)):this._finished(a,e,d):this._handleUploadError(a,c,e)}}},{key:"_handleUploadError",value:function(a,c,d){if(a[0].status!==b.CANCELED){if(a[0].upload.chunked&&this.options.retryChunks){var e=this._getChunk(a[0],c);if(e.retries++=f.length)break;f[g++];this._errorProcessing(a,d||this.options.dictResponseError.replace("{{statusCode}}",c.status),c)}}}},{key:"submitRequest",value:function(a,b,c){a.send(b)}},{key:"_finished",value:function(a,c,d){for(var e=a,f=0,e=e;;){var g;if(f>=e.length)break;g=e[f++];var h=g;h.status=b.SUCCESS,this.emit("success",h,c,d),this.emit("complete",h)}if(this.options.uploadMultiple&&(this.emit("successmultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue)return this.processQueue()}},{key:"_errorProcessing",value:function(a,c,d){for(var e=a,f=0,e=e;;){var g;if(f>=e.length)break;g=e[f++];var h=g;h.status=b.ERROR,this.emit("error",h,c,d),this.emit("complete",h)}if(this.options.uploadMultiple&&(this.emit("errormultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue)return this.processQueue()}}],[{key:"uuidv4",value:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"===a?b:3&b|8).toString(16)})}}]),b}(Emitter);Dropzone.initClass(),Dropzone.version="5.5.0",Dropzone.options={},Dropzone.optionsForElement=function(a){return a.getAttribute("id")?Dropzone.options[camelize(a.getAttribute("id"))]:void 0},Dropzone.instances=[],Dropzone.forElement=function(a){if("string"==typeof a&&(a=document.querySelector(a)),null==(null!=a?a.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return a.dropzone},Dropzone.autoDiscover=!0,Dropzone.discover=function(){var a=void 0;if(document.querySelectorAll)a=document.querySelectorAll(".dropzone");else{a=[];var b=function(b){return function(){for(var c=[],d=b,e=0,d=d;;){var f;if(e>=d.length)break;f=d[e++];var g=f;/(^| )dropzone($| )/.test(g.className)?c.push(a.push(g)):c.push(void 0)}return c}()};b(document.getElementsByTagName("div")),b(document.getElementsByTagName("form"))}return function(){for(var b=[],c=a,d=0,c=c;;){var e;if(d>=c.length)break;e=c[d++];var f=e;!1!==Dropzone.optionsForElement(f)?b.push(new Dropzone(f)):b.push(void 0)}return b}()},Dropzone.blacklistedBrowsers=[/opera.*(Macintosh|Windows Phone).*version\/12/i],Dropzone.isBrowserSupported=function(){var a=!0;if(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(var b=Dropzone.blacklistedBrowsers,c=0,b=b;;){var d;if(c>=b.length)break;d=b[c++];var e=d;e.test(navigator.userAgent)&&(a=!1)}else a=!1;else a=!1;return a},Dropzone.dataURItoBlob=function(a){for(var b=atob(a.split(",")[1]),c=a.split(",")[0].split(":")[1].split(";")[0],d=new ArrayBuffer(b.length),e=new Uint8Array(d),f=0,g=b.length,h=0<=g;h?f<=g:f>=g;h?f++:f--)e[f]=b.charCodeAt(f);return new Blob([d],{type:c})};var without=function(a,b){return a.filter(function(a){return a!==b}).map(function(a){return a})},camelize=function(a){return a.replace(/[\-_](\w)/g,function(a){return a.charAt(1).toUpperCase()})};Dropzone.createElement=function(a){var b=document.createElement("div");return b.innerHTML=a,b.childNodes[0]},Dropzone.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},Dropzone.getElement=function(a,b){var c=void 0;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},Dropzone.getElements=function(a,b){var c=void 0,d=void 0;if(a instanceof Array){d=[];try{for(var e=a,f=0,e=e;!(f>=e.length);)c=e[f++],d.push(this.getElement(c,b))}catch(a){d=null}}else if("string"==typeof a){d=[];for(var g=document.querySelectorAll(a),h=0,g=g;!(h>=g.length);)c=g[h++],d.push(c)}else null!=a.nodeType&&(d=[a]);if(null==d||!d.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return d},Dropzone.confirm=function(a,b,c){return window.confirm(a)?b():null!=c?c():void 0},Dropzone.isValidFile=function(a,b){if(!b)return!0;b=b.split(",");for(var c=a.type,d=c.replace(/\/.*$/,""),e=b,f=0,e=e;;){var g;if(f>=e.length)break;g=e[f++];var h=g;if(h=h.trim(),"."===h.charAt(0)){if(-1!==a.name.toLowerCase().indexOf(h.toLowerCase(),a.name.length-h.length))return!0}else if(/\/\*$/.test(h)){if(d===h.replace(/\/.*$/,""))return!0}else if(c===h)return!0}return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(a){return this.each(function(){return new Dropzone(this,a)})}),"undefined"!=typeof module&&null!==module?module.exports=Dropzone:window.Dropzone=Dropzone,Dropzone.ADDED="added",Dropzone.QUEUED="queued",Dropzone.ACCEPTED=Dropzone.QUEUED,Dropzone.UPLOADING="uploading",Dropzone.PROCESSING=Dropzone.UPLOADING,Dropzone.CANCELED="canceled",Dropzone.ERROR="error",Dropzone.SUCCESS="success";var detectVerticalSquash=function(a){var b=(a.naturalWidth,a.naturalHeight),c=document.createElement("canvas");c.width=1,c.height=b;var d=c.getContext("2d");d.drawImage(a,0,0);for(var e=d.getImageData(1,0,1,b),f=e.data,g=0,h=b,i=b;i>g;){0===f[4*(i-1)+3]?h=i:g=i,i=h+g>>1}var j=i/b;return 0===j?1:j},drawImageIOSFix=function(a,b,c,d,e,f,g,h,i,j){var k=detectVerticalSquash(b);return a.drawImage(b,c,d,e,f,g,h,i,j/k)},ExifRestore=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"initClass",value:function(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function(a){for(var b="",c=void 0,d=void 0,e="",f=void 0,g=void 0,h=void 0,i="",j=0;;)if(c=a[j++],d=a[j++],e=a[j++],f=c>>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?h=i=64:isNaN(e)&&(i=64),b=b+this.KEY_STR.charAt(f)+this.KEY_STR.charAt(g)+this.KEY_STR.charAt(h)+this.KEY_STR.charAt(i),c=d=e="",f=g=h=i="",!(ja.length)break}return c}},{key:"decode64",value:function(a){var b=void 0,c=void 0,d="",e=void 0,f=void 0,g=void 0,h="",i=0,j=[],k=/[^A-Za-z0-9\+\/\=]/g;for(k.exec(a)&&console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding."),a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");;)if(e=this.KEY_STR.indexOf(a.charAt(i++)),f=this.KEY_STR.indexOf(a.charAt(i++)),g=this.KEY_STR.indexOf(a.charAt(i++)),h=this.KEY_STR.indexOf(a.charAt(i++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,j.push(b),64!==g&&j.push(c),64!==h&&j.push(d),b=c=d="",e=f=g=h="",!(i { return res.json({ private: config.private, enableUserAccounts: config.enableUserAccounts, - maxFileSize: config.uploads.maxSize, + maxSize: config.uploads.maxSize, chunkSize: config.uploads.chunkSize }) }) diff --git a/views/_globals.njk b/views/_globals.njk index f0f362f..8875e4b 100644 --- a/views/_globals.njk +++ b/views/_globals.njk @@ -16,9 +16,9 @@ v3: CSS and JS files (libs such as bulma, lazyload, etc). v4: Renders in /public/render/* directories (to be used by render.js). #} -{% set v1 = "S3TAWpPeFS" %} +{% set v1 = "f0nYw5J15T" %} {% set v2 = "hiboQUzAzp" %} -{% set v3 = "RpD2narcvz" %} +{% set v3 = "f0nYw5J15T" %} {% set v4 = "S3TAWpPeFS" %} {# diff --git a/views/dashboard.njk b/views/dashboard.njk index 75d1f2a..d82b41c 100644 --- a/views/dashboard.njk +++ b/views/dashboard.njk @@ -19,25 +19,6 @@ {% block content %} {{ super() }} -{# - -
-
-
-

- Admin dashboard -

-

-

- - Check -

-

-
-
-
-#} -

diff --git a/views/home.njk b/views/home.njk index e60e83d..5883a24 100644 --- a/views/home.njk +++ b/views/home.njk @@ -38,7 +38,7 @@

{{ globals.name }}

{{ globals.home_subtitle | safe }}

-

+