🎨 — Use template literals in js
This commit is contained in:
parent
43ee9fc4da
commit
cd4168d2b8
|
@ -3,6 +3,7 @@ Revision history for Lufi
|
||||||
0.07.0 ????-??-??
|
0.07.0 ????-??-??
|
||||||
- ⬆️ — Update jQuery
|
- ⬆️ — Update jQuery
|
||||||
- 🩹 — Fix a format query parameter
|
- 🩹 — Fix a format query parameter
|
||||||
|
- 🎨 — Use template literals in js
|
||||||
|
|
||||||
0.06.00 2023-12-18
|
0.06.00 2023-12-18
|
||||||
- ⬆️ — Update deps
|
- ⬆️ — Update deps
|
||||||
|
|
|
@ -11,13 +11,13 @@ function pageKey() {
|
||||||
// We will strip any additional data.
|
// We will strip any additional data.
|
||||||
|
|
||||||
// First, strip everything after the equal sign (=) which signals end of base64 string.
|
// 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:
|
// 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
|
// 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;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ function addAlert(msg) {
|
||||||
var pbd = $('.file-progress');
|
var pbd = $('.file-progress');
|
||||||
pbd.attr('role', 'alert');
|
pbd.attr('role', 'alert');
|
||||||
pbd.removeClass('progress');
|
pbd.removeClass('progress');
|
||||||
pbd.html(['<div class="card pink">',
|
pbd.html(`<div class="card pink">
|
||||||
'<div class="card-content white-text">',
|
<div class="card-content white-text">
|
||||||
'<strong>', msg, '</strong>',
|
<strong>${msg}</strong>
|
||||||
'</div>',
|
</div>
|
||||||
'</div>'].join(''));
|
</div>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn WebSocket
|
// Spawn WebSocket
|
||||||
|
@ -55,9 +55,10 @@ function spawnWebsocket(pa) {
|
||||||
var l = $('#loading');
|
var l = $('#loading');
|
||||||
l.html(i18n.loading.replace(/XX1/, (pa + 1)));
|
l.html(i18n.loading.replace(/XX1/, (pa + 1)));
|
||||||
if ($('#file_pwd').length === 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 {
|
} else {
|
||||||
window.ws.send('{"part":'+pa+'}');
|
window.ws.send(`{"part":${pa}}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
|
@ -65,7 +66,7 @@ function spawnWebsocket(pa) {
|
||||||
if (!window.completed) {
|
if (!window.completed) {
|
||||||
window.attempts++;
|
window.attempts++;
|
||||||
if (window.attempts < 10) {
|
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);
|
window.ws = spawnWebsocket(pa);
|
||||||
} else {
|
} else {
|
||||||
alert(i18n.tooMuchAttempts);
|
alert(i18n.tooMuchAttempts);
|
||||||
|
@ -89,16 +90,16 @@ function spawnWebsocket(pa) {
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
window.attempts = 10;
|
window.attempts = 10;
|
||||||
} else {
|
} 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 slice = JSON.parse(res.shift());
|
||||||
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();
|
||||||
pb.addClass('determinate');
|
pb.addClass('determinate');
|
||||||
pb.addClass('width-'+wClass);
|
pb.addClass(`width-${wClass}`);
|
||||||
pb.attr('aria-valuenow', percent);
|
pb.attr('aria-valuenow', percent);
|
||||||
$('#pbt').html(percent+'%');
|
$('#pbt').html(`${percent}%`);
|
||||||
try {
|
try {
|
||||||
var b64 = sjcl.decrypt(window.key, slice);
|
var b64 = sjcl.decrypt(window.key, slice);
|
||||||
window.a[data.part] = base64ToArrayBuffer(b64);
|
window.a[data.part] = base64ToArrayBuffer(b64);
|
||||||
|
@ -118,43 +119,44 @@ function spawnWebsocket(pa) {
|
||||||
} else {
|
} else {
|
||||||
var blobURL = URL.createObjectURL(blob);
|
var blobURL = URL.createObjectURL(blob);
|
||||||
}
|
}
|
||||||
var innerHTML = ['<p><a href="', blobURL, '" class="btn btn-primary" download="', escapeHtml(data.name), '">', i18n.download, '</a></p>'];
|
var innerHTML = `<p><a href="${blobURL}" class="btn btn-primary" download="${escapeHtml(data.name)}">${i18n.download}</a></p>`;
|
||||||
|
|
||||||
var isZip = ($('#filesize').attr('data-zipped') === 'true');
|
var isZip = ($('#filesize').attr('data-zipped') === 'true');
|
||||||
if (data.type.match(/^image\//) !== null) {
|
if (data.type.match(/^image\//) !== null) {
|
||||||
innerHTML.push('<img id="render-image" class="responsive-img" alt="', escapeHtml(data.name), '" src="', blobURL, '">');
|
innerHTML += `<img id="render-image" class="responsive-img" alt="${escapeHtml(data.name)}" src="${blobURL}">`;
|
||||||
} else if (data.type.match(/^video\//) !== null) {
|
} else if (data.type.match(/^video\//) !== null) {
|
||||||
innerHTML.push('<video class="responsive-video" controls>',
|
innerHTML += `<video class="responsive-video" controls>
|
||||||
'<source src="', blobURL, '" type="', data.type, '">',
|
<source src="${blobURL}" type="${data.type}">
|
||||||
'</video>');
|
</video>`;
|
||||||
} else if (data.type.match(/^audio\//) !== null) {
|
} else if (data.type.match(/^audio\//) !== null) {
|
||||||
innerHTML.push('<audio class="responsive-video" controls>',
|
innerHTML += `<audio class="responsive-video" controls>
|
||||||
'<source src="', blobURL, '" type="', data.type, '">',
|
<source src="${blobURL}" type="${data.type}">
|
||||||
'</audio>');
|
</audio>`;
|
||||||
} else if (isZip) {
|
} else if (isZip) {
|
||||||
innerHTML.push('<p><a class="btn btn-primary" id="showZipContent">', i18n.showZipContent, '</a></p>');
|
innerHTML += `<p><a class="btn btn-primary" id="showZipContent">${i18n.showZipContent}</a></p>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbd.html(innerHTML.join(''));
|
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.push(
|
innerHTML += `<li>
|
||||||
'<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), '" class="download-zip-content" title="', i18n.download, '">',
|
download="${escapeHtml(zipEntry.name)}"
|
||||||
'<i class="mdi-file-file-download"></i>',
|
class="download-zip-content"
|
||||||
'</a>',
|
title="${i18n.download}">
|
||||||
'</li>'
|
<i class="mdi-file-file-download"></i>
|
||||||
);
|
</a>
|
||||||
|
</li>`
|
||||||
});
|
});
|
||||||
innerHTML.push('</ul>');
|
innerHTML += '</ul>';
|
||||||
pbd.append(innerHTML.join(''));
|
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);
|
||||||
|
@ -171,7 +173,8 @@ function spawnWebsocket(pa) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($('#file_pwd').length === 1) {
|
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 {
|
} else {
|
||||||
window.ws.send('{"ended":true}');
|
window.ws.send('{"ended":true}');
|
||||||
}
|
}
|
||||||
|
@ -187,18 +190,19 @@ function spawnWebsocket(pa) {
|
||||||
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);
|
||||||
};
|
};
|
||||||
if ($('#file_pwd').length === 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 {
|
} 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() {
|
ws.onerror = function() {
|
||||||
window.attempts++;
|
window.attempts++;
|
||||||
if (window.attempts < 10) {
|
if (window.attempts < 10) {
|
||||||
console.log('Error. Retrying to get slice '+pa);
|
console.log(`Error. Retrying to get slice ${pa}`);
|
||||||
window.ws = spawnWebsocket(pa);
|
window.ws = spawnWebsocket(pa);
|
||||||
} else {
|
} else {
|
||||||
alert(i18n.tooMuchAttempts);
|
alert(i18n.tooMuchAttempts);
|
||||||
|
@ -229,7 +233,13 @@ $(document).ready(function(){
|
||||||
window.ws.onclose = function() {};
|
window.ws.onclose = function() {};
|
||||||
window.ws.close();
|
window.ws.close();
|
||||||
$('#please-wait, #loading, #pbd, #abort').remove();
|
$('#please-wait, #loading, #pbd, #abort').remove();
|
||||||
$('#filesize').parent().append('<h4>'+i18n.aborted1+'</h4><a id="reloadLocation" class="waves-effect waves-light btn">'+i18n.aborted2+'</a></p>');
|
$('#filesize').parent().append(`<h4>${i18n.aborted1}</h4>
|
||||||
|
<p>
|
||||||
|
<a id="reloadLocation"
|
||||||
|
class="waves-effect waves-light btn">
|
||||||
|
${i18n.aborted2}
|
||||||
|
</a>
|
||||||
|
</p>`);
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
$('#reloadLocation').on('click', function(e) {
|
$('#reloadLocation').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
// vim:set sw=4 ts=4 sts=4 ft=javascript expandtab:
|
// vim:set sw=4 ts=4 sts=4 ft=javascript expandtab:
|
||||||
// Add item to localStorage
|
// Add item to localStorage
|
||||||
function addItem(item) {
|
function addItem(item) {
|
||||||
var files = localStorage.getItem(window.prefix + 'files');
|
var files = localStorage.getItem(`${window.prefix}files`);
|
||||||
if (files === null) {
|
if (files === null) {
|
||||||
files = new Array();
|
files = new Array();
|
||||||
} else {
|
} else {
|
||||||
files = JSON.parse(files);
|
files = JSON.parse(files);
|
||||||
}
|
}
|
||||||
files.push(item);
|
files.push(item);
|
||||||
localStorage.setItem(window.prefix + 'files', JSON.stringify(files));
|
localStorage.setItem(`${window.prefix}files`, JSON.stringify(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
function delItem(name) {
|
function delItem(name) {
|
||||||
var files = localStorage.getItem(window.prefix + 'files');
|
var files = localStorage.getItem(`${window.prefix}files`);
|
||||||
if (files === null) {
|
if (files === null) {
|
||||||
files = new Array();
|
files = new Array();
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,11 +24,11 @@ function delItem(name) {
|
||||||
files.splice(i, 1);
|
files.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem(window.prefix + 'files', JSON.stringify(files));
|
localStorage.setItem(`${window.prefix}files`, JSON.stringify(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
function itemExists(name) {
|
function itemExists(name) {
|
||||||
var files = localStorage.getItem(window.prefix + 'files');
|
var files = localStorage.getItem(`${window.prefix}files`);
|
||||||
if (files === null) {
|
if (files === null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +59,7 @@ function invertSelection(event) {
|
||||||
|
|
||||||
function purgeExpired(event) {
|
function purgeExpired(event) {
|
||||||
event.preventDefault();
|
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) {
|
files.forEach(function(element, index, array) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -73,7 +73,7 @@ function purgeExpired(event) {
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
if (data.deleted) {
|
if (data.deleted) {
|
||||||
$('#count-'+data.short).parent().remove();
|
$(`#count-${data.short}`).parent().remove();
|
||||||
delItem(data.short);
|
delItem(data.short);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,11 @@ function purgeExpired(event) {
|
||||||
|
|
||||||
function exportStorage(event) {
|
function exportStorage(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var a = $('<a id="data-json">');
|
var a = $('<a id="data-json">');
|
||||||
a.hide();
|
a.hide();
|
||||||
$('body').append(a);
|
$('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 exportFile = new Blob(storageData, {type : 'application/json'});
|
||||||
var url = window.URL.createObjectURL(exportFile);
|
var url = window.URL.createObjectURL(exportFile);
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ function delFile() {
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
$('#row-'+short).remove();
|
$(`#row-${short}`).remove();
|
||||||
delItem(short);
|
delItem(short);
|
||||||
} else {
|
} else {
|
||||||
alert(data.msg);
|
alert(data.msg);
|
||||||
|
@ -178,15 +178,15 @@ function massDelete(event) {
|
||||||
function populateFilesTable() {
|
function populateFilesTable() {
|
||||||
$('#myfiles').empty();
|
$('#myfiles').empty();
|
||||||
|
|
||||||
var files = localStorage.getItem(window.prefix + 'files');
|
var files = localStorage.getItem(`${window.prefix}files`);
|
||||||
if (files === null) {
|
if (files === null) {
|
||||||
var filesWithoutPrefix = localStorage.getItem('files');
|
var filesWithoutPrefix = localStorage.getItem('files');
|
||||||
if (filesWithoutPrefix !== null) {
|
if (filesWithoutPrefix !== null) {
|
||||||
if (window.confirm(i18n.importFilesWithoutPrefix)) {
|
if (window.confirm(i18n.importFilesWithoutPrefix)) {
|
||||||
localStorage.setItem(window.prefix + 'files', filesWithoutPrefix);
|
localStorage.setItem(`${window.prefix}files`, filesWithoutPrefix);
|
||||||
files = JSON.parse(filesWithoutPrefix);
|
files = JSON.parse(filesWithoutPrefix);
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem(window.prefix + 'files', JSON.stringify([]));
|
localStorage.setItem(`${window.prefix}files`, JSON.stringify([]));
|
||||||
files = new Array();
|
files = new Array();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -206,45 +206,59 @@ function populateFilesTable() {
|
||||||
});
|
});
|
||||||
files.forEach(function(element, index, array) {
|
files.forEach(function(element, index, array) {
|
||||||
var del_view = (element.del_at_first_view) ? '<i class="small mdi-action-done"></i>' : '<i class="small mdi-navigation-close"></i>';
|
var del_view = (element.del_at_first_view) ? '<i class="small mdi-action-done"></i>' : '<i class="small mdi-navigation-close"></i>';
|
||||||
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 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 created_at = moment.unix(element.created_at).locale(window.navigator.language).format('LLLL');
|
||||||
|
|
||||||
var tr = $('<tr id="row-'+element.short+'">');
|
var tr = $(`<tr id="row-${element.short}">`);
|
||||||
tr.html([ '<td class="center-align">',
|
tr.html(`<td class="center-align">
|
||||||
'<input type="checkbox" id="check-', element.short,'" data-short="', element.short, '" data-dlink="', dlink, '" data-checked="">',
|
<input type="checkbox"
|
||||||
'<label for="check-', element.short,'"></label>',
|
id="check-${element.short}"
|
||||||
'</td>',
|
data-short="${element.short}"
|
||||||
'<td class="left-align">',
|
data-dlink="${dlink}"
|
||||||
escapeHtml(element.name),
|
data-checked="">
|
||||||
'</td>',
|
<label for="check-${element.short}"></label>
|
||||||
'<td class="center-align">',
|
</td>
|
||||||
'<a href="', element.url, '" class="classic"><i class="small mdi-file-file-download"></i></a>',
|
<td class="left-align">
|
||||||
'</td>',
|
${escapeHtml(element.name)}
|
||||||
'<td id="count-', element.short, '" class="center-align">',
|
</td>
|
||||||
'</td>',
|
<td class="center-align">
|
||||||
'<td class="center-align">',
|
<a href="${element.url}"
|
||||||
del_view,
|
class="classic">
|
||||||
'</td>',
|
<i class="small mdi-file-file-download"></i>
|
||||||
'<td>',
|
</a>
|
||||||
created_at,
|
</td>
|
||||||
'</td>',
|
<td id="count-${element.short}" class="center-align">
|
||||||
'<td>',
|
</td>
|
||||||
limit,
|
<td class="center-align">
|
||||||
'</td>',
|
${del_view}
|
||||||
'<td class="center-align">',
|
</td>
|
||||||
'<a id="del-', element.short, '" data-short="', element.short, '" data-dlink="', dlink, '" href="#" class="classic"><i class="small mdi-action-delete"></i></a>',
|
<td>
|
||||||
'</td>',
|
${created_at}
|
||||||
'<td class="center-align">',
|
</td>
|
||||||
'<a href="'+actionURL+'m?links=["'+element.short+'"]" class="classic"><i class="small mdi-communication-email"></i></a>',
|
<td>
|
||||||
'</td>'].join(''));
|
${limit}
|
||||||
|
</td>
|
||||||
|
<td class="center-align">
|
||||||
|
<a id="del-${element.short}"
|
||||||
|
data-short="${element.short}"
|
||||||
|
data-dlink="${dlink}"
|
||||||
|
href="#"
|
||||||
|
class="classic">
|
||||||
|
<i class="small mdi-action-delete"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="center-align">
|
||||||
|
<a href="${actionURL}m?links=["${element.short}"]"
|
||||||
|
class="classic"><i class="small mdi-communication-email"></i></a>
|
||||||
|
</td>`);
|
||||||
$('#myfiles').append(tr);
|
$('#myfiles').append(tr);
|
||||||
$('#del-'+element.short).on('click', delFile);
|
$(`#del-${element.short}`).on('click', delFile);
|
||||||
$('label[for="check-'+element.short+'"]').on('click', function(){
|
$(`label[for="check-${element.short}"]`).on('click', function(){
|
||||||
if ($('#check-'+element.short).attr('data-checked') && $('#check-'+element.short).attr('data-checked') === 'data-checked') {
|
if ($(`#check-${element.short}`).attr('data-checked') && $(`#check-${element.short}`).attr('data-checked') === 'data-checked') {
|
||||||
$('#check-'+element.short).attr('data-checked', null);
|
$(`#check-${element.short}`).attr('data-checked', null);
|
||||||
} else {
|
} else {
|
||||||
$('#check-'+element.short).attr('data-checked', 'data-checked');
|
$(`#check-${element.short}`).attr('data-checked', 'data-checked');
|
||||||
}
|
}
|
||||||
evaluateMassDelete();
|
evaluateMassDelete();
|
||||||
});
|
});
|
||||||
|
@ -259,13 +273,13 @@ function populateFilesTable() {
|
||||||
},
|
},
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
$('#count-'+data.short).html(data.counter);
|
$(`#count-${data.short}`).html(data.counter);
|
||||||
if (data.deleted) {
|
if (data.deleted) {
|
||||||
$('#count-'+data.short).parent().addClass('purple lighten-4');
|
$(`#count-${data.short}`).parent().addClass('purple lighten-4');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(data.msg);
|
alert(data.msg);
|
||||||
$('#count-'+data.short).parent().remove();
|
$(`#count-${data.short}`).parent().remove();
|
||||||
if (data.missing) {
|
if (data.missing) {
|
||||||
delItem(data.short);
|
delItem(data.short);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ function deleteInvit(e) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
data.tokens.forEach(function(t) {
|
data.tokens.forEach(function(t) {
|
||||||
Materialize.toast(t.msg, 6000, 'teal accent-3');
|
Materialize.toast(t.msg, 6000, 'teal accent-3');
|
||||||
$('#row-' + t.token).remove();
|
$(`#row-${t.token}`).remove();
|
||||||
});
|
});
|
||||||
data.failures.forEach(function(msg) {
|
data.failures.forEach(function(msg) {
|
||||||
Materialize.toast(msg, 10000, 'red accent-2');
|
Materialize.toast(msg, 10000, 'red accent-2');
|
||||||
|
@ -74,8 +74,8 @@ function resendMail(e) {
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
data.success.forEach(function(s) {
|
data.success.forEach(function(s) {
|
||||||
Materialize.toast(s.msg, 6000, 'teal accent-3');
|
Materialize.toast(s.msg, 6000, 'teal accent-3');
|
||||||
$('#expire-' + s.token).text(s.expires)
|
$(`#expire-${s.token}`).text(s.expires)
|
||||||
$('#' + s.token).click();
|
$(`#${s.token}`).click();
|
||||||
});
|
});
|
||||||
data.failures.forEach(function(msg) {
|
data.failures.forEach(function(msg) {
|
||||||
Materialize.toast(msg, 10000, 'red accent-2');
|
Materialize.toast(msg, 10000, 'red accent-2');
|
||||||
|
@ -97,19 +97,19 @@ function toggleVisibility(e) {
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
data.tokens.forEach(function(t) {
|
data.tokens.forEach(function(t) {
|
||||||
var row = $('#row-' + t.token)
|
var row = $(`#row-${t.token}`)
|
||||||
if (t.show) {
|
if (t.show) {
|
||||||
row.attr('data-visibility', 1);
|
row.attr('data-visibility', 1);
|
||||||
row.removeClass('hide');
|
row.removeClass('hide');
|
||||||
$('#row-' + t.token + ' > td:first i').remove();
|
$(`#row-${t.token} > td:first i`).remove();
|
||||||
} else {
|
} else {
|
||||||
row.attr('data-visibility', 0);
|
row.attr('data-visibility', 0);
|
||||||
if ($('#myInvitations').attr('data-visibility') === 'hidden') {
|
if ($('#myInvitations').attr('data-visibility') === 'hidden') {
|
||||||
row.addClass('hide');
|
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();
|
disableButtons();
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,25 +169,17 @@ function fillModal() {
|
||||||
);
|
);
|
||||||
|
|
||||||
var files = JSON.parse(el.attr('data-files'));
|
var files = JSON.parse(el.attr('data-files'));
|
||||||
var content = [];
|
var content = '';
|
||||||
for (i = 0; i < files.length; i++) {
|
for (i = 0; i < files.length; i++) {
|
||||||
var f = files[i];
|
var f = files[i];
|
||||||
var expires = i18n.expiration.replace('XXX',
|
var expires = i18n.expiration.replace('XXX',
|
||||||
moment.unix(f.delay * 86400 + f.created_at).locale(window.navigator.language).format('LLLL')
|
moment.unix(f.delay * 86400 + f.created_at).locale(window.navigator.language).format('LLLL')
|
||||||
);
|
);
|
||||||
content.push(
|
content += `<li>— <a href="${f.url}">${f.name}</a>
|
||||||
'<li>— ',
|
(${filesize(f.size)}, ${expires})
|
||||||
'<a href="', f.url, '">',
|
</li>`;
|
||||||
f.name,
|
|
||||||
'</a> (',
|
|
||||||
filesize(f.size),
|
|
||||||
', ',
|
|
||||||
expires,
|
|
||||||
')',
|
|
||||||
'</li>',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$('#files-ul').html(content.join(''));
|
$('#files-ul').html(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function notify(title, body) {
|
function notify(title, body) {
|
||||||
if (!'Notification' in window || typeof(Notification) === 'undefined') {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,14 @@ function copyAllToClipboard(event) {
|
||||||
|
|
||||||
// Add item to localStorage
|
// Add item to localStorage
|
||||||
function addItem(name, url, size, del_at_first_view, created_at, delay, short, token) {
|
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) {
|
if (files === null) {
|
||||||
files = new Array();
|
files = new Array();
|
||||||
} else {
|
} else {
|
||||||
files = JSON.parse(files);
|
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 });
|
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
|
// Remove a file block
|
||||||
|
@ -192,7 +192,7 @@ function updateMailLink() {
|
||||||
for (i = 0; i < a.length; i++) {
|
for (i = 0; i < a.length; i++) {
|
||||||
l.push(a[i].id);
|
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);
|
$('#mailto').attr('href', u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,18 +240,16 @@ function handleFiles(f) {
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
while (typeof(window.zip.files[filename]) !== 'undefined') {
|
while (typeof(window.zip.files[filename]) !== 'undefined') {
|
||||||
counter += 1;
|
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.zip.file(filename, element);
|
||||||
|
|
||||||
window.zipSize += element.size;
|
window.zipSize += element.size;
|
||||||
$('#zip-size').text(filesize(window.zipSize));
|
$('#zip-size').text(filesize(window.zipSize));
|
||||||
$('#zip-parts').append([
|
$('#zip-parts').append(`<li>
|
||||||
'<li>',
|
— ${escapeHtml(filename)} (${filesize(element.size)})
|
||||||
'— ', escapeHtml(filename), ' (', filesize(element.size), ')',
|
</li>`);
|
||||||
'</li>'
|
|
||||||
].join(''));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (window.fileList === undefined || window.fileList === null) {
|
if (window.fileList === undefined || window.fileList === null) {
|
||||||
|
@ -295,23 +293,32 @@ function uploadFile(i, delay, del_at_first_view) {
|
||||||
var r = $('#ul-results');
|
var r = $('#ul-results');
|
||||||
var w = $('<li>');
|
var w = $('<li>');
|
||||||
w.addClass('list-group-item');
|
w.addClass('list-group-item');
|
||||||
w.html(['<div class="card">',
|
w.html(`<div class="card">
|
||||||
'<div>',
|
<div>
|
||||||
'<a href="#" id="destroy-', window.fc, '">',
|
<a href="#" id="destroy-${window.fc}">
|
||||||
'<i class="right mdi-navigation-close small"></i>',
|
<i class="right mdi-navigation-close small"></i>
|
||||||
'</a>',
|
</a>
|
||||||
'<div class="card-content">',
|
<div class="card-content">
|
||||||
'<span class="card-title" id="name-', window.fc, '">', name, '</span> <span id="size-', window.fc ,'">(', size,')</span>',
|
<span class="card-title"
|
||||||
'<p id="parts-', window.fc, '"></p>',
|
id="name-${window.fc}">${name}</span>
|
||||||
'</div>',
|
<span id="size-${window.fc }">(${size})</span>
|
||||||
'<div class="progress">',
|
<p id="parts-${window.fc}"></p>
|
||||||
'<div id="progress-', window.fc, '" data-key="', randomkey, '" data-name="', name, '" aria-valuemax="100" aria-valuemin="0" aria-valuenow="0" role="progressbar" class="determinate width-0">',
|
</div>
|
||||||
'<span class="sr-only">', name, '0%</span>',
|
<div class="progress">
|
||||||
'</div>',
|
<div id="progress-${window.fc}"
|
||||||
'</div>',
|
data-key="${randomkey}"
|
||||||
'<div>'].join(''));
|
data-name="${name}"
|
||||||
|
aria-valuemax="100"
|
||||||
|
aria-valuemin="0"
|
||||||
|
aria-valuenow="0"
|
||||||
|
role="progressbar"
|
||||||
|
class="determinate width-0">
|
||||||
|
<span class="sr-only">${name}0%</span>
|
||||||
|
</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);
|
||||||
|
@ -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 slice = file.slice(j * window.sliceLength, (j + 1) * window.sliceLength, file.type);
|
||||||
var fr = new FileReader();
|
var fr = new FileReader();
|
||||||
fr.onloadend = function() {
|
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)
|
// Get the binary result, different result in IE browsers (see default.html.ep line 27:48)
|
||||||
if (isIE == true){
|
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['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;
|
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) {
|
||||||
|
@ -403,14 +410,14 @@ function sliceAndUpload(randomkey, i, parts, j, delay, del_at_first_view, short,
|
||||||
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);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -427,7 +434,7 @@ function updateProgressBar(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
console.log('Upload successfully cancelled');
|
console.log('Upload successfully cancelled');
|
||||||
} else {
|
} else {
|
||||||
console.log('Upload cancellation failed: ' + data.msg);
|
console.log(`Upload cancellation failed: ${data.msg}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the cancelled index
|
// Remove the cancelled index
|
||||||
|
@ -463,9 +470,9 @@ function updateProgressBar(data) {
|
||||||
var short = data.short;
|
var short = data.short;
|
||||||
var created_at = data.created_at;
|
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');
|
var key = dp.attr('data-key');
|
||||||
|
|
||||||
if (j + 1 === parts) {
|
if (j + 1 === parts) {
|
||||||
|
@ -474,44 +481,44 @@ function updateProgressBar(data) {
|
||||||
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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
notify(i18n.fileUploaded, data.name);
|
notify(i18n.fileUploaded, data.name);
|
||||||
|
|
||||||
$('#parts-'+window.fc).remove();
|
$(`#parts-${window.fc}`).remove();
|
||||||
var n = $('#name-'+window.fc);
|
var n = $(`#name-${window.fc}`);
|
||||||
var s = $('#size-'+window.fc);
|
var s = $(`#size-${window.fc}`);
|
||||||
var d = $('<div>');
|
var d = $('<div>');
|
||||||
var url = baseURL+'r/'+short+'#'+key;
|
var url = `${baseURL}r/${short}#${key}`;
|
||||||
var del_url = actionURL+'d/'+short+'/'+data.token;
|
var del_url = `${actionURL}d/${short}/${data.token}`;
|
||||||
var links = encodeURIComponent('["'+short+'"]');
|
var links = encodeURIComponent(`["${short}"]`);
|
||||||
var limit = (delay === 0) ? i18n.noLimit : i18n.expiration+' '+moment.unix(delay * 86400 + created_at).locale(window.navigator.language).format('LLLL');
|
var limit = (delay === 0) ? i18n.noLimit : i18n.expiration+' '+moment.unix(delay * 86400 + created_at).locale(window.navigator.language).format('LLLL');
|
||||||
if (!isGuest) {
|
if (!isGuest) {
|
||||||
n.html(n.html()+' '+s.html()+' <a href="'+actionURL+'m?links='+links+'"><i class="mdi-communication-email"></i></a><br>'+limit);
|
n.html(`${n.html()} ${s.html()} <a href="${actionURL}m?links=${links}"><i class="mdi-communication-email"></i></a><br>${limit}`);
|
||||||
d.html(['<div class="card-action">',
|
d.html(`<div class="card-action">
|
||||||
'<div class="input-field">',
|
<div class="input-field">
|
||||||
'<span class="prefix big-prefix">',
|
<span class="prefix big-prefix">
|
||||||
'<a href="', url, '" target="_blank">',
|
<a href="${url}" target="_blank">
|
||||||
'<i class="mdi-file-file-download small" title="', i18n.dlText, '"></i>',
|
<i class="mdi-file-file-download small" title="${i18n.dlText}"></i>
|
||||||
'</a>',
|
</a>
|
||||||
'<a href="#" id="copyurl-', window.fc, '" title="', i18n.cpText, '">',
|
<a href="#" id="copyurl-${window.fc}" title="${i18n.cpText}">
|
||||||
'<i class="mdi-content-content-copy small"></i>',
|
<i class="mdi-content-content-copy small"></i>
|
||||||
'</a>',
|
</a>
|
||||||
'</span>',
|
</span>
|
||||||
'<input id="', short, '" class="form-control link-input white-background" value="', url, '" readonly="" type="text">',
|
<input id="${short}" class="form-control link-input white-background" value="${url}" readonly="" type="text">
|
||||||
'<label class="active" for="', short, '">', i18n.dlText, '</label>',
|
<label class="active" for="${short}">${i18n.dlText}</label>
|
||||||
'</div>',
|
</div>
|
||||||
'<div class="input-field">',
|
<div class="input-field">
|
||||||
'<a href="', del_url, '" target="_blank" class="prefix big-prefix">',
|
<a href="${del_url}" target="_blank" class="prefix big-prefix">
|
||||||
'<i class="mdi-action-delete small" title="', i18n.delText, '"></i>',
|
<i class="mdi-action-delete small" title="${i18n.delText}"></i>
|
||||||
'</a>',
|
</a>
|
||||||
'<input id="delete-', short, '" class="form-control white-background" value="', del_url, '" readonly="" type="text">',
|
<input id="delete-${short}" class="form-control white-background" value="${del_url}" readonly="" type="text">
|
||||||
'<label class="active" for="delete-', short, '">', i18n.delText, '</label>',
|
<label class="active" for="delete-${short}">${i18n.delText}</label>
|
||||||
'</div>',
|
</div>
|
||||||
'</div>'].join(''));
|
</div>`);
|
||||||
} else {
|
} else {
|
||||||
n.html(n.html()+' '+s.html());
|
n.html(`${n.html()} ${s.html()}`);
|
||||||
}
|
}
|
||||||
s.remove();
|
s.remove();
|
||||||
|
|
||||||
|
@ -521,7 +528,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);
|
||||||
});
|
});
|
||||||
|
@ -531,7 +538,12 @@ function updateProgressBar(data) {
|
||||||
// Add copy all and mailto buttons
|
// Add copy all and mailto buttons
|
||||||
var misc = $('#misc');
|
var misc = $('#misc');
|
||||||
if (misc.html() === '' && !isGuest) {
|
if (misc.html() === '' && !isGuest) {
|
||||||
misc.html('<a href="#" id="copyall" class="btn btn-info">'+i18n.copyAll+'</a> <a id="mailto" href="'+actionURL+'m?links='+links+'" class="btn btn-info">'+i18n.mailTo+'</a>');
|
misc.html(`<a href="#"
|
||||||
|
id="copyall"
|
||||||
|
class="btn btn-info">${i18n.copyAll}</a>
|
||||||
|
<a id="mailto"
|
||||||
|
href="${actionURL}m?links=${links}"
|
||||||
|
class="btn btn-info">${i18n.mailTo}</a>`);
|
||||||
$('#copyall').on('click', copyAllToClipboard);
|
$('#copyall').on('click', copyAllToClipboard);
|
||||||
} else {
|
} else {
|
||||||
updateMailLink();
|
updateMailLink();
|
||||||
|
@ -574,7 +586,7 @@ function updateProgressBar(data) {
|
||||||
var wClass = percent.toString().replace('.', '-');
|
var wClass = percent.toString().replace('.', '-');
|
||||||
dp.removeClass();
|
dp.removeClass();
|
||||||
dp.addClass('determinate');
|
dp.addClass('determinate');
|
||||||
dp.addClass('width-'+wClass);
|
dp.addClass(`width-${wClass}`);
|
||||||
dp.attr('aria-valuenow', percent);
|
dp.attr('aria-valuenow', percent);
|
||||||
|
|
||||||
// Encrypt and upload next slice
|
// Encrypt and upload next slice
|
||||||
|
@ -593,15 +605,15 @@ function updateProgressBar(data) {
|
||||||
|
|
||||||
// Write message instead in a file block
|
// Write message instead in a file block
|
||||||
function addAlertOnFile(msg, i, sent_delay, del_at_first_view) {
|
function addAlertOnFile(msg, i, sent_delay, del_at_first_view) {
|
||||||
var n = $('#name-'+window.fc);
|
var n = $(`#name-${window.fc}`);
|
||||||
var p = $('#progress-'+window.fc);
|
var p = $(`#progress-${window.fc}`);
|
||||||
var d = $('<div>');
|
var d = $('<div>');
|
||||||
|
|
||||||
p.parent().remove();
|
p.parent().remove();
|
||||||
d.addClass('card pink');
|
d.addClass('card pink');
|
||||||
d.html(['<div class="card-content white-text">',
|
d.html(`<div class="card-content white-text">
|
||||||
'<strong>', msg, '</strong>',
|
<strong>${msg}</strong>
|
||||||
'</div>'].join(''));
|
</div>`);
|
||||||
n.parent().append(d);
|
n.parent().append(d);
|
||||||
|
|
||||||
// Upload next file
|
// Upload next file
|
||||||
|
@ -653,7 +665,7 @@ function spawnWebsocket(i, callback) {
|
||||||
ws.onerror = function() {
|
ws.onerror = function() {
|
||||||
console.log('error');
|
console.log('error');
|
||||||
if (i < 5 && callback !== undefined) {
|
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);
|
window.ws = spawnWebsocket(i + 1, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
% # vim:set sts=4 sw=4 ts=4 ft=javascript expandtab:
|
% # vim:set sts=4 sw=4 ts=4 ft=javascript expandtab:
|
||||||
function findItem(name) {
|
function findItem(name) {
|
||||||
var files = localStorage.getItem(window.prefix + 'files');
|
var files = localStorage.getItem(`${window.prefix}files`);
|
||||||
if (files === null) {
|
if (files === null) {
|
||||||
files = new Array();
|
files = new Array();
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,7 @@ function updateMailtoLink() {
|
||||||
var subject = document.getElementById('subject');
|
var subject = document.getElementById('subject');
|
||||||
var text = document.getElementById('body');
|
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() {
|
function populateBody() {
|
||||||
var links = [
|
var links = [
|
||||||
|
@ -37,16 +37,16 @@ function populateBody() {
|
||||||
var item = findItem(name);
|
var item = findItem(name);
|
||||||
if (item !== null && item !== undefined) {
|
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');
|
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) {
|
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'))) {
|
% 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;
|
tArea = document.getElementById('body').value = text;
|
||||||
updateMailtoLink();
|
updateMailtoLink();
|
||||||
|
|
Loading…
Reference in New Issue