From e1804bce972846064e7a8fced83824a65b5968b7 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 18 Jan 2021 01:09:33 -0800 Subject: [PATCH] Made changes needed to support Android agent. --- translate/translate.json | 8 ++++-- views/default-mobile.handlebars | 17 ++++++------ views/default.handlebars | 49 +++++++++++++++++---------------- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/translate/translate.json b/translate/translate.json index 70fdd283..a127e195 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -5058,7 +5058,7 @@ "ru": "Android", "tr": "Android", "zh-chs": "Android", - "zh-cht": "Android" + "zh-cht": "Android", "xloc": [ "default-mobile.handlebars->11->20", "default.handlebars->31->22", @@ -11727,9 +11727,11 @@ "default.handlebars->31->611" ] }, + { + "en": "Desktop, Alleen kijken" + }, { "en": "Desktop, View only", - "en": "Desktop, Alleen kijken", "xloc": [ "default.handlebars->31->750" ] @@ -46195,4 +46197,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 6fa34098..8ca0e634 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -3848,7 +3848,7 @@ function p13gotFiles(data) { if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } // This is ok because 4 first bytes is a control value. //console.log('p13gotFiles', data); - data = JSON.parse(decode_utf8(data)); + try { data = JSON.parse(decode_utf8(data)); } catch (ex) { data = JSON.parse(data); } if (data.action == 'download') { p13gotDownloadCommand(data); return; } // Process file upload commands @@ -3960,6 +3960,7 @@ } function p13setActions() { + var advancedFeatures = (currentNode.agent.id != 14); // Reduct file feature on some devices. if (p13filetree == null) { QE('p13DeleteFileButton', false); QE('p13NewFolderButton', false); @@ -3974,16 +3975,16 @@ } else { var cc = p13getFileSelCount(), tc = p13getFileCount(), sfc = p13getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders) var winAgent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5)); - QE('p13DeleteFileButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13NewFolderButton', ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13UploadButton', ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13RenameFileButton', (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13DeleteFileButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13NewFolderButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13UploadButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13RenameFileButton', advancedFeatures && (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); QE('p13SelectAllButton', tc > 0); Q('p13SelectAllButton').value = (cc > 0 ? "None" : "All"); QE('p13RefreshButton', true); - QE('p13CutButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13CopyButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13PasteButton', ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0))); + QE('p13CutButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13CopyButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0))); } } diff --git a/views/default.handlebars b/views/default.handlebars index 971acb55..ba3bcb50 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4357,9 +4357,7 @@ if (xxdialogMode) return false; var mesh = meshes[meshid], x = '', installType = 0, moreoptions = ''; - var opts = ''; + var opts = ''; x += addHtmlValue("Operating System", opts); var servername = serverinfo.name; @@ -4424,13 +4422,11 @@ setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload'); // Create the QR code - if (debugmode > 0) { - var servername = serverinfo.name; - if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name. - var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1); - var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port); - new QRCode(Q('agins_qrimage'), { text: 'mc://' + servername + portStr + domainUrlNoSlash + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M }); - } + var servername = serverinfo.name; + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name. + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1); + var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port); + new QRCode(Q('agins_qrimage'), { text: 'mc://' + servername + portStr + domainUrlNoSlash + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M }); if (serverinfo.https == true) { @@ -8308,7 +8304,7 @@ function p13gotFiles(data) { if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } // This is ok because 4 first bytes is a control value. //console.log('p13gotFiles', data); - data = JSON.parse(decode_utf8(data)); + try { data = JSON.parse(decode_utf8(data)); } catch (ex) { data = JSON.parse(data); } if (data.action == 'download') { p13gotDownloadCommand(data); return; } // Find file result @@ -8397,7 +8393,11 @@ // Figure out the date var fdatestr = ''; - if (f.d != null) { var fdate = new Date(f.d), fdatestr = printDateTime(fdate) + ' '; } + if (f.d != null) { + var fdate = new Date(f.d); + if (typeof f.d == 'number') { fdate = new Date(f.d * 1000); } + var fdatestr = printDateTime(fdate) + ' '; + } // Figure out the size var fsize = ''; @@ -8492,6 +8492,7 @@ } function p13setActions() { + var advancedFeatures = (currentNode.agent.id != 14); // Reduct file feature on some devices. if (p13filetree == null) { QE('p13DeleteFileButton', false); QE('p13NewFolderButton', false); @@ -8509,19 +8510,19 @@ } else { var cc = p13getFileSelCount(), tc = p13getFileCount(), sfc = p13getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders) var winAgent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5)); - QE('p13DeleteFileButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13NewFolderButton', ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13UploadButton', ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13RenameFileButton', (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13ViewFileButton', (cc == 1) && (sfc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13DeleteFileButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13NewFolderButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13UploadButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13RenameFileButton', advancedFeatures && (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13ViewFileButton', advancedFeatures && (cc == 1) && (sfc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false))); QE('p13SelectAllButton', tc > 0); Q('p13SelectAllButton').value = (cc > 0 ? "Select None" : "Select All"); QE('p13RefreshButton', true); - QE('p13FindButton', ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13CutButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13CopyButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13ZipButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); - QE('p13PasteButton', ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0))); + QE('p13FindButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13CutButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13CopyButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13ZipButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false))); + QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0))); } } @@ -8605,7 +8606,7 @@ haltEvent(e); QV('p13bigfail', false); QV('p13bigok', false); - if (e.dataTransfer == null || e.dataTransfer.files.length == 0 || p13filetree == null) return; + if ((e.dataTransfer == null) || (e.dataTransfer.files.length == 0) || (p13filetree == null) || (currentNode.agent.id == 14)) return; // Check if these are files we can upload, remove all folders. var files = []; @@ -8619,7 +8620,7 @@ function p13fileDragOver(e) { haltEvent(e); if (p13dragtimer != null) { clearTimeout(p13dragtimer); p13dragtimer = null; } - var ac = (p13filetree != null); // Set to true if we can accept the file + var ac = (p13filetree != null) && (currentNode.agent.id != 14); // Set to true if we can accept the file QV('p13bigok', ac); QV('p13bigfail', !ac); }