Formatting
This commit is contained in:
parent
d071467ea7
commit
3ab54f6dae
|
@ -18,18 +18,18 @@ function pageKey() {
|
||||||
i = key.indexOf('=');
|
i = key.indexOf('=');
|
||||||
let isb64 = false
|
let isb64 = false
|
||||||
|
|
||||||
if (i>-1) {
|
if (i > -1) {
|
||||||
key = key.substring(0, i + 1);
|
key = key.substring(0, i + 1);
|
||||||
|
|
||||||
isb64 = true
|
isb64 = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the equal sign was not present, some parameters may remain:
|
// 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
|
// Then add trailing equal sign if it's missing and was using the Sjcl algorithm
|
||||||
if (isb64) {
|
if (isb64) {
|
||||||
if (key.charAt(key.length-1)!=='=') key += '=';
|
if (key.charAt(key.length - 1) !== '=') key += '=';
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
|
@ -102,7 +102,7 @@ function spawnWebsocket(pa) {
|
||||||
slice.iv = new Uint8Array(Object.values(slice.iv))
|
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 wClass = percent.toString().replace('.', '-');
|
||||||
var pb = $('#pb');
|
var pb = $('#pb');
|
||||||
pb.removeClass();
|
pb.removeClass();
|
||||||
|
@ -150,14 +150,14 @@ function spawnWebsocket(pa) {
|
||||||
pbd.html(innerHTML);
|
pbd.html(innerHTML);
|
||||||
|
|
||||||
if (isZip) {
|
if (isZip) {
|
||||||
$('#showZipContent').click(function() {
|
$('#showZipContent').click(function () {
|
||||||
JSZip.loadAsync(blob)
|
JSZip.loadAsync(blob)
|
||||||
.then(function (zip) {
|
.then(function (zip) {
|
||||||
var innerHTML = `<h3>${i18n.zipContent}</h3><ul>`;
|
var innerHTML = `<h3>${i18n.zipContent}</h3><ul>`;
|
||||||
zip.forEach(function (relativePath, zipEntry) {
|
zip.forEach(function (relativePath, zipEntry) {
|
||||||
innerHTML += `<li>
|
innerHTML += `<li>
|
||||||
${escapeHtml(zipEntry.name)}
|
${escapeHtml(zipEntry.name)}
|
||||||
(${filesize(zipEntry._data.uncompressedSize, {base: 10})})
|
(${filesize(zipEntry._data.uncompressedSize, { base: 10 })})
|
||||||
<a href="#"
|
<a href="#"
|
||||||
download="${escapeHtml(zipEntry.name)}"
|
download="${escapeHtml(zipEntry.name)}"
|
||||||
class="download-zip-content"
|
class="download-zip-content"
|
||||||
|
@ -168,11 +168,11 @@ function spawnWebsocket(pa) {
|
||||||
});
|
});
|
||||||
innerHTML += '</ul>';
|
innerHTML += '</ul>';
|
||||||
pbd.append(innerHTML);
|
pbd.append(innerHTML);
|
||||||
$('.download-zip-content').click(function(e) {
|
$('.download-zip-content').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var t = $(this);
|
var t = $(this);
|
||||||
var filename = t.attr('download');
|
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.unbind('click');
|
||||||
t.attr('href', URL.createObjectURL(blob));
|
t.attr('href', URL.createObjectURL(blob));
|
||||||
t[0].click();
|
t[0].click();
|
||||||
|
@ -198,14 +198,14 @@ function spawnWebsocket(pa) {
|
||||||
if (ws.readyState === 3) {
|
if (ws.readyState === 3) {
|
||||||
window.ws = spawnWebsocket(data.part + 1);
|
window.ws = spawnWebsocket(data.part + 1);
|
||||||
} else {
|
} else {
|
||||||
window.ws.onclose = function() {
|
window.ws.onclose = function () {
|
||||||
console.log('Connection is closed');
|
console.log('Connection is closed');
|
||||||
if (!window.completed) {
|
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 = spawnWebsocket(data.part + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.ws.onerror = function() {
|
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);
|
window.ws = spawnWebsocket(data.part + 1);
|
||||||
};
|
};
|
||||||
|
|
|
@ -300,7 +300,7 @@ function uploadFile(i, delay, del_at_first_view) {
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title"
|
<span class="card-title"
|
||||||
id="name-${window.fc}">${name}</span>
|
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>
|
<p id="parts-${window.fc}"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
|
@ -317,7 +317,7 @@ function uploadFile(i, delay, del_at_first_view) {
|
||||||
</div>
|
</div>
|
||||||
<div>`);
|
<div>`);
|
||||||
r.prepend(w);
|
r.prepend(w);
|
||||||
$(`#destroy-${window.fc}`).on('click', function(event) {
|
$(`#destroy-${window.fc}`).on('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
window.cancelled.push(i);
|
window.cancelled.push(i);
|
||||||
destroyBlock(this);
|
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)}`;
|
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}%)`);
|
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
|
// Verify that we have a websocket and send json
|
||||||
if (window.ws.readyState === 3) {
|
if (window.ws.readyState === 3) {
|
||||||
window.ws = spawnWebsocket(0, function() {
|
window.ws = spawnWebsocket(0, function () {
|
||||||
window.ws.send(data);
|
window.ws.send(data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.ws.onclose = function() {
|
window.ws.onclose = function () {
|
||||||
console.log('Websocket closed, waiting 10sec.');
|
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}`);
|
console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`);
|
||||||
window.ws.send(data);
|
window.ws.send(data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
window.ws.onerror = function() {
|
window.ws.onerror = function () {
|
||||||
console.log('Error on Websocket, waiting 10sec.');
|
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}`);
|
console.log(`sending again slice ${j + 1}/${parts} of file ${file.name}`);
|
||||||
window.ws.send(data);
|
window.ws.send(data);
|
||||||
});
|
});
|
||||||
|
@ -476,7 +476,7 @@ function updateProgressBar(data) {
|
||||||
window.ws.onclose = function () {
|
window.ws.onclose = function () {
|
||||||
console.log('Connection is closed.');
|
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 don’t care.');
|
console.log('Error on WebSocket connection but file has been fully send, so we don’t care.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ function updateProgressBar(data) {
|
||||||
p2.remove();
|
p2.remove();
|
||||||
p1.append(d);
|
p1.append(d);
|
||||||
|
|
||||||
$(`#copyurl-${window.fc}`).on('click', function(e) {
|
$(`#copyurl-${window.fc}`).on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
copyToClipboard(url);
|
copyToClipboard(url);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue