From 84a3b73a7d8ba0c3bc4ee4a6760f1371a52b2d80 Mon Sep 17 00:00:00 2001 From: fatchan Date: Mon, 13 Apr 2020 15:59:18 +1000 Subject: [PATCH 1/7] improve redirects and handle referer better when doing mod actions --- models/forms/actionhandler.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/models/forms/actionhandler.js b/models/forms/actionhandler.js index fd2972a5..aa95c28c 100644 --- a/models/forms/actionhandler.js +++ b/models/forms/actionhandler.js @@ -18,11 +18,19 @@ const { Posts, Boards, Modlogs } = require(__dirname+'/../../db/') , getAffectedBoards = require(__dirname+'/../../helpers/affectedboards.js') , buildQueue = require(__dirname+'/../../queue.js') , { postPasswordSecret } = require(__dirname+'/../../configs/main.js') + , threadRegex = /\/[a-z0-9]+\/(?:manage\/)?thread\/(\d+)\.html/i , { createHash, timingSafeEqual } = require('crypto'); module.exports = async (req, res, next) => { - const redirect = req.headers.referer || `/${req.params.board ? req.params.board+'/manage/reports' : 'globalmanage/recents'}.html`; + let redirect = req.headers.referer; + if (!redirect) { + if (!req.params.board) { + redirect = '/globalmanage/recent.html'; + } else { + redirect = `/${req.params.board}/${req.path.endsWith('modactions') ? 'manage/reports' : 'index'}.html`; + } + } //if user isnt staff, and they put an action that requires password, e.g. delete/spoiler, then filter posts to only matching password if (res.locals.permLevel >= 4 && res.locals.actions.numPasswords > 0) { @@ -54,6 +62,16 @@ module.exports = async (req, res, next) => { const deleting = req.body.delete || req.body.delete_ip_board || req.body.delete_ip_global || req.body.delete_ip_thread; let { boardThreadMap, beforePages, threadBoards } = await getAffectedBoards(res.locals.posts, deleting); + if (deleting + && req.params.board + && req.headers.referer + && boardThreadMap[req.params.board]) { + const threadRefMatch = req.headers.referer.match(threadRegex); + if (threadRefMatch && boardThreadMap[req.params.board].directThreads.has(+threadRefMatch[1])) { + redirect = `/${req.params.board}/${req.path.endsWith('modactions') ? 'manage/' : ''}index.html`; + } + } + const messages = []; const modlogActions = [] const combinedQuery = {}; From f7bc8e8f18cefdf2ebc8cb6f0941ac6d1220857d Mon Sep 17 00:00:00 2001 From: fatchan Date: Mon, 13 Apr 2020 16:10:35 +1000 Subject: [PATCH 2/7] add ctrl-enter to submit post --- gulp/res/js/forms.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gulp/res/js/forms.js b/gulp/res/js/forms.js index 77fb5f6d..a191d78e 100644 --- a/gulp/res/js/forms.js +++ b/gulp/res/js/forms.js @@ -69,10 +69,17 @@ class formHandler { this.fileInput.addEventListener('change', e => this.fileInputChange(e)); this.fileLabel.addEventListener('auxclick', e => this.fileLabelAuxclick(e)); } + this.messageBox.addEventListener('keydown', e => this.controlEnterSubmit(e)); form.addEventListener('paste', e => this.paste(e)); form.addEventListener('submit', e => this.formSubmit(e)); } + controlEnterSubmit(e) { + if (e.ctrlKey && e.key === 'Enter') { + this.formSubmit(e); + } + } + formSubmit(e) { let postData; if (this.form.getAttribute('enctype') === 'multipart/form-data') { @@ -101,8 +108,8 @@ class formHandler { xhr.onloadstart = () => { this.submit.value = '0%'; } - xhr.upload.onprogress = (e) => { - const progress = Math.floor((e.loaded / e.total) * 100); + xhr.upload.onprogress = (ev) => { + const progress = Math.floor((ev.loaded / ev.total) * 100); this.submit.value = `${progress}%`; } xhr.onload = () => { @@ -176,8 +183,8 @@ class formHandler { this.submit.value = this.originalSubmitText; } } - xhr.onerror = (e) => { - console.error(e); //why is this error fucking useless + xhr.onerror = (err) => { + console.error(err); //why is this error fucking useless doModal({ 'title': 'Error', 'message': 'Something broke' From 06a5387e4cf0f105434899d5faacd5751f5fe189 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2020 07:25:48 +0000 Subject: [PATCH 3/7] Bump ioredis from 4.16.1 to 4.16.2 Bumps [ioredis](https://github.com/luin/ioredis) from 4.16.1 to 4.16.2. - [Release notes](https://github.com/luin/ioredis/releases) - [Changelog](https://github.com/luin/ioredis/blob/master/Changelog.md) - [Commits](https://github.com/luin/ioredis/compare/v4.16.1...v4.16.2) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04ae51a1..83e3bffd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4116,9 +4116,9 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, "ioredis": { - "version": "4.16.1", - "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.16.1.tgz", - "integrity": "sha512-g76Mm9dE7BLuewncu1MimGZw5gDDjDwjoRony/VoSxSJEKAhuYncDEwYKYjtHi2NWsTNIB6XXRjE64uVa/wpKQ==", + "version": "4.16.2", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.16.2.tgz", + "integrity": "sha512-hlRK9q9K8pWpYIxUh079dWUWECiGNdI7+/AR21pgeqIBXQzjVKFnz0wXvmhEQZV3Hvv4saQpvJww9SkjwvPXZA==", "requires": { "cluster-key-slot": "^1.1.0", "debug": "^4.1.1", From 68208d3ca842ba8417df0e09892e31cbce0e0d35 Mon Sep 17 00:00:00 2001 From: fatchan Date: Mon, 13 Apr 2020 17:26:33 +1000 Subject: [PATCH 4/7] show uploaded files with thumb in scrollabel area todo: - handle tumbnails properly for video and other files - allow to selectively remove files with a X button or something --- gulp/res/css/style.css | 28 ++++++++++++++++++++++++++++ gulp/res/js/forms.js | 12 ++++++++++++ views/includes/postform.pug | 1 + 3 files changed, 41 insertions(+) diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index fdf9acf2..fa7d6cc9 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -260,6 +260,33 @@ p { margin: 5px; } +.upload-list { + max-height: 75px; + overflow: hidden auto; + max-width: 100%; +} + +.upload-item { + display: flex; + align-items: center; + position: relative; +} + +.upload-item p { + max-width: calc(100% - 60px); + max-height: 1.5em; + overflow: hidden; + text-overflow: ellipsis; + position: absolute; + margin-left: 60px; +} + +.upload-thumb { + width: 50px; + height: 50px; + object-fit: contain; +} + .catalog { display:flex; align-items:flex-start; @@ -299,6 +326,7 @@ p { min-width: 220px; flex-grow: 1; flex-direction: column; + min-height: 38px; } .form-file { diff --git a/gulp/res/js/forms.js b/gulp/res/js/forms.js index a191d78e..9cbe9a1d 100644 --- a/gulp/res/js/forms.js +++ b/gulp/res/js/forms.js @@ -216,6 +216,17 @@ class formHandler { this.fileInput.removeAttribute('required'); } this.files.push(file); +console.log(file) + const listElem = document.createElement('div'); + listElem.classList.add('upload-item'); + const thumb = document.createElement('img'); + const name = document.createElement('p'); + name.textContent = file.name; + thumb.src = URL.createObjectURL(file); + thumb.classList.add('upload-thumb'); + listElem.appendChild(thumb); + listElem.appendChild(name); + this.fileInput.nextSibling.appendChild(listElem); } //show number of files on new label @@ -238,6 +249,7 @@ class formHandler { this.fileInput.setAttribute('required', true) } this.updateFilesText(); + this.fileInput.nextSibling.textContent = ''; } //paste file from clipboard diff --git a/views/includes/postform.pug b/views/includes/postform.pug index 2454c459..0e75bbb8 100644 --- a/views/includes/postform.pug +++ b/views/includes/postform.pug @@ -48,6 +48,7 @@ section.form-wrapper.flex-center span.col include ./filelabel.pug input#file(type='file', name='file' multiple required=fileRequired ) + div.upload-list if board.settings.userPostSpoiler label.postform-style.ph-5.ml-1.fh input(type='checkbox', name='spoiler', value='true') From 4ad5617d4c2c3df4e2507bda1ad0ac273f5b07a2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2020 07:11:10 +0000 Subject: [PATCH 5/7] Bump mongodb from 3.5.5 to 3.5.6 Bumps [mongodb](https://github.com/mongodb/node-mongodb-native) from 3.5.5 to 3.5.6. - [Release notes](https://github.com/mongodb/node-mongodb-native/releases) - [Changelog](https://github.com/mongodb/node-mongodb-native/blob/master/CHANGES_3.0.0.md) - [Commits](https://github.com/mongodb/node-mongodb-native/compare/v3.5.5...v3.5.6) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04ae51a1..9110ce52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1064,9 +1064,9 @@ } }, "bson": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", - "integrity": "sha512-TdiJxMVnodVS7r0BdL42y/pqC9cL2iKynVwA0Ho3qbsQYr428veL3l7BQyuqiw+Q5SqqoT0m4srSY/BlZ9AxXg==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.4.tgz", + "integrity": "sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q==" }, "buffer-equal": { "version": "1.0.0", @@ -4943,12 +4943,12 @@ } }, "mongodb": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.5.5.tgz", - "integrity": "sha512-GCjDxR3UOltDq00Zcpzql6dQo1sVry60OXJY3TDmFc2SWFY6c8Gn1Ardidc5jDirvJrx2GC3knGOImKphbSL3A==", + "version": "3.5.6", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.5.6.tgz", + "integrity": "sha512-sh3q3GLDLT4QmoDLamxtAECwC3RGjq+oNuK1ENV8+tnipIavss6sMYt77hpygqlMOCt0Sla5cl7H4SKCVBCGEg==", "requires": { "bl": "^2.2.0", - "bson": "^1.1.1", + "bson": "^1.1.4", "denque": "^1.4.1", "require_optional": "^1.0.1", "safe-buffer": "^5.1.2", From ca8284f9aa782e4efd871e6725c57ee4b04a1e30 Mon Sep 17 00:00:00 2001 From: fatchan Date: Wed, 15 Apr 2020 19:05:50 +1000 Subject: [PATCH 6/7] X to remove files individually, with thumbnails shown --- gulp/res/css/style.css | 18 ++++++++++-- gulp/res/img/video.png | Bin 0 -> 886 bytes gulp/res/js/forms.js | 51 ++++++++++++++++++++++++++-------- views/includes/postform.pug | 2 +- views/pages/managebanners.pug | 1 + 5 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 gulp/res/img/video.png diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index fa7d6cc9..e7b1b0f8 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -262,8 +262,16 @@ p { .upload-list { max-height: 75px; - overflow: hidden auto; + overflow-x: hidden; + overflow-y: auto; max-width: 100%; + scrollbar-width: none; + border: 1px solid var(--input-borders); + margin-top: 1px; + display: none; +} +.upload-list::-webkit-scrollbar { + display: none; } .upload-item { @@ -273,7 +281,7 @@ p { } .upload-item p { - max-width: calc(100% - 60px); + max-width: calc(100% - 85px); max-height: 1.5em; overflow: hidden; text-overflow: ellipsis; @@ -281,6 +289,12 @@ p { margin-left: 60px; } +.upload-item a { + height: 50px; + display: flex; + align-items: center; +} + .upload-thumb { width: 50px; height: 50px; diff --git a/gulp/res/img/video.png b/gulp/res/img/video.png new file mode 100644 index 0000000000000000000000000000000000000000..27994f734fd57f8970e4154b8cc31714f5f37f57 GIT binary patch literal 886 zcmV-+1Bv{JP)EX>4Tx04R}tkv&MmKpe$iKcpg+4t5Z6$WWau6cu&UDionYs1;guFuC*#nlvOS zE{=k0!NHHks)LKOt`4q(Aou~|}?mh0_0sdx{sb(+%sG4PD zQb{3~Ull^H2qJLd`>)O&;^Mfxh}i>#<}FMpJzsmY-XM~N-UJRSngt0HdNwC;+Udpl<&{E ztZ?4qtXAu+eNX0S*p< z(Gq2^d%U~1ySIPOwEO!3tRQl}6eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00B-(L_t(&-tAdY4udcVMbmrCWxM~0mTWiazD#OEDTvgz zfj=8WAHD*wE-}Uk6W9uqm>9@=dz$$A7dZ>$^ZRxQB&0OJUNT=V`Q=oi0Oyp`#ybGf z8U~o_hb2dnKmY)UiM<|Mq^>1v+;|$l)Iw`6TUD~=K&*ZY}hEEQ+i zvn1V|tw+*zOfzWoh9(|nY-;7%(N4zL{hFBb?U50T+M`1Op{Tc7XRTFl3Y0RFZod6~ zOki1?3o8fWKpe=xKvH$=8 M07*qoM6N<$f)A{RjQ{`u literal 0 HcmV?d00001 diff --git a/gulp/res/js/forms.js b/gulp/res/js/forms.js index 9cbe9a1d..016c835d 100644 --- a/gulp/res/js/forms.js +++ b/gulp/res/js/forms.js @@ -62,6 +62,7 @@ class formHandler { if (this.fileInput) { this.fileRequired = this.fileInput.required; this.fileLabel = this.fileInput.previousSibling; + this.fileUploadList = this.fileInput.nextSibling; this.multipleFiles = this.fileLabel.parentNode.previousSibling.firstChild.textContent.endsWith('s'); this.fileLabelText = this.fileLabel.childNodes[0]; this.fileLabel.addEventListener('dragover', e => this.fileLabelDrag(e)); @@ -160,9 +161,9 @@ class formHandler { this.updateMessageBox(); this.files = []; this.updateFilesText(); - const captcha = this.form.querySelector('img'); + const captcha = this.form.querySelector('.captcharefresh'); if (captcha) { - captcha.dispatchEvent(new Event('dblclick')); + captcha.dispatchEvent(new Event('click')); } } else { if (xhr.status === 413) { @@ -204,11 +205,17 @@ class formHandler { this.messageBox && this.messageBox.dispatchEvent(new Event('input')); } - //remove a single file, unused atm - removeFile(index) { - const childNode = this.fileLabel.childNodes[index+1]; //+1 because first one is fileLabelText - childNode.remove(); - files.splice(index, 1); + removeFile(fileElem, name, size) { + fileElem.remove(); + let fileIndex; + this.files.find((f, index) => { + if (f.name === name && f.size === size) { + fileIndex = index; + } + }) + this.files.splice(fileIndex, 1); + this.updateFilesText(); +console.log(this.files) } addFile(file) { @@ -216,17 +223,38 @@ class formHandler { this.fileInput.removeAttribute('required'); } this.files.push(file); -console.log(file) + //add to upload list const listElem = document.createElement('div'); listElem.classList.add('upload-item'); const thumb = document.createElement('img'); const name = document.createElement('p'); + const remove = document.createElement('a'); name.textContent = file.name; - thumb.src = URL.createObjectURL(file); + remove.textContent = 'X'; + switch (file.type.split('/')[0]) { + case 'image': + thumb.src = URL.createObjectURL(file); + break; + case 'audio': + thumb.src = '/file/audio.png' + break; + case 'video': + thumb.src = '/file/video.png' + break; + default: + thumb.src = '/file/attachment.png' + break; + } thumb.classList.add('upload-thumb'); + remove.classList.add('close'); listElem.appendChild(thumb); listElem.appendChild(name); - this.fileInput.nextSibling.appendChild(listElem); + listElem.appendChild(remove); + remove.addEventListener('click', () => { + this.removeFile(listElem, file.name, file.size); + }) + this.fileUploadList.appendChild(listElem); + this.fileUploadList.style.display = 'unset'; } //show number of files on new label @@ -235,6 +263,8 @@ console.log(file) return; } if (this.files && this.files.length === 0) { + this.fileUploadList.textContent = ''; + this.fileUploadList.style.display = 'none'; this.fileLabelText.nodeValue = `Select/Drop/Paste file${this.multipleFiles ? 's' : ''}`; } else { this.fileLabelText.nodeValue = `${this.files.length} file${this.files.length > 1 ? 's' : ''} selected`; @@ -249,7 +279,6 @@ console.log(file) this.fileInput.setAttribute('required', true) } this.updateFilesText(); - this.fileInput.nextSibling.textContent = ''; } //paste file from clipboard diff --git a/views/includes/postform.pug b/views/includes/postform.pug index 0e75bbb8..2229a695 100644 --- a/views/includes/postform.pug +++ b/views/includes/postform.pug @@ -48,7 +48,7 @@ section.form-wrapper.flex-center span.col include ./filelabel.pug input#file(type='file', name='file' multiple required=fileRequired ) - div.upload-list + .upload-list if board.settings.userPostSpoiler label.postform-style.ph-5.ml-1.fh input(type='checkbox', name='spoiler', value='true') diff --git a/views/pages/managebanners.pug b/views/pages/managebanners.pug index b88f36c5..f2bd2d90 100644 --- a/views/pages/managebanners.pug +++ b/views/pages/managebanners.pug @@ -26,6 +26,7 @@ block content span.col include ../includes/filelabel.pug input#file(type='file', name='file' multiple required) + .upload-list input(type='submit', value='submit') if board.banners.length > 0 hr(size=1) From fcef46aca0ef9b70229258dadbdb40ff9edc3b09 Mon Sep 17 00:00:00 2001 From: fatchan Date: Wed, 15 Apr 2020 23:50:37 +1000 Subject: [PATCH 7/7] palememe possible fix --- gulp/res/css/style.css | 1 + gulp/res/js/expand.js | 102 +++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index e7b1b0f8..59468ffc 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -677,6 +677,7 @@ video, img { display: flex; image-orientation: from-image; position:relative; + flex-direction: column; } .expanded { diff --git a/gulp/res/js/expand.js b/gulp/res/js/expand.js index ef39e186..f9fcbf17 100644 --- a/gulp/res/js/expand.js +++ b/gulp/res/js/expand.js @@ -47,68 +47,63 @@ window.addEventListener('DOMContentLoaded', (event) => { if (!isCatalog) { //dont expand on catalog const thumbs = document.getElementsByClassName('post-file-src'); - const toggle = function(thumb, exp, fn, src) { - if (loopEnabled) { - exp.loop = true; - } else { - exp.loop = false; - } - exp.volume = volumeLevel/100; - const close = exp.previousSibling.innerText === 'Close' ? exp.previousSibling : null; - if (thumb.style.display === 'none') { - //closing + const toggle = function(thumb, expanded, filename, src) { + if (thumb.style.display === 'none') { //closing thumb.style.display = ''; - exp.style.display = 'none'; - fn.style.maxWidth = ''; - if (close) { - src.style.visibility = 'visible'; - close.style.display = 'none'; - exp.pause(); - } - } else { - //expanding + expanded.style.display = 'none'; + filename.style.maxWidth = ''; + } else { //expanding thumb.style.display = 'none'; - exp.style.display = ''; - if (exp.offsetWidth >= fn.offsetWidth) { - fn.style.maxWidth = exp.offsetWidth+'px'; + expanded.style.display = ''; + if (expanded.offsetWidth >= filename.offsetWidth) { + filename.style.maxWidth = expanded.offsetWidth+'px'; } - if (close) { + } + //handle css thing for play icon on vid/audio + const close = thumb.nextSibling.innerText === 'Close' ? thumb.nextSibling : null; + if (close) { + expanded.loop = loopEnabled; + expanded.volume = volumeLevel/100; + if (src.style.visibility === 'hidden') { + src.style.visibility = 'visible'; + close.style.display = 'none'; + expanded.pause(); + } else { src.style.visibility = 'hidden'; close.style.display = ''; - exp.play(); + expanded.play(); } } } const expand = function(e) { - const fileLink = this.firstChild; - const fileSrc = fileLink.href; - const type = this.dataset.type; + if (e.target.nodeName === 'VIDEO' || e.target.nodeName === 'AUDIO') { + e.stopPropagation(); + return; + } if (this.dataset.attachment == 'true') { - return; //attachments dont expand + return; } - const thumbElement = fileLink.firstChild; + e.preventDefault(); + const fileAnchor = this.firstChild; + const fileHref = fileAnchor.href; + const type = this.dataset.type; + const thumbElement = fileAnchor.firstChild; const fileName = this.previousSibling; - const next = thumbElement.nextSibling; const pfs = this.closest('.post-file-src'); - let expandedElement; - if (next) { - if (next.innerText === 'Close') { - expandedElement = next.nextSibling; - } else { - expandedElement = next; - } - } - if (!expandedElement && thumbElement.style.opacity !== '0.5') { + let expandedElement = type === 'image' ? thumbElement.nextSibling : fileAnchor.nextSibling; + + if (expandedElement) { + toggle(thumbElement, expandedElement, fileName, pfs); + } else if (thumbElement.style.opacity !== '0.5') { let source; - fileLink.style.minWidth = fileLink.offsetWidth+'px'; - fileLink.style.minHeight = fileLink.offsetHeight+'px'; switch(type) { case 'image': e.preventDefault(); + fileAnchor.style.minWidth = fileAnchor.offsetWidth+'px'; + fileAnchor.style.minHeight = fileAnchor.offsetHeight+'px'; thumbElement.style.opacity = '0.5'; thumbElement.style.cursor = 'wait' -// loading bar experiment if (localStorage.getItem('imageloadingbars') == 'true') { const request = new XMLHttpRequest(); request.onprogress = (e) => { @@ -123,7 +118,6 @@ window.addEventListener('DOMContentLoaded', (event) => { } expandedElement = document.createElement('img'); source = expandedElement; - //some jank here to try and recude any delay induced by xhr const loaded = function(e) { pfs.removeAttribute('data-loading'); pfs.removeAttribute('style'); @@ -131,24 +125,23 @@ window.addEventListener('DOMContentLoaded', (event) => { source.src = window.URL.createObjectURL(blob); thumbElement.style.opacity = ''; thumbElement.style.cursor = ''; - fileLink.appendChild(expandedElement); + fileAnchor.appendChild(expandedElement); toggle(thumbElement, expandedElement, fileName, pfs); } request.onload = loaded; request.responseType = 'blob'; - request.open('GET', fileSrc, true); + request.open('GET', fileHref, true); request.send(null); } else { -// loading bar experiment expandedElement = document.createElement('img'); source = expandedElement; source.onload = function() { thumbElement.style.opacity = ''; thumbElement.style.cursor = ''; - fileLink.appendChild(expandedElement); + fileAnchor.appendChild(expandedElement); toggle(thumbElement, expandedElement, fileName, pfs); } - source.src = fileSrc; + source.src = fileHref; } break; case 'video': @@ -165,19 +158,16 @@ window.addEventListener('DOMContentLoaded', (event) => { expandedElement.controls = 'true'; source = document.createElement('source'); expandedElement.appendChild(source); - fileLink.appendChild(expandedElement); - fileLink.insertBefore(close, expandedElement); + expandedElement.style.minWidth = fileAnchor.offsetWidth+'px'; + expandedElement.style.minHeight = fileAnchor.offsetHeight+'px'; + pfs.appendChild(expandedElement); + fileAnchor.appendChild(close); toggle(thumbElement, expandedElement, fileName, pfs); - source.src = fileSrc; + source.src = fileHref; break; deault: return; } - } else if (expandedElement) { - e.preventDefault(); - toggle(thumbElement, expandedElement, fileName, pfs); - } else { - e.preventDefault(); } };