Fixed web editor
Ylian Saint-Hilaire committed
Oct 12, 2020 at 17:00 UTC
083fd92e446ed1560397f187531004701cdcefaf
1 file changed
+23
-23
views/default.handlebars
+23
-23
@@ -6737,7 +6737,7 @@
6737
// ###BEGIN###{DesktopInbandFiles}
6738
/*
6739
QV('go24', true); // Files
6740
- downloadFile = null;
6740
+ gdownloadFile = null;
6741
p24files = webRtcDesktop.softdesktop;
6742
p24targetpath = '';
6743
webRtcDesktop.softdesktop.onControlMsg = onFilesControlData;
@@ -7977,7 +7977,7 @@
7977
// Server link
7978
//link = '<a href="devicefile.ashx?c=' + authCookie + '&m=' + currentNode.meshid.split('/')[2] + '&n=' + currentNode._id.split('/')[2] + '&f=' + encodeURIComponentEx(newlinkpath + '/' + name) + '" download="' + name + '" style=cursor:pointer>' + shortname + '</a>';
7979
// Server link
7980
- link = '<a onclick=downloadFile("devicefile.ashx?c=' + authCookie + '&m=' + currentNode.meshid.split('/')[2] + '&n=' + currentNode._id.split('/')[2] + '&f=' + encodeURIComponentEx(newlinkpath + '/' + name) + '","' + name + '") style=cursor:pointer>' + shortname + '</a>';
7980
+ link = '<a onclick=downloadFile("devicefile.ashx?c=' + authCookie + '&m=' + currentNode.meshid.split('/')[2] + '&n=' + currentNode._id.split('/')[2] + '&f=' + encodeURIComponentEx(newlinkpath + '/' + name) + '","' + encodeURIComponentEx(name) + '") style=cursor:pointer>' + shortname + '</a>';
7981
}
7982
h = '<div id=fileEntry cmenu=filesContextMenu fileIndex=' + i + ' class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value=\'' + f.nx + '\'> <span class=fsize>' + fdatestr + '</span><span style=float:right>' + EscapeHtml(fsize) + '</span><span><div class=fileIcon' + f.t + '></div>' + link + '</span></div>';
7983
}
@@ -8170,51 +8170,51 @@
8170
// FILES DOWNLOAD
8171
//
8172
8173
- var downloadFile; // Global state for file download
8173
+ var gdownloadFile; // Global state for file download
8174
8175
// Called by the html page to start a download, arguments are: path, file name and file size.
8176
function p13downloadfile(x, y, z, tag) {
8177
- if (xxdialogMode || downloadFile || !files) return;
8178
- downloadFile = { path: decodeURIComponent(x), file: decodeURIComponent(y), size: z, tsize: 0, data: '', state: 0, id: Math.random(), tag: tag }
8179
- //console.log('p13downloadFileCancel', downloadFile);
8180
- files.sendText({ action: 'download', sub: 'start', id: downloadFile.id, path: downloadFile.path });
8181
- setDialogMode(2, "Download File", 10, p13downloadFileCancel, '<div>' + downloadFile.file + '</div><br /><progress id=d2progressBar style=width:100% value=0 max=' + z + ' />');
8177
+ if (xxdialogMode || !files) return;
8178
+ gdownloadFile = { path: decodeURIComponent(x), file: decodeURIComponent(y), size: z, tsize: 0, data: '', state: 0, id: Math.random(), tag: tag }
8179
+ //console.log('p13downloadFileCancel', gdownloadFile);
8180
+ files.sendText({ action: 'download', sub: 'start', id: gdownloadFile.id, path: gdownloadFile.path });
8181
+ setDialogMode(2, "Download File", 10, p13downloadFileCancel, '<div>' + gdownloadFile.file + '</div><br /><progress id=d2progressBar style=width:100% value=0 max=' + z + ' />');
8182
}
8183
8184
// Called by the html page to cancel the download
8185
- function p13downloadFileCancel() { setDialogMode(0); files.sendText({ action: 'download', sub: 'cancel', id: downloadFile.id }); downloadFile = null; }
8185
+ function p13downloadFileCancel() { setDialogMode(0); files.sendText({ action: 'download', sub: 'cancel', id: gdownloadFile.id }); gdownloadFile = null; }
8186
8187
// Called by the transport when download control command is received
8188
function p13gotDownloadCommand(cmd) {
8189
//console.log('p13gotDownloadCommand', cmd);
8190
- if ((downloadFile == null) || (cmd.id != downloadFile.id)) return;
8191
- if (cmd.sub == 'start') { downloadFile.state = 1; files.sendText({ action: 'download', sub: 'startack', id: downloadFile.id }); }
8192
- else if (cmd.sub == 'cancel') { downloadFile = null; setDialogMode(0); }
8190
+ if ((gdownloadFile == null) || (cmd.id != gdownloadFile.id)) return;
8191
+ if (cmd.sub == 'start') { gdownloadFile.state = 1; files.sendText({ action: 'download', sub: 'startack', id: gdownloadFile.id }); }
8192
+ else if (cmd.sub == 'cancel') { gdownloadFile = null; setDialogMode(0); }
8193
}
8194
8195
// Called by the transport when binary data is received
8196
function p13gotDownloadBinaryData(data) {
8197
- if (!downloadFile || downloadFile.state == 0) return;
8197
+ if (!gdownloadFile || gdownloadFile.state == 0) return;
8198
if (data.length > 4) {
8199
- downloadFile.tsize += (data.length - 4); // Add to the total bytes received
8200
- downloadFile.data += data.substring(4); // Append the data
8201
- Q('d2progressBar').value = downloadFile.tsize; // Change the progress bar
8199
+ gdownloadFile.tsize += (data.length - 4); // Add to the total bytes received
8200
+ gdownloadFile.data += data.substring(4); // Append the data
8201
+ Q('d2progressBar').value = gdownloadFile.tsize; // Change the progress bar
8202
}
8203
if ((ReadInt(data, 0) & 1) != 0) { // Check end flag
8204
- if (downloadFile.tag == 'viewer') {
8204
+ if (gdownloadFile.tag == 'viewer') {
8205
// View the file in the dialog box
8206
- setDialogMode(4, EscapeHtml(downloadFile.file), 3, p13editSaveBack, null, downloadFile.file);
8206
+ setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
8207
QS('dialog').width = 'auto';
8208
QS('dialog').bottom = '80px';
8209
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
8210
- Q('d4editorarea').value = downloadFile.data;
8211
- downloadFile = null;
8210
+ Q('d4editorarea').value = gdownloadFile.data;
8211
+ gdownloadFile = null;
8212
} else {
8213
// Save the file to disk
8214
- saveAs(data2blob(downloadFile.data), downloadFile.file); downloadFile = null; setDialogMode(0); // Save the file
8214
+ saveAs(data2blob(gdownloadFile.data), gdownloadFile.file); gdownloadFile = null; setDialogMode(0); // Save the file
8215
}
8216
} else {
8217
- files.sendText({ action: 'download', sub: 'ack', id: downloadFile.id }); // Send the ACK
8217
+ files.sendText({ action: 'download', sub: 'ack', id: gdownloadFile.id }); // Send the ACK
8218
}
8219
}
8220
@@ -13667,7 +13667,7 @@
13667
var element = document.createElement('a');
13668
element.setAttribute('href', link);
13669
element.setAttribute('rel', 'noreferrer noopener');
13670
- if (navigator.userAgent.indexOf('Firefox') >= 0) { element.setAttribute('download', name?name:''); } else { element.setAttribute('target', 'fileDownloadFrame'); }
13670
+ if (navigator.userAgent.indexOf('Firefox') >= 0) { element.setAttribute('download', decodeURIComponent(name?name:'')); } else { element.setAttribute('target', 'fileDownloadFrame'); }
13671
document.body.appendChild(element);
13672
element.click();
13673
document.body.removeChild(element);