`);
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();