diff --git a/themes/default/public/js/lufi-down.js b/themes/default/public/js/lufi-down.js index 386bbf7..d933f6d 100644 --- a/themes/default/public/js/lufi-down.js +++ b/themes/default/public/js/lufi-down.js @@ -17,19 +17,19 @@ function pageKey() { // First, strip everything after the equal sign (=) which signals end of base64 string. i = key.indexOf('='); let isb64 = false - - if (i>-1) { + + if (i > -1) { key = key.substring(0, i + 1); - + isb64 = true } // 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 and was using the Sjcl algorithm if (isb64) { - if (key.charAt(key.length-1)!=='=') key += '='; + if (key.charAt(key.length - 1) !== '=') key += '='; } return key; @@ -95,16 +95,16 @@ function spawnWebsocket(pa) { window.attempts = 10; } else { console.log(`Getting slice ${data.part + 1} of ${data.total}`); - var slice = JSON.parse(res.shift()); - + var slice = JSON.parse(res.shift()); + // If file was used using Lufi API if (slice.iv) { slice.iv = new Uint8Array(Object.values(slice.iv)) } - var percent = Math.round(1000 * (data.part + 1)/data.total)/10; - var wClass = percent.toString().replace('.', '-'); - var pb = $('#pb'); + 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}`); @@ -112,7 +112,7 @@ function spawnWebsocket(pa) { $('#pbt').html(`${percent}%`); try { lufiApi.lufiCrypto.decrypt(window.key, slice).then((decrypted) => { - window.a[data.part] = decrypted; + window.a[data.part] = decrypted; if (data.part + 1 === data.total) { var blob = new Blob(a, { type: data.type }); @@ -121,43 +121,43 @@ function spawnWebsocket(pa) { $('#please-wait').remove(); $('#loading').remove(); - var pbd = $('#pbd'); - pbd.attr('class', 'center-align'); - // IE & Edge fix for downloading blob files, gives option to save or open the file when the link is opened. - if (window.navigator && window.navigator.msSaveOrOpenBlob) { - var fileName = escapeHtml(data.name); - window.navigator.msSaveOrOpenBlob(blob, fileName); - } else { - var blobURL = URL.createObjectURL(blob); - } - var innerHTML = `

${i18n.download}

`; + var pbd = $('#pbd'); + pbd.attr('class', 'center-align'); + // IE & Edge fix for downloading blob files, gives option to save or open the file when the link is opened. + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + var fileName = escapeHtml(data.name); + window.navigator.msSaveOrOpenBlob(blob, fileName); + } else { + var blobURL = URL.createObjectURL(blob); + } + var innerHTML = `

${i18n.download}

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