diff --git a/themes/default/public/js/lufi-upload.js b/themes/default/public/js/lufi-upload.js index 193a1be..8e9f8da 100644 --- a/themes/default/public/js/lufi-upload.js +++ b/themes/default/public/js/lufi-upload.js @@ -188,7 +188,6 @@ document.addEventListener("DOMContentLoaded", () => { }; mustZipDOM.onchange = () => { - console.debug(zipNameDOM.classList); if (!mustZipDOM.checked) { clearZip(); } else { diff --git a/themes/default/templates/index.html.ep b/themes/default/templates/index.html.ep index fac9af4..a48120d 100644 --- a/themes/default/templates/index.html.ep +++ b/themes/default/templates/index.html.ep @@ -110,24 +110,6 @@ - - % } -% if (defined stash('invitation')) { -%= javascript '/partial/index.js?token=' . stash('invitation')->token + %= javascript '/js/lufi-upload.js', type => 'module' diff --git a/themes/default/templates/partial/index.js.ep b/themes/default/templates/partial/index.js.ep deleted file mode 100644 index 8208978..0000000 --- a/themes/default/templates/partial/index.js.ep +++ /dev/null @@ -1,36 +0,0 @@ -const ws_url = '<%= url_for('upload')->to_abs() %>'; -% if (defined($self->config('fixed_domain')) && $self->config('fixed_domain')) { -const baseURL = '<%= url_for('/')->host($self->config('fixed_domain'))->to_abs() %>'; -% } else { -const baseURL = '<%= url_for('/')->to_abs() %>'; -% } -const actionURL = '<%= url_for('/')->to_abs() %>'; -const i18n = { - enqueued: '<%= l('XXX file has been added to upload queue.') %>', - confirmExit: '<%= l('You have attempted to leave this page. The upload will be canceled. Are you sure?') %>', - copyAll: '<%= l('Copy all links to clipboard') %>', - copySuccess: '<%= l('The link(s) has been copied to your clipboard') %>', - copyFail: '<%= l('Unable to copy the link(s) to your clipboard') %>', - cpText: '<%= l('Copy to clipboard') %>', - delText: '<%= l('Deletion link') %>', - dlText: '<%= l('Download link') %>', - download: '<%= l('Download') %>', - encrypting: '<%= l('Encrypting part XX1 of XX2') %>', - expiration: '<%= l('Expiration:') %>', - fileUploaded: '<%= l('File uploaded') %>', - hit: '<%= l('Hit Enter, then Ctrl+C to copy the download link') %>', - hits: '<%= l('Hit Enter, then Ctrl+C to copy all the download links') %>', - mailTo: '<%= l('Send all links by email') %>', - maxSize: '<%= l('(max size: XXX)') %>', - noLimit: '<%= l('No expiration delay') %>', - sending: '<%= l('Sending part XX1 of XX2. Please, be patient, the progress bar can take a while to move.') %>', - wsProblem: '<%= l('Websocket communication error') %>', -}; -const maxSize = <%= config('max_file_size') || 0 %>; - -% if (stash('token')) { -const isGuest = true; -const sendFilesURLsURL = '<%= url_for('guest_send_mail', token => stash('token'))->to_abs() %>'; -% } else { -const isGuest = false; -% } diff --git a/themes/default/templates/partial/mail.js.ep b/themes/default/templates/partial/mail.js.ep deleted file mode 100644 index 8d1bec9..0000000 --- a/themes/default/templates/partial/mail.js.ep +++ /dev/null @@ -1,64 +0,0 @@ -const findItem = (name) => { - var files = localStorage.getItem(`${window.prefix}files`); - if (files === null) { - files = new Array(); - } else { - files = JSON.parse(files); - } - var i; - for (i = 0; i < files.length; i++) { - if (files[i].short === name) { - return files[i]; - } - } -} -function updateMailtoLink() { - var btn = document.getElementById('mailto'); - var emails = document.getElementById('emails'); - var subject = document.getElementById('subject'); - var text = document.getElementById('body'); - - btn.href = `mailto:${encodeURIComponent(emails.value)}?subject=${encodeURIComponent(subject.value)}&body=${encodeURIComponent(text.value)}`; -} -function populateBody() { - var links = [ - % my $ref = ref(stash('links')); - % if ($ref eq 'ARRAY') { - % for my $link (@{stash('links')}) { - '<%= $link %>', - % } - % } else { - '<%= stash('links') %>', - % } - ]; - var text = "<%== l('Hello,\n\nHere\'s some files I want to share with you:\n') %>"; - links.forEach(function(name, index, array) { - var item = findItem(name); - if (item !== null && item !== undefined) { - var limit = (item.delay === 0) ? null : formatDate(item.delay * 86400 + item.created_at); - text += `- ${item.name}<%= l(':') %> ${item.url}`; - if (limit !== null) { - text += `\n (<%= l('deadline: ') %>${limit})`; - } - text += "\n"; - } - }); - -% if (!defined(config('ldap')) && !defined(config('htpasswd'))) { - text += "\n-- \n<%= l('Share your files in total privacy on %1', url_for('/')->to_abs) %>"; -% } - tArea = document.getElementById('body').value = text; - updateMailtoLink(); -} -document.addEventListener('DOMContentLoaded', function() { -% if (stash('populate')) { - populateBody(); -% } - - var emails = document.getElementById('emails'); - var subject = document.getElementById('subject'); - var text = document.getElementById('body'); - emails.addEventListener('change', updateMailtoLink); - subject.addEventListener('change', updateMailtoLink); - text.addEventListener('change', updateMailtoLink); -}); diff --git a/themes/default/templates/partial/render.js.ep b/themes/default/templates/partial/render.js.ep deleted file mode 100755 index 6c3eead..0000000 --- a/themes/default/templates/partial/render.js.ep +++ /dev/null @@ -1,14 +0,0 @@ -const ws_url = '<%= url_for('download')->to_abs().stash('file') %>'; -const i18n = { - aborted1: '<%= l('Download aborted.') %>', - aborted2: '<%= l('Click here to refresh the page and restart the download.') %>', - badkey: '<%= l('It seems that the key in your URL is incorrect. Please, verify your URL.') %>', - confirmExit: '<%= l('You have attempted to leave this page. The download will be canceled. Are you sure?') %>', - download: '<%= l('Get the file') %>', - fileDownloaded: '<%= l('File downloaded') %>', - loading: '<%= l('Asking for file part XX1 of %1', stash('nbslices')) %>', - nokey: '<%= l('You don\'t seem to have a key in your URL. You won\'t be able to decrypt the file. Download canceled.') %>', - showZipContent: '<%= l('Show zip content') %>', - tooMuchAttempts: '<%= l('Unable to download the file: too much unsuccessful attempts to open a websocket. Please, contact the administrator.') %>', - zipContent: '<%= l('Zip content:') %>' -} diff --git a/themes/default/templates/render.html.ep b/themes/default/templates/render.html.ep index baee237..0160286 100755 --- a/themes/default/templates/render.html.ep +++ b/themes/default/templates/render.html.ep @@ -80,8 +80,24 @@
-%= javascript '/partial/render.js?nbslices='.stash('f')->nbslices.'&file='.stash('f')->short -%= javascript '/js/lufi-download.js', type => 'module' % } % } + + +%= javascript '/js/lufi-download.js', type => 'module' \ No newline at end of file