diff --git a/CHANGELOG b/CHANGELOG index fde0320..565adee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Revision history for Lufi 0.07.0 ????-??-?? - ⬆️ β€” Update jQuery - 🩹 β€” Fix a format query parameter + - 🎨 β€” Use template literals in js 0.06.00 2023-12-18 - ⬆️ β€” Update deps diff --git a/themes/default/public/js/lufi-down.js b/themes/default/public/js/lufi-down.js index ee1f666..49da321 100644 --- a/themes/default/public/js/lufi-down.js +++ b/themes/default/public/js/lufi-down.js @@ -11,13 +11,13 @@ function pageKey() { // We will strip any additional data. // First, strip everything after the equal sign (=) which signals end of base64 string. - i = key.indexOf('='); if (i>-1) { key = key.substring(0,i+1); } + i = key.indexOf('='); if (i>-1) { key = key.substring(0, i + 1); } // If the equal sign was not present, some parameters may remain: - i = key.indexOf('&'); if (i>-1) { key = key.substring(0,i); } + i = key.indexOf('&'); if (i>-1) { key = key.substring(0, i); } // Then add trailing equal sign if it's missing - if (key.charAt(key.length-1)!=='=') key+='='; + if (key.charAt(key.length-1)!=='=') key += '='; return key; } @@ -38,11 +38,11 @@ function addAlert(msg) { var pbd = $('.file-progress'); pbd.attr('role', 'alert'); pbd.removeClass('progress'); - pbd.html(['
', - '
', - '', msg, '', - '
', - '
'].join('')); + pbd.html(`
+
+ ${msg} +
+
`); } // Spawn WebSocket @@ -55,9 +55,10 @@ function spawnWebsocket(pa) { var l = $('#loading'); l.html(i18n.loading.replace(/XX1/, (pa + 1))); if ($('#file_pwd').length === 1) { - window.ws.send('{"part":'+pa+', "file_pwd": "'+$('#file_pwd').val()+'"}'); + val = $('#file_pwd').val(); + window.ws.send(`{"part":${pa}, "file_pwd": "${val}"}`); } else { - window.ws.send('{"part":'+pa+'}'); + window.ws.send(`{"part":${pa}}`); } }; ws.onclose = function() { @@ -65,7 +66,7 @@ function spawnWebsocket(pa) { if (!window.completed) { window.attempts++; if (window.attempts < 10) { - console.log('Connection closed. Retrying to get slice '+pa); + console.log(`Connection closed. Retrying to get slice ${pa}`); window.ws = spawnWebsocket(pa); } else { alert(i18n.tooMuchAttempts); @@ -89,16 +90,16 @@ function spawnWebsocket(pa) { window.onbeforeunload = null; window.attempts = 10; } else { - console.log('Getting slice '+(data.part + 1)+' of '+data.total); + console.log(`Getting slice ${data.part + 1} of ${data.total}`); var slice = JSON.parse(res.shift()); var percent = Math.round(1000 * (data.part + 1)/data.total)/10; var wClass = percent.toString().replace('.', '-'); var pb = $('#pb'); pb.removeClass(); pb.addClass('determinate'); - pb.addClass('width-'+wClass); + pb.addClass(`width-${wClass}`); pb.attr('aria-valuenow', percent); - $('#pbt').html(percent+'%'); + $('#pbt').html(`${percent}%`); try { var b64 = sjcl.decrypt(window.key, slice); window.a[data.part] = base64ToArrayBuffer(b64); @@ -118,43 +119,44 @@ function spawnWebsocket(pa) { } else { var blobURL = URL.createObjectURL(blob); } - var innerHTML = ['

', i18n.download, '

']; + var innerHTML = `

${i18n.download}

`; var isZip = ($('#filesize').attr('data-zipped') === 'true'); if (data.type.match(/^image\//) !== null) { - innerHTML.push('', escapeHtml(data.name), ''); + innerHTML += `${escapeHtml(data.name)}`; } else if (data.type.match(/^video\//) !== null) { - innerHTML.push(''); + innerHTML += ``; } else if (data.type.match(/^audio\//) !== null) { - innerHTML.push(''); + innerHTML += ``; } else if (isZip) { - innerHTML.push('

', i18n.showZipContent, '

'); + innerHTML += `

${i18n.showZipContent}

`; } - pbd.html(innerHTML.join('')); + pbd.html(innerHTML); if (isZip) { $('#showZipContent').click(function() { JSZip.loadAsync(blob) .then(function (zip) { - var innerHTML = ['

', i18n.zipContent, '

'; + pbd.append(innerHTML); $('.download-zip-content').click(function(e) { e.preventDefault(); var t = $(this); @@ -171,7 +173,8 @@ function spawnWebsocket(pa) { }); } if ($('#file_pwd').length === 1) { - window.ws.send('{"ended":true, "file_pwd": "'+$('#file_pwd').val()+'"}'); + val = $('#file_pwd').val(); + window.ws.send(`{"ended":true, "file_pwd": "${val}"}`); } else { window.ws.send('{"ended":true}'); } @@ -187,18 +190,19 @@ function spawnWebsocket(pa) { window.ws.onclose = function() { console.log('Connection is closed'); if (!window.completed) { - console.log('Connection closed. Retrying to get slice '+(data.part + 1)); + console.log(`Connection closed. Retrying to get slice ${data.part + 1}`); window.ws = spawnWebsocket(data.part + 1); } } window.ws.onerror = function() { - console.log('Error. Retrying to get slice '+(data.part + 1)); + console.log(`Error. Retrying to get slice ${data.part + 1}`); window.ws = spawnWebsocket(data.part + 1); }; if ($('#file_pwd').length === 1) { - window.ws.send('{"part":'+(data.part + 1)+', "file_pwd": "'+$('#file_pwd').val()+'"}'); + val = $('#file_pwd').val(); + window.ws.send(`{"part":${data.part + 1}, "file_pwd": "${val}"}`); } else { - window.ws.send('{"part":'+(data.part + 1)+'}'); + window.ws.send(`{"part":${data.part + 1}}`); } } } @@ -215,7 +219,7 @@ function spawnWebsocket(pa) { ws.onerror = function() { window.attempts++; if (window.attempts < 10) { - console.log('Error. Retrying to get slice '+pa); + console.log(`Error. Retrying to get slice ${pa}`); window.ws = spawnWebsocket(pa); } else { alert(i18n.tooMuchAttempts); @@ -229,7 +233,13 @@ $(document).ready(function(){ window.ws.onclose = function() {}; window.ws.close(); $('#please-wait, #loading, #pbd, #abort').remove(); - $('#filesize').parent().append('

'+i18n.aborted1+'

'+i18n.aborted2+'

'); + $('#filesize').parent().append(`

${i18n.aborted1}

+

+ + ${i18n.aborted2} + +

`); window.onbeforeunload = null; $('#reloadLocation').on('click', function(e) { e.preventDefault(); diff --git a/themes/default/public/js/lufi-files.js b/themes/default/public/js/lufi-files.js index 26abb46..f49b5e0 100644 --- a/themes/default/public/js/lufi-files.js +++ b/themes/default/public/js/lufi-files.js @@ -1,18 +1,18 @@ // vim:set sw=4 ts=4 sts=4 ft=javascript expandtab: // Add item to localStorage function addItem(item) { - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { files = new Array(); } else { files = JSON.parse(files); } files.push(item); - localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); + localStorage.setItem(`${window.prefix}files`, JSON.stringify(files)); } function delItem(name) { - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { files = new Array(); } else { @@ -24,11 +24,11 @@ function delItem(name) { files.splice(i, 1); } } - localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); + localStorage.setItem(`${window.prefix}files`, JSON.stringify(files)); } function itemExists(name) { - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { return false; } else { @@ -59,7 +59,7 @@ function invertSelection(event) { function purgeExpired(event) { event.preventDefault(); - var files = JSON.parse(localStorage.getItem(window.prefix + 'files')); + var files = JSON.parse(localStorage.getItem(`${window.prefix}files`)); files.forEach(function(element, index, array) { $.ajax({ @@ -73,7 +73,7 @@ function purgeExpired(event) { success: function(data, textStatus, jqXHR) { if (data.success) { if (data.deleted) { - $('#count-'+data.short).parent().remove(); + $(`#count-${data.short}`).parent().remove(); delItem(data.short); } } @@ -84,11 +84,11 @@ function purgeExpired(event) { function exportStorage(event) { event.preventDefault(); - var a = $(''); + var a = $(''); a.hide(); $('body').append(a); - var storageData = [localStorage.getItem(window.prefix + 'files')]; + var storageData = [localStorage.getItem(`${window.prefix}files`)]; var exportFile = new Blob(storageData, {type : 'application/json'}); var url = window.URL.createObjectURL(exportFile); @@ -146,7 +146,7 @@ function delFile() { }, success: function(data) { if (data.success) { - $('#row-'+short).remove(); + $(`#row-${short}`).remove(); delItem(short); } else { alert(data.msg); @@ -178,15 +178,15 @@ function massDelete(event) { function populateFilesTable() { $('#myfiles').empty(); - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { var filesWithoutPrefix = localStorage.getItem('files'); if (filesWithoutPrefix !== null) { if (window.confirm(i18n.importFilesWithoutPrefix)) { - localStorage.setItem(window.prefix + 'files', filesWithoutPrefix); + localStorage.setItem(`${window.prefix}files`, filesWithoutPrefix); files = JSON.parse(filesWithoutPrefix); } else { - localStorage.setItem(window.prefix + 'files', JSON.stringify([])); + localStorage.setItem(`${window.prefix}files`, JSON.stringify([])); files = new Array(); } } else { @@ -206,45 +206,59 @@ function populateFilesTable() { }); files.forEach(function(element, index, array) { var del_view = (element.del_at_first_view) ? '' : ''; - var dlink = actionURL+'d/'+element.short+'/'+element.token; + var dlink = `${actionURL}d/${element.short}/${element.token}`; var limit = (element.delay === 0) ? i18n.noExpiration : moment.unix(element.delay * 86400 + element.created_at).locale(window.navigator.language).format('LLLL'); var created_at = moment.unix(element.created_at).locale(window.navigator.language).format('LLLL'); - var tr = $(''); - tr.html([ '', - '', - '', - '', - '', - escapeHtml(element.name), - '', - '', - '', - '', - '', - '', - '', - del_view, - '', - '', - created_at, - '', - '', - limit, - '', - '', - '', - '', - '', - '', - ''].join('')); + var tr = $(``); + tr.html(` + + + + + ${escapeHtml(element.name)} + + + + + + + + + + ${del_view} + + + ${created_at} + + + ${limit} + + + + + + + + + `); $('#myfiles').append(tr); - $('#del-'+element.short).on('click', delFile); - $('label[for="check-'+element.short+'"]').on('click', function(){ - if ($('#check-'+element.short).attr('data-checked') && $('#check-'+element.short).attr('data-checked') === 'data-checked') { - $('#check-'+element.short).attr('data-checked', null); + $(`#del-${element.short}`).on('click', delFile); + $(`label[for="check-${element.short}"]`).on('click', function(){ + if ($(`#check-${element.short}`).attr('data-checked') && $(`#check-${element.short}`).attr('data-checked') === 'data-checked') { + $(`#check-${element.short}`).attr('data-checked', null); } else { - $('#check-'+element.short).attr('data-checked', 'data-checked'); + $(`#check-${element.short}`).attr('data-checked', 'data-checked'); } evaluateMassDelete(); }); @@ -259,13 +273,13 @@ function populateFilesTable() { }, success: function(data, textStatus, jqXHR) { if (data.success) { - $('#count-'+data.short).html(data.counter); + $(`#count-${data.short}`).html(data.counter); if (data.deleted) { - $('#count-'+data.short).parent().addClass('purple lighten-4'); + $(`#count-${data.short}`).parent().addClass('purple lighten-4'); } } else { alert(data.msg); - $('#count-'+data.short).parent().remove(); + $(`#count-${data.short}`).parent().remove(); if (data.missing) { delItem(data.short); } diff --git a/themes/default/public/js/lufi-list-invitations.js b/themes/default/public/js/lufi-list-invitations.js index 8aab3d8..685dbd3 100644 --- a/themes/default/public/js/lufi-list-invitations.js +++ b/themes/default/public/js/lufi-list-invitations.js @@ -42,7 +42,7 @@ function deleteInvit(e) { if (data.success) { data.tokens.forEach(function(t) { Materialize.toast(t.msg, 6000, 'teal accent-3'); - $('#row-' + t.token).remove(); + $(`#row-${t.token}`).remove(); }); data.failures.forEach(function(msg) { Materialize.toast(msg, 10000, 'red accent-2'); @@ -74,8 +74,8 @@ function resendMail(e) { success: function(data, textStatus, jqXHR) { data.success.forEach(function(s) { Materialize.toast(s.msg, 6000, 'teal accent-3'); - $('#expire-' + s.token).text(s.expires) - $('#' + s.token).click(); + $(`#expire-${s.token}`).text(s.expires) + $(`#${s.token}`).click(); }); data.failures.forEach(function(msg) { Materialize.toast(msg, 10000, 'red accent-2'); @@ -97,19 +97,19 @@ function toggleVisibility(e) { success: function(data, textStatus, jqXHR) { if (data.success) { data.tokens.forEach(function(t) { - var row = $('#row-' + t.token) + var row = $(`#row-${t.token}`) if (t.show) { row.attr('data-visibility', 1); row.removeClass('hide'); - $('#row-' + t.token + ' > td:first i').remove(); + $(`#row-${t.token} > td:first i`).remove(); } else { row.attr('data-visibility', 0); if ($('#myInvitations').attr('data-visibility') === 'hidden') { row.addClass('hide'); } - $('#row-' + t.token + ' > td:first').append(i18n.hiddenMark); + $(`#row-${t.token} > td:first`).append(i18n.hiddenMark); } - $('#' + t.token).click(); + $(`#${t.token}`).click(); }); disableButtons(); } else { @@ -169,25 +169,17 @@ function fillModal() { ); var files = JSON.parse(el.attr('data-files')); - var content = []; + var content = ''; for (i = 0; i < files.length; i++) { var f = files[i]; var expires = i18n.expiration.replace('XXX', moment.unix(f.delay * 86400 + f.created_at).locale(window.navigator.language).format('LLLL') ); - content.push( - '
  • β€” ', - '', - f.name, - ' (', - filesize(f.size), - ', ', - expires, - ')', - '
  • ', - ); + content += `
  • β€” ${f.name} + (${filesize(f.size)}, ${expires}) +
  • `; } - $('#files-ul').html(content.join('')); + $('#files-ul').html(content); } $(document).ready(function(){ diff --git a/themes/default/public/js/lufi-notifications.js b/themes/default/public/js/lufi-notifications.js index 52af2c2..a3616aa 100644 --- a/themes/default/public/js/lufi-notifications.js +++ b/themes/default/public/js/lufi-notifications.js @@ -1,6 +1,6 @@ function notify(title, body) { if (!'Notification' in window || typeof(Notification) === 'undefined') { - console.log("This browser does not support desktop notification, cannot send following message: "+title+" "+body); + console.log(`This browser does not support desktop notification, cannot send following message: ${title} ${body}`); return; } diff --git a/themes/default/public/js/lufi-up.js b/themes/default/public/js/lufi-up.js index 2b7ef68..fdf4948 100644 --- a/themes/default/public/js/lufi-up.js +++ b/themes/default/public/js/lufi-up.js @@ -68,14 +68,14 @@ function copyAllToClipboard(event) { // Add item to localStorage function addItem(name, url, size, del_at_first_view, created_at, delay, short, token) { - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { files = new Array(); } else { files = JSON.parse(files); } files.push({ name: name, short: short, url: url, size: size, del_at_first_view: del_at_first_view, created_at: created_at, delay: delay, token: token }); - localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); + localStorage.setItem(`${window.prefix}files`, JSON.stringify(files)); } // Remove a file block @@ -192,7 +192,7 @@ function updateMailLink() { for (i = 0; i < a.length; i++) { l.push(a[i].id); } - var u = actionURL+'m?links='+JSON.stringify(l); + var u = `${actionURL}m?links=${JSON.stringify(l)}`; $('#mailto').attr('href', u); } @@ -240,18 +240,16 @@ function handleFiles(f) { var counter = 0; while (typeof(window.zip.files[filename]) !== 'undefined') { counter += 1; - filename = origname.substring(0, origname.lastIndexOf('.')) + '_(' + counter + ')' + origname.substring(origname.lastIndexOf('.')); + filename = `${origname.substring(0, origname.lastIndexOf('.'))}_(${counter})${origname.substring(origname.lastIndexOf('.'))}`; } window.zip.file(filename, element); window.zipSize += element.size; $('#zip-size').text(filesize(window.zipSize)); - $('#zip-parts').append([ - '
  • ', - 'β€” ', escapeHtml(filename), ' (', filesize(element.size), ')', - '
  • ' - ].join('')); + $('#zip-parts').append(`
  • + β€” ${escapeHtml(filename)} (${filesize(element.size)}) +
  • `); } } else { if (window.fileList === undefined || window.fileList === null) { @@ -295,23 +293,32 @@ function uploadFile(i, delay, del_at_first_view) { var r = $('#ul-results'); var w = $('
  • '); w.addClass('list-group-item'); - w.html(['
    ', - '
    ', - '', - '', - '', - '
    ', - '', name, ' (', size,')', - '

    ', - '
    ', - '
    ', - '
    ', - '', name, '0%', - '
    ', - '
    ', - '
    '].join('')); + w.html(`
    +
    + + + +
    + ${name} + (${size}) +

    +
    +
    +
    + ${name}0% +
    +
    +
    `); r.prepend(w); - $('#destroy-'+window.fc).on('click', function(event) { + $(`#destroy-${window.fc}`).on('click', function(event) { event.preventDefault(); window.cancelled.push(i); destroyBlock(this); @@ -350,7 +357,7 @@ function sliceAndUpload(randomkey, i, parts, j, delay, del_at_first_view, short, var slice = file.slice(j * window.sliceLength, (j + 1) * window.sliceLength, file.type); var fr = new FileReader(); fr.onloadend = function() { - var sl = $('#parts-'+window.fc); + var sl = $(`#parts-${window.fc}`); // Get the binary result, different result in IE browsers (see default.html.ep line 27:48) if (isIE == true){ @@ -387,12 +394,12 @@ function sliceAndUpload(randomkey, i, parts, j, delay, del_at_first_view, short, data['file_pwd'] = $('#file_pwd').val(); } } - data = JSON.stringify(data)+'XXMOJOXX'+JSON.stringify(encrypted);; + data = `${JSON.stringify(data)}XXMOJOXX${JSON.stringify(encrypted)}`; var percent = Math.round(1000 * j/parts)/10; - console.log('sending slice '+(j + 1)+'/'+parts+' of file '+file.name+' ('+percent+'%)'); + console.log(`sending slice ${j + 1}/${parts} of file ${file.name} (${percent}%)`); - sl.html(percent.toFixed(1)+'%'); + sl.html(`${percent.toFixed(1)}%`); // Verify that we have a websocket and send json if (window.ws.readyState === 3) { @@ -403,14 +410,14 @@ function sliceAndUpload(randomkey, i, parts, j, delay, del_at_first_view, short, window.ws.onclose = function() { console.log('Websocket closed, waiting 10sec.'); window.ws = spawnWebsocket(0, function() { - console.log('sending again slice '+(j + 1)+'/'+parts+' of file '+file.name); + console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`); window.ws.send(data); }); }; window.ws.onerror = function() { console.log('Error on Websocket, waiting 10sec.'); window.ws = spawnWebsocket(0, function() { - console.log('sending again slice '+(j + 1)+'/'+parts+' of file '+file.name); + console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`); window.ws.send(data); }); }; @@ -427,7 +434,7 @@ function updateProgressBar(data) { if (data.success) { console.log('Upload successfully cancelled'); } else { - console.log('Upload cancellation failed: ' + data.msg); + console.log(`Upload cancellation failed: ${data.msg}`); } // Remove the cancelled index @@ -463,9 +470,9 @@ function updateProgressBar(data) { var short = data.short; var created_at = data.created_at; - console.log('getting response for slice '+(j + 1)+'/'+parts+' of file '+data.name+' ('+data.duration+' sec)'); + console.log(`getting response for slice ${j + 1}/${parts} of file ${data.name} (${data.duration} sec)`); - var dp = $('#progress-'+window.fc); + var dp = $(`#progress-${window.fc}`); var key = dp.attr('data-key'); if (j + 1 === parts) { @@ -474,44 +481,44 @@ function updateProgressBar(data) { console.log('Connection is closed.'); }; window.ws.onerror = function() { - console.log('Error on WebSocket connection but file has been fully send, so we don\'t care.'); + console.log('Error on WebSocket connection but file has been fully send, so we don’t care.'); } notify(i18n.fileUploaded, data.name); - $('#parts-'+window.fc).remove(); - var n = $('#name-'+window.fc); - var s = $('#size-'+window.fc); + $(`#parts-${window.fc}`).remove(); + var n = $(`#name-${window.fc}`); + var s = $(`#size-${window.fc}`); var d = $('
    '); - var url = baseURL+'r/'+short+'#'+key; - var del_url = actionURL+'d/'+short+'/'+data.token; - var links = encodeURIComponent('["'+short+'"]'); + var url = `${baseURL}r/${short}#${key}`; + var del_url = `${actionURL}d/${short}/${data.token}`; + var links = encodeURIComponent(`["${short}"]`); var limit = (delay === 0) ? i18n.noLimit : i18n.expiration+' '+moment.unix(delay * 86400 + created_at).locale(window.navigator.language).format('LLLL'); if (!isGuest) { - n.html(n.html()+' '+s.html()+'
    '+limit); - d.html(['
    ', - '
    ', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '
    ', - '
    ', - '', - '', - '', - '', - '', - '
    ', - '
    '].join('')); + n.html(`${n.html()} ${s.html()}
    ${limit}`); + d.html(`
    +
    + + + + + + + + + + +
    +
    + + + + + +
    +
    `); } else { - n.html(n.html()+' '+s.html()); + n.html(`${n.html()} ${s.html()}`); } s.remove(); @@ -521,7 +528,7 @@ function updateProgressBar(data) { p2.remove(); p1.append(d); - $('#copyurl-'+window.fc).on('click', function(e) { + $(`#copyurl-${window.fc}`).on('click', function(e) { e.preventDefault(); copyToClipboard(url); }); @@ -531,7 +538,12 @@ function updateProgressBar(data) { // Add copy all and mailto buttons var misc = $('#misc'); if (misc.html() === '' && !isGuest) { - misc.html(''+i18n.copyAll+' '+i18n.mailTo+''); + misc.html(`${i18n.copyAll} + ${i18n.mailTo}`); $('#copyall').on('click', copyAllToClipboard); } else { updateMailLink(); @@ -574,7 +586,7 @@ function updateProgressBar(data) { var wClass = percent.toString().replace('.', '-'); dp.removeClass(); dp.addClass('determinate'); - dp.addClass('width-'+wClass); + dp.addClass(`width-${wClass}`); dp.attr('aria-valuenow', percent); // Encrypt and upload next slice @@ -593,15 +605,15 @@ function updateProgressBar(data) { // Write message instead in a file block function addAlertOnFile(msg, i, sent_delay, del_at_first_view) { - var n = $('#name-'+window.fc); - var p = $('#progress-'+window.fc); + var n = $(`#name-${window.fc}`); + var p = $(`#progress-${window.fc}`); var d = $('
    '); p.parent().remove(); d.addClass('card pink'); - d.html(['
    ', - '', msg, '', - '
    '].join('')); + d.html(`
    + ${msg} +
    `); n.parent().append(d); // Upload next file @@ -653,7 +665,7 @@ function spawnWebsocket(i, callback) { ws.onerror = function() { console.log('error'); if (i < 5 && callback !== undefined) { - console.log('Retrying to send file (try '+i+' of 5)'); + console.log(`Retrying to send file (try ${i} of 5)`); window.ws = spawnWebsocket(i + 1, callback); } } diff --git a/themes/default/templates/partial/mail.js.ep b/themes/default/templates/partial/mail.js.ep index 15e7332..72598f6 100644 --- a/themes/default/templates/partial/mail.js.ep +++ b/themes/default/templates/partial/mail.js.ep @@ -1,6 +1,6 @@ % # vim:set sts=4 sw=4 ts=4 ft=javascript expandtab: function findItem(name) { - var files = localStorage.getItem(window.prefix + 'files'); + var files = localStorage.getItem(`${window.prefix}files`); if (files === null) { files = new Array(); } else { @@ -19,7 +19,7 @@ function updateMailtoLink() { var subject = document.getElementById('subject'); var text = document.getElementById('body'); - btn.href = 'mailto:'+encodeURIComponent(emails.value)+'?subject='+encodeURIComponent(subject.value)+'&body='+encodeURIComponent(text.value); + btn.href = `mailto:${encodeURIComponent(emails.value)}?subject=${encodeURIComponent(subject.value)}&body=${encodeURIComponent(text.value)}`; } function populateBody() { var links = [ @@ -37,16 +37,16 @@ function populateBody() { var item = findItem(name); if (item !== null && item !== undefined) { var limit = (item.delay === 0) ? null : moment.unix(item.delay * 86400 + item.created_at).locale(window.navigator.language).format('LLLL'); - text = text+'- '+item.name+'<%= l(':') %> '+item.url; + text += `- ${item.name}<%= l(':') %> ${item.url}`; if (limit !== null) { - text = text+"\n (<%= l('deadline: ') %>"+limit+')'; + text += `\n (<%= l('deadline: ') %>${limit})`; } - text = text+"\n"; + text += "\n"; } }); % if (!defined(config('ldap')) && !defined(config('htpasswd'))) { - text = text+"\n-- \n<%= l('Share your files in total privacy on %1', url_for('/')->to_abs) %>"; + text += "\n-- \n<%= l('Share your files in total privacy on %1', url_for('/')->to_abs) %>"; % } tArea = document.getElementById('body').value = text; updateMailtoLink();