mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 04:33:16 +03:00
add new line break feature to file edit #6365
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
516a14b4ca
commit
6fe30b7730
File diff suppressed because it is too large
Load Diff
@ -1368,6 +1368,7 @@
|
|||||||
<input id="d4WrapButton" type="button" value="Wrap On" onclick="d4ToggleWrap()" />
|
<input id="d4WrapButton" type="button" value="Wrap On" onclick="d4ToggleWrap()" />
|
||||||
<input id="d4SizeButton" type="button" value="Small" onclick="d4ToggleSize()" />
|
<input id="d4SizeButton" type="button" value="Small" onclick="d4ToggleSize()" />
|
||||||
<input id="d4EncodingButton" type="button" value="Raw" onclick="d4ToggleEncoding()" />
|
<input id="d4EncodingButton" type="button" value="Raw" onclick="d4ToggleEncoding()" />
|
||||||
|
<input id="d4LineBreakButton" type="button" value="Windows" onclick="d4ToggleLineBreak()" />
|
||||||
<textarea id=d4editorarea autocomplete="off" style="height:calc(100vh - 286px);width:100%;overflow:scroll;resize:none;white-space:pre"></textarea>
|
<textarea id=d4editorarea autocomplete="off" style="height:calc(100vh - 286px);width:100%;overflow:scroll;resize:none;white-space:pre"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id=dialog7 style="">
|
<div id=dialog7 style="">
|
||||||
@ -1778,12 +1779,14 @@
|
|||||||
QV('p4UserBatchCreate', (features & 0x00080000) == 0);
|
QV('p4UserBatchCreate', (features & 0x00080000) == 0);
|
||||||
|
|
||||||
// Set the file editor
|
// Set the file editor
|
||||||
d4EditWrapVal = getstore('editorWrap', 0);
|
d4EditWrapVal = Number(getstore('editorWrap', 0));
|
||||||
d4EditSizeVal = getstore('editorSize', 0);
|
d4EditSizeVal = Number(getstore('editorSize', 0));
|
||||||
d4EditEncodingVal = getstore('editorEncoding', 0);
|
d4EditEncodingVal = Number(getstore('editorEncoding', 0));
|
||||||
|
d4EditLineBreakVal = Number(getstore('editorLineBreak', 0));
|
||||||
d4ToggleWrap(true);
|
d4ToggleWrap(true);
|
||||||
d4ToggleSize(true);
|
d4ToggleSize(true);
|
||||||
d4ToggleEncoding(true);
|
d4ToggleEncoding(true);
|
||||||
|
d4ToggleLineBreak(true);
|
||||||
if (pluginHandler != null) pluginHandler.callHook('onWebUIStartupEnd');
|
if (pluginHandler != null) pluginHandler.callHook('onWebUIStartupEnd');
|
||||||
|
|
||||||
// Deleted non-english style and fix all topbar titles
|
// Deleted non-english style and fix all topbar titles
|
||||||
@ -2894,6 +2897,7 @@
|
|||||||
} else {
|
} else {
|
||||||
setDialogMode(4, "Server Configuration", 2);
|
setDialogMode(4, "Server Configuration", 2);
|
||||||
QV('d4EncodingButton', false);
|
QV('d4EncodingButton', false);
|
||||||
|
QV('d4LineBreakButton', false);
|
||||||
QS('dialog').width = 'auto';
|
QS('dialog').width = 'auto';
|
||||||
QS('dialog').bottom = '80px';
|
QS('dialog').bottom = '80px';
|
||||||
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
||||||
@ -3127,15 +3131,20 @@
|
|||||||
// View the file in the dialog box
|
// View the file in the dialog box
|
||||||
var p5editSaveBack = function(b, tag) {
|
var p5editSaveBack = function(b, tag) {
|
||||||
var data;
|
var data;
|
||||||
|
var value = Q('d4editorarea').value;
|
||||||
|
value = d4EditLineBreakVal === 0 ? value.replace(/\r?\n|\r/g, '\r\n') : // Windows
|
||||||
|
d4EditLineBreakVal === 2 ? value.replace(/\r\n|\n/g, '\r') : // Mac
|
||||||
|
value.replace(/\r\n|\r/g, '\n'); // Linux
|
||||||
if (d4EditEncodingVal == 1) {
|
if (d4EditEncodingVal == 1) {
|
||||||
data = encode_utf8(Q('d4editorarea').value); // UTF8 encoding
|
data = encode_utf8(value); // UTF8 encoding
|
||||||
} else {
|
} else {
|
||||||
data = Q('d4editorarea').value; // RAW encoding
|
data = value; // RAW encoding
|
||||||
}
|
}
|
||||||
meshserver.send({ action: 'fileoperation', fileop: 'set', path: tag.path, file: tag.file, data: btoa(data) });
|
meshserver.send({ action: 'fileoperation', fileop: 'set', path: tag.path, file: tag.file, data: btoa(data) });
|
||||||
}
|
}
|
||||||
setDialogMode(4, EscapeHtml(message.file), 3, p5editSaveBack, null, message);
|
setDialogMode(4, EscapeHtml(message.file), 3, p5editSaveBack, null, message);
|
||||||
QV('d4EncodingButton', true);
|
QV('d4EncodingButton', true);
|
||||||
|
QV('d4LineBreakButton', true);
|
||||||
QS('dialog').width = 'auto';
|
QS('dialog').width = 'auto';
|
||||||
QS('dialog').bottom = '80px';
|
QS('dialog').bottom = '80px';
|
||||||
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
||||||
@ -11562,6 +11571,7 @@
|
|||||||
// View the file in the dialog box
|
// View the file in the dialog box
|
||||||
setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
|
setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
|
||||||
QV('d4EncodingButton', true);
|
QV('d4EncodingButton', true);
|
||||||
|
QV('d4LineBreakButton', true);
|
||||||
QS('dialog').width = 'auto';
|
QS('dialog').width = 'auto';
|
||||||
QS('dialog').bottom = '80px';
|
QS('dialog').bottom = '80px';
|
||||||
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
||||||
@ -11597,6 +11607,7 @@
|
|||||||
var d4EditWrapVal = 0;
|
var d4EditWrapVal = 0;
|
||||||
var d4EditSizeVal = 0;
|
var d4EditSizeVal = 0;
|
||||||
var d4EditEncodingVal = 0;
|
var d4EditEncodingVal = 0;
|
||||||
|
var d4EditLineBreakVal = 0;
|
||||||
function d4ToggleWrap(update) {
|
function d4ToggleWrap(update) {
|
||||||
if (!update) { d4EditWrapVal = ++d4EditWrapVal % 2; }
|
if (!update) { d4EditWrapVal = ++d4EditWrapVal % 2; }
|
||||||
Q('d4WrapButton').value = ["Wrap: ON","Wrap: OFF"][d4EditWrapVal];
|
Q('d4WrapButton').value = ["Wrap: ON","Wrap: OFF"][d4EditWrapVal];
|
||||||
@ -11625,12 +11636,24 @@
|
|||||||
putstore('editorEncoding', d4EditEncodingVal);
|
putstore('editorEncoding', d4EditEncodingVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function d4ToggleLineBreak(update) {
|
||||||
|
if (!update) {
|
||||||
|
d4EditLineBreakVal = ++d4EditLineBreakVal % 3;
|
||||||
|
}
|
||||||
|
Q('d4LineBreakButton').value = ["Line Break: Windows (CR LF)","Line Break: Linux (LF)","Line Break: Mac (CR)"][d4EditLineBreakVal];
|
||||||
|
putstore('editorLineBreak', d4EditLineBreakVal);
|
||||||
|
}
|
||||||
|
|
||||||
function p13editSaveBack(b, tag) {
|
function p13editSaveBack(b, tag) {
|
||||||
var data;
|
var data;
|
||||||
|
var value = Q('d4editorarea').value;
|
||||||
|
value = d4EditLineBreakVal === 0 ? value.replace(/\r?\n|\r/g, '\r\n') : // Windows
|
||||||
|
d4EditLineBreakVal === 2 ? value.replace(/\r\n|\n/g, '\r') : // Mac
|
||||||
|
value.replace(/\r\n|\r/g, '\n'); // Linux
|
||||||
if (d4EditEncodingVal == 1) {
|
if (d4EditEncodingVal == 1) {
|
||||||
data = new TextEncoder().encode(Q('d4editorarea').value); // UTF8 encoding
|
data = new TextEncoder().encode(value); // UTF8 encoding
|
||||||
} else {
|
} else {
|
||||||
data = new TextEncoder().encode(decode_utf8(Q('d4editorarea').value)); // RAW encoding
|
data = new TextEncoder().encode(decode_utf8(value)); // RAW encoding
|
||||||
}
|
}
|
||||||
p13uploadFileContinue(1, [{ name: tag, size: data.byteLength, type: 'text/plain', xdata: data }]);
|
p13uploadFileContinue(1, [{ name: tag, size: data.byteLength, type: 'text/plain', xdata: data }]);
|
||||||
}
|
}
|
||||||
@ -19116,6 +19139,7 @@
|
|||||||
function round(value, precision) { var multiplier = Math.pow(10, precision || 0); return Math.round(value * multiplier) / multiplier; }
|
function round(value, precision) { var multiplier = Math.pow(10, precision || 0); return Math.round(value * multiplier) / multiplier; }
|
||||||
function safeNewWindow(url, target) { var newWindow = window.open(url, target, 'noopener,noreferrer'); if (newWindow) { newWindow.opener = null; } }
|
function safeNewWindow(url, target) { var newWindow = window.open(url, target, 'noopener,noreferrer'); if (newWindow) { newWindow.opener = null; } }
|
||||||
function isWindowsNode(node) { if ((node.mtype != 2) || (node.agent == null) || (node.agent.id == null)) return false; return ([1,2,3,4,21,22,34,42,43].indexOf(node.agent.id) >= 0); }
|
function isWindowsNode(node) { if ((node.mtype != 2) || (node.agent == null) || (node.agent.id == null)) return false; return ([1,2,3,4,21,22,34,42,43].indexOf(node.agent.id) >= 0); }
|
||||||
|
function isMacNode(node) { if ((node.mtype != 2) || (node.agent == null) || (node.agent.id == null)) return false; return ([11,16,29].indexOf(node.agent.id) >= 0); }
|
||||||
|
|
||||||
function downloadFile(link, name, closeDialog) {
|
function downloadFile(link, name, closeDialog) {
|
||||||
var element = document.createElement('a');
|
var element = document.createElement('a');
|
||||||
|
@ -217,6 +217,13 @@
|
|||||||
<div id=dialog2 style="">
|
<div id=dialog2 style="">
|
||||||
<div id=id_dialogOptions></div>
|
<div id=id_dialogOptions></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id=dialog4 style="">
|
||||||
|
<input id="d4WrapButton" type="button" value="Wrap On" onclick="d4ToggleWrap()" />
|
||||||
|
<input id="d4SizeButton" type="button" value="Small" onclick="d4ToggleSize()" />
|
||||||
|
<input id="d4EncodingButton" type="button" value="Raw" onclick="d4ToggleEncoding()" />
|
||||||
|
<input id="d4LineBreakButton" type="button" value="Windows" onclick="d4ToggleLineBreak()" />
|
||||||
|
<textarea id=d4editorarea autocomplete="off" style="height:calc(100vh - 286px);width:100%;overflow:scroll;resize:none;white-space:pre"></textarea>
|
||||||
|
</div>
|
||||||
<div id=dialog7 style="">
|
<div id=dialog7 style="">
|
||||||
<div id="d7meshkvm">
|
<div id="d7meshkvm">
|
||||||
<h4>Agent Remote Desktop</h4>
|
<h4>Agent Remote Desktop</h4>
|
||||||
@ -340,6 +347,16 @@
|
|||||||
setupTerminal();
|
setupTerminal();
|
||||||
setupFiles();
|
setupFiles();
|
||||||
|
|
||||||
|
// Set the file editor
|
||||||
|
d4EditWrapVal = Number(getstore('editorWrap', 0));
|
||||||
|
d4EditSizeVal = Number(getstore('editorSize', 0));
|
||||||
|
d4EditEncodingVal = Number(getstore('editorEncoding', 0));
|
||||||
|
d4EditLineBreakVal = Number(getstore('editorLineBreak', 0));
|
||||||
|
d4ToggleWrap(true);
|
||||||
|
d4ToggleSize(true);
|
||||||
|
d4ToggleEncoding(true);
|
||||||
|
d4ToggleLineBreak(true);
|
||||||
|
|
||||||
// Set the document title
|
// Set the document title
|
||||||
if (nodeName.length > 0) { document.title += ' - ' + nodeName; }
|
if (nodeName.length > 0) { document.title += ' - ' + nodeName; }
|
||||||
|
|
||||||
@ -2030,6 +2047,8 @@
|
|||||||
if (gdownloadFile.tag == 'viewer') {
|
if (gdownloadFile.tag == 'viewer') {
|
||||||
// View the file in the dialog box
|
// View the file in the dialog box
|
||||||
setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
|
setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
|
||||||
|
QV('d4EncodingButton', true);
|
||||||
|
QV('d4LineBreakButton', true);
|
||||||
QS('dialog').width = 'auto';
|
QS('dialog').width = 'auto';
|
||||||
QS('dialog').bottom = '80px';
|
QS('dialog').bottom = '80px';
|
||||||
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
|
||||||
@ -2046,6 +2065,9 @@
|
|||||||
|
|
||||||
var d4EditWrapVal = 0;
|
var d4EditWrapVal = 0;
|
||||||
var d4EditSizeVal = 0;
|
var d4EditSizeVal = 0;
|
||||||
|
var d4EditEncodingVal = 0;
|
||||||
|
var d4EditLineBreakVal = 0;
|
||||||
|
|
||||||
function d4ToggleWrap(update) {
|
function d4ToggleWrap(update) {
|
||||||
if (!update) { d4EditWrapVal = ++d4EditWrapVal % 2; }
|
if (!update) { d4EditWrapVal = ++d4EditWrapVal % 2; }
|
||||||
Q('d4WrapButton').value = ["Wrap: ON", "Wrap: OFF"][d4EditWrapVal];
|
Q('d4WrapButton').value = ["Wrap: ON", "Wrap: OFF"][d4EditWrapVal];
|
||||||
@ -2061,8 +2083,38 @@
|
|||||||
putstore('editorSize', d4EditSizeVal);
|
putstore('editorSize', d4EditSizeVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function d4ToggleEncoding(update) {
|
||||||
|
if (!update) {
|
||||||
|
d4EditEncodingVal = ++d4EditEncodingVal % 2;
|
||||||
|
if (d4EditEncodingVal == 1) {
|
||||||
|
Q('d4editorarea').value = decode_utf8(Q('d4editorarea').value);
|
||||||
|
} else {
|
||||||
|
Q('d4editorarea').value = encode_utf8(Q('d4editorarea').value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Q('d4EncodingButton').value = ["Encoding: RAW","Encoding: UTF8"][d4EditEncodingVal];
|
||||||
|
putstore('editorEncoding', d4EditEncodingVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
function d4ToggleLineBreak(update) {
|
||||||
|
if (!update) {
|
||||||
|
d4EditLineBreakVal = ++d4EditLineBreakVal % 3;
|
||||||
|
}
|
||||||
|
Q('d4LineBreakButton').value = ["Line Break: Windows (CR LF)","Line Break: Linux (LF)","Line Break: Mac (CR)"][d4EditLineBreakVal];
|
||||||
|
putstore('editorLineBreak', d4EditLineBreakVal);
|
||||||
|
}
|
||||||
|
|
||||||
function p13editSaveBack(b, tag) {
|
function p13editSaveBack(b, tag) {
|
||||||
var data = new TextEncoder().encode(Q('d4editorarea').value);
|
var data;
|
||||||
|
var value = Q('d4editorarea').value;
|
||||||
|
value = d4EditLineBreakVal === 0 ? value.replace(/\r?\n|\r/g, '\r\n') : // Windows
|
||||||
|
d4EditLineBreakVal === 2 ? value.replace(/\r\n|\n/g, '\r') : // Mac
|
||||||
|
value.replace(/\r\n|\r/g, '\n'); // Linux
|
||||||
|
if (d4EditEncodingVal == 1) {
|
||||||
|
data = new TextEncoder().encode(value); // UTF8 encoding
|
||||||
|
} else {
|
||||||
|
data = new TextEncoder().encode(decode_utf8(value)); // RAW encoding
|
||||||
|
}
|
||||||
p13uploadFileContinue(1, [{ name: tag, size: data.byteLength, type: 'text/plain', xdata: data }]);
|
p13uploadFileContinue(1, [{ name: tag, size: data.byteLength, type: 'text/plain', xdata: data }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2260,6 +2312,27 @@
|
|||||||
xxcurrentView = x;
|
xxcurrentView = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function putstore(name, val) {
|
||||||
|
try {
|
||||||
|
if ((typeof (localStorage) === 'undefined') || (localStorage.getItem(name) == val)) return;
|
||||||
|
if (val == null) { localStorage.removeItem(name); } else { localStorage.setItem(name, val); }
|
||||||
|
} catch (ex) { }
|
||||||
|
if (name[0] != '_') {
|
||||||
|
var s = {};
|
||||||
|
try {
|
||||||
|
for (var i = 0, len = localStorage.length; i < len; ++i) {
|
||||||
|
var k = localStorage.key(i);
|
||||||
|
if (k[0] != '_') {
|
||||||
|
s[k] = localStorage.getItem(k);
|
||||||
|
if ((k != 'desktopsettings') && (k != 'stars') && (k != 'deskKeyShortcuts') && (k != 'deskStrings') && (k != 'cmdopt') && (typeof s[k] == 'string') && (s[k].length > 64)) { delete s[k]; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ex) {}
|
||||||
|
// meshserver.send({ action: 'userWebState', state: JSON.stringify(s) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } }
|
||||||
function messagebox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
|
function messagebox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
|
||||||
function statusbox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t); }
|
function statusbox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t); }
|
||||||
function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
|
function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
|
||||||
|
Loading…
Reference in New Issue
Block a user