Formatting

This commit is contained in:
Booteille 2024-08-02 08:07:17 +02:00
parent d071467ea7
commit 3ab54f6dae
No known key found for this signature in database
GPG Key ID: 0FE17AFD5A1F837F
2 changed files with 101 additions and 101 deletions

View File

@ -18,18 +18,18 @@ function pageKey() {
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;
@ -102,7 +102,7 @@ function spawnWebsocket(pa) {
slice.iv = new Uint8Array(Object.values(slice.iv))
}
var percent = Math.round(1000 * (data.part + 1)/data.total)/10;
var percent = Math.round(1000 * (data.part + 1) / data.total) / 10;
var wClass = percent.toString().replace('.', '-');
var pb = $('#pb');
pb.removeClass();
@ -150,14 +150,14 @@ function spawnWebsocket(pa) {
pbd.html(innerHTML);
if (isZip) {
$('#showZipContent').click(function() {
$('#showZipContent').click(function () {
JSZip.loadAsync(blob)
.then(function (zip) {
var innerHTML = `<h3>${i18n.zipContent}</h3><ul>`;
zip.forEach(function (relativePath, zipEntry) {
innerHTML += `<li>
${escapeHtml(zipEntry.name)}
(${filesize(zipEntry._data.uncompressedSize, {base: 10})})
(${filesize(zipEntry._data.uncompressedSize, { base: 10 })})
<a href="#"
download="${escapeHtml(zipEntry.name)}"
class="download-zip-content"
@ -168,11 +168,11 @@ function spawnWebsocket(pa) {
});
innerHTML += '</ul>';
pbd.append(innerHTML);
$('.download-zip-content').click(function(e) {
$('.download-zip-content').click(function (e) {
e.preventDefault();
var t = $(this);
var filename = t.attr('download');
zip.files[filename].async('blob').then(function(blob) {
zip.files[filename].async('blob').then(function (blob) {
t.unbind('click');
t.attr('href', URL.createObjectURL(blob));
t[0].click();
@ -198,14 +198,14 @@ function spawnWebsocket(pa) {
if (ws.readyState === 3) {
window.ws = spawnWebsocket(data.part + 1);
} else {
window.ws.onclose = function() {
window.ws.onclose = function () {
console.log('Connection is closed');
if (!window.completed) {
console.log(`Connection closed. Retrying to get slice ${data.part + 1}`);
window.ws = spawnWebsocket(data.part + 1);
}
}
window.ws.onerror = function() {
window.ws.onerror = function () {
console.log(`Error. Retrying to get slice ${data.part + 1}`);
window.ws = spawnWebsocket(data.part + 1);
};

View File

@ -300,7 +300,7 @@ function uploadFile(i, delay, del_at_first_view) {
<div class="card-content">
<span class="card-title"
id="name-${window.fc}">${name}</span>
<span id="size-${window.fc }">(${size})</span>
<span id="size-${window.fc}">(${size})</span>
<p id="parts-${window.fc}"></p>
</div>
<div class="progress">
@ -317,7 +317,7 @@ function uploadFile(i, delay, del_at_first_view) {
</div>
<div>`);
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);
@ -392,27 +392,27 @@ function sliceAndUpload(randomKey, i, parts, j, delay, del_at_first_view, short,
data = `${JSON.stringify(data)}XXMOJOXX${JSON.stringify(encrypted)}`;
var percent = Math.round(1000 * j/parts)/10;
var percent = Math.round(1000 * j / parts) / 10;
console.log(`sending slice ${j + 1}/${parts} of file ${file.name} (${percent}%)`);
sl.html(`${percent.toFixed(1)}%`);
// Verify that we have a websocket and send json
if (window.ws.readyState === 3) {
window.ws = spawnWebsocket(0, function() {
window.ws = spawnWebsocket(0, function () {
window.ws.send(data);
});
} else {
window.ws.onclose = function() {
window.ws.onclose = function () {
console.log('Websocket closed, waiting 10sec.');
window.ws = spawnWebsocket(0, function() {
window.ws = spawnWebsocket(0, function () {
console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`);
window.ws.send(data);
});
};
window.ws.onerror = function() {
window.ws.onerror = function () {
console.log('Error on Websocket, waiting 10sec.');
window.ws = spawnWebsocket(0, function() {
window.ws = spawnWebsocket(0, function () {
console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`);
window.ws.send(data);
});
@ -476,7 +476,7 @@ function updateProgressBar(data) {
window.ws.onclose = function () {
console.log('Connection is closed.');
};
window.ws.onerror = function() {
window.ws.onerror = function () {
console.log('Error on WebSocket connection but file has been fully send, so we dont care.');
}
@ -524,7 +524,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);
});