fix minify files and log minify errors
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Feb 25, 2025 at 17:21 UTC
91bd5ae70279a2b0934428066a90346e3ba10f4a
6 files changed
+20
-984
public/scripts/agent-desktop-0.0.2-min.js
+1
-966
@@ -1,966 +1 @@
1
-/**
2
-* @description Remote Desktop
3
-* @author Ylian Saint-Hilaire
4
-* @version v0.0.2g
5
-*/
6
-
7
-// Polyfill Uint8Array.slice() for IE
8
-if (!Uint8Array.prototype.slice) { Object.defineProperty(Uint8Array.prototype, 'slice', { value: function (begin, end) { return new Uint8Array(Array.prototype.slice.call(this, begin, end)); } }); }
9
-
10
-function isWindowsBrowser() {
11
- return navigator && !!(/win/i).exec(navigator.platform);
12
-}
13
-
14
-// Construct a MeshServer object
15
-var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
16
- var obj = {}
17
- obj.CanvasId = canvasid;
18
- if (typeof canvasid === 'string') obj.CanvasId = Q(canvasid);
19
- obj.Canvas = obj.CanvasId.getContext('2d');
20
- obj.scrolldiv = scrolldiv;
21
- obj.State = 0;
22
- obj.PendingOperations = [];
23
- obj.tilesReceived = 0;
24
- obj.TilesDrawn = 0;
25
- obj.KillDraw = 0;
26
- obj.ipad = false;
27
- obj.tabletKeyboardVisible = false;
28
- obj.LastX = 0;
29
- obj.LastY = 0;
30
- obj.touchenabled = 0;
31
- obj.submenuoffset = 0;
32
- obj.touchtimer = null;
33
- obj.TouchArray = {};
34
- obj.connectmode = 0; // 0 = HTTP, 1 = WebSocket, 2 = WebRTC
35
- obj.connectioncount = 0;
36
- obj.rotation = 0;
37
- obj.protocol = 2; // KVM
38
- obj.debugmode = 0;
39
- obj.firstUpKeys = [];
40
- obj.stopInput = false;
41
- obj.localKeyMap = true;
42
- obj.remoteKeyMap = false; // If false, the remote keyboard mapping is not used.
43
- obj.pressedKeys = [];
44
- obj._altGrArmed = false; // Windows AltGr detection
45
- obj._altGrTimeout = 0;
46
- obj.isWindowsBrowser = isWindowsBrowser();
47
-
48
- obj.sessionid = 0;
49
- obj.username;
50
- obj.oldie = false;
51
- obj.ImageType = 1; // 1 = JPEG, 2 = PNG, 3 = TIFF, 4 = WebP
52
- obj.CompressionLevel = 50;
53
- obj.ScalingLevel = 1024;
54
- obj.FrameRateTimer = 100;
55
- obj.SwapMouse = false;
56
- obj.UseExtendedKeyFlag = true;
57
- obj.FirstDraw = false;
58
-
59
- // Remote user mouse and keyboard lock
60
- obj.onRemoteInputLockChanged = null;
61
- obj.RemoteInputLock = null;
62
-
63
- // Remote keyboard state
64
- obj.onKeyboardStateChanged = null;
65
- obj.KeyboardState = 0; // 1 = NumLock, 2 = ScrollLock, 4 = CapsLock
66
-
67
- obj.ScreenWidth = 960;
68
- obj.ScreenHeight = 701;
69
- obj.width = 960;
70
- obj.height = 960;
71
-
72
- obj.displays = null;
73
- obj.selectedDisplay = null;
74
-
75
- obj.onScreenSizeChange = null;
76
- obj.onMessage = null;
77
- obj.onConnectCountChanged = null;
78
- obj.onDebugMessage = null;
79
- obj.onTouchEnabledChanged = null;
80
- obj.onDisplayinfo = null;
81
- obj.accumulator = null;
82
-
83
- var xMouseCursorActive = true;
84
- var xMouseCursorCurrent = 'default';
85
- obj.mouseCursorActive = function (x) { if (xMouseCursorActive == x) return; xMouseCursorActive = x; obj.CanvasId.style.cursor = ((x == true) ? xMouseCursorCurrent : 'default'); }
86
- var mouseCursors = ['default', 'progress', 'crosshair', 'pointer', 'help', 'text', 'no-drop', 'move', 'nesw-resize', 'ns-resize', 'nwse-resize', 'w-resize', 'alias', 'wait', 'none', 'not-allowed', 'col-resize', 'row-resize', 'copy', 'zoom-in', 'zoom-out'];
87
-
88
- obj.Start = function () {
89
- obj.State = 0;
90
- obj.accumulator = null;
91
- }
92
-
93
- obj.Stop = function () {
94
- obj.setRotation(0);
95
- obj.UnGrabKeyInput();
96
- obj.UnGrabMouseInput();
97
- obj.touchenabled = 0;
98
- if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
99
- obj.Canvas.clearRect(0, 0, obj.CanvasId.width, obj.CanvasId.height);
100
- }
101
-
102
- obj.xxStateChange = function (newstate) {
103
- if (obj.State == newstate) return;
104
- obj.State = newstate;
105
- obj.CanvasId.style.cursor = 'default';
106
- //console.log('xxStateChange', newstate);
107
- switch (newstate) {
108
- case 0: {
109
- // Disconnect
110
- obj.Stop();
111
- break;
112
- }
113
- case 3: {
114
- // Websocket connected
115
-
116
- break;
117
- }
118
- }
119
- }
120
-
121
- obj.send = function (x) {
122
- if (obj.debugmode > 2) { console.log('KSend(' + x.length + '): ' + rstr2hex(x)); }
123
- if (obj.parent != null) { obj.parent.send(x); }
124
- }
125
-
126
- // KVM Control.
127
- // Routines for processing incoming packets from the AJAX server, and handling individual messages.
128
- obj.ProcessPictureMsg = function (data, X, Y) {
129
- //if (obj.targetnode != null) obj.Debug("ProcessPictureMsg " + X + "," + Y + " - " + obj.targetnode.substring(0, 8));
130
- var tile = new Image();
131
- tile.xcount = obj.tilesReceived++;
132
- var r = obj.tilesReceived, tdata = data.slice(4), ptr = 0, strs = [];
133
- // String.fromCharCode.apply() can't handle very large argument count, so we have to split like this.
134
- while ((tdata.byteLength - ptr) > 50000) { strs.push(String.fromCharCode.apply(null, tdata.slice(ptr, ptr + 50000))); ptr += 50000; }
135
- if (ptr > 0) { strs.push(String.fromCharCode.apply(null, tdata.slice(ptr))); } else { strs.push(String.fromCharCode.apply(null, tdata)); }
136
- tile.src = 'data:image/jpeg;base64,' + btoa(strs.join(''));
137
- tile.onload = function () {
138
- //console.log('DecodeTile #' + this.xcount);
139
- if ((obj.Canvas != null) && (obj.KillDraw < r) && (obj.State != 0)) {
140
- obj.PendingOperations.push([r, 2, tile, X, Y]);
141
- while (obj.DoPendingOperations()) { }
142
- } else {
143
- obj.PendingOperations.push([r, 0]);
144
- }
145
- }
146
- tile.error = function () { console.log('DecodeTileError'); }
147
- }
148
-
149
- obj.DoPendingOperations = function () {
150
- if (obj.PendingOperations.length == 0) return false;
151
- for (var i = 0; i < obj.PendingOperations.length; i++) { // && KillDraw < tilesDrawn
152
- var Msg = obj.PendingOperations[i];
153
- if (Msg[0] == (obj.TilesDrawn + 1)) {
154
- if (obj.onPreDrawImage != null) obj.onPreDrawImage(); // Notify that we are about to draw on the canvas.
155
- if (Msg[1] == 1) { obj.ProcessCopyRectMsg(Msg[2]); }
156
- else if (Msg[1] == 2) { obj.Canvas.drawImage(Msg[2], obj.rotX(Msg[3], Msg[4]), obj.rotY(Msg[3], Msg[4])); delete Msg[2]; }
157
- obj.PendingOperations.splice(i, 1);
158
- delete Msg;
159
- obj.TilesDrawn++;
160
- if ((obj.TilesDrawn == obj.tilesReceived) && (obj.KillDraw < obj.TilesDrawn)) { obj.KillDraw = obj.TilesDrawn = obj.tilesReceived = 0; }
161
- return true;
162
- }
163
- }
164
- if (obj.oldie && obj.PendingOperations.length > 0) { obj.TilesDrawn++; }
165
- return false;
166
- }
167
-
168
- obj.ProcessCopyRectMsg = function (str) {
169
- var SX = ((str.charCodeAt(0) & 0xFF) << 8) + (str.charCodeAt(1) & 0xFF);
170
- var SY = ((str.charCodeAt(2) & 0xFF) << 8) + (str.charCodeAt(3) & 0xFF);
171
- var DX = ((str.charCodeAt(4) & 0xFF) << 8) + (str.charCodeAt(5) & 0xFF);
172
- var DY = ((str.charCodeAt(6) & 0xFF) << 8) + (str.charCodeAt(7) & 0xFF);
173
- var WIDTH = ((str.charCodeAt(8) & 0xFF) << 8) + (str.charCodeAt(9) & 0xFF);
174
- var HEIGHT = ((str.charCodeAt(10) & 0xFF) << 8) + (str.charCodeAt(11) & 0xFF);
175
- obj.Canvas.drawImage(Canvas.canvas, SX, SY, WIDTH, HEIGHT, DX, DY, WIDTH, HEIGHT);
176
- }
177
-
178
- obj.SendUnPause = function () {
179
- if (obj.debugmode > 1) { console.log('SendUnPause'); }
180
- //obj.xxStateChange(3);
181
- obj.send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x00));
182
- }
183
-
184
- obj.SendPause = function () {
185
- if (obj.debugmode > 1) { console.log('SendPause'); }
186
- //obj.xxStateChange(2);
187
- obj.send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x01));
188
- }
189
-
190
- obj.SendCompressionLevel = function (type, level, scaling, frametimer) { // Type: 1 = JPEG, 2 = PNG, 3 = TIFF, 4 = WebP
191
- obj.ImageType = type;
192
- if (level) { obj.CompressionLevel = level; }
193
- if (scaling) { obj.ScalingLevel = scaling; }
194
- if (frametimer) { obj.FrameRateTimer = frametimer; }
195
- obj.send(String.fromCharCode(0x00, 0x05, 0x00, 0x0A, type, obj.CompressionLevel) + obj.shortToStr(obj.ScalingLevel) + obj.shortToStr(obj.FrameRateTimer));
196
- }
197
-
198
- obj.SendRefresh = function () {
199
- obj.send(String.fromCharCode(0x00, 0x06, 0x00, 0x04));
200
- }
201
-
202
- obj.ProcessScreenMsg = function (width, height) {
203
- if (obj.debugmode > 0) { console.log('ScreenSize: ' + width + ' x ' + height); }
204
- if ((obj.ScreenWidth == width) && (obj.ScreenHeight == height)) return; // Ignore change if screen is same size.
205
- obj.Canvas.setTransform(1, 0, 0, 1, 0, 0);
206
- obj.rotation = 0;
207
- obj.FirstDraw = true;
208
- obj.ScreenWidth = obj.width = width;
209
- obj.ScreenHeight = obj.height = height;
210
- obj.KillDraw = obj.tilesReceived;
211
- while (obj.PendingOperations.length > 0) { obj.PendingOperations.shift(); }
212
- obj.SendCompressionLevel(obj.ImageType);
213
- obj.SendUnPause();
214
- obj.SendRemoteInputLock(2); // Query input lock state
215
- // No need to event the display size change now, it will be evented on first draw.
216
- if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
217
- }
218
-
219
- obj.ProcessBinaryCommand = function (cmd, cmdsize, view) {
220
- var X, Y;
221
- if ((cmd == 3) || (cmd == 4) || (cmd == 7)) { X = (view[4] << 8) + view[5]; Y = (view[6] << 8) + view[7]; }
222
- if (obj.debugmode > 2) { console.log('CMD', cmd, cmdsize, X, Y); }
223
-
224
- // Fix for view being too large for String.fromCharCode.apply()
225
- var chunkSize = 10000;
226
- let result = '';
227
- for (let i = 0; i < view.length; i += chunkSize) { result += String.fromCharCode.apply(null, view.slice(i, i + chunkSize)); }
228
- // Record the command if needed
229
- if (obj.recordedData != null) {
230
- if (cmdsize > 65000) {
231
- obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(27) + obj.shortToStr(8) + obj.intToStr(cmdsize) + obj.shortToStr(cmd) + obj.shortToStr(0) + obj.shortToStr(0) + obj.shortToStr(0) + result));
232
- } else {
233
- obj.recordedData.push(recordingEntry(2, 1, result));
234
- }
235
- }
236
-
237
- switch (cmd) {
238
- case 3: // Tile
239
- if (obj.FirstDraw) obj.onResize();
240
- //console.log('TILE', X, Y, cmdsize);
241
- obj.ProcessPictureMsg(view.slice(4), X, Y);
242
- break;
243
- case 7: // Screen size
244
- obj.ProcessScreenMsg(X, Y);
245
- obj.SendKeyMsgKC(obj.KeyAction.UP, 16); // Shift
246
- obj.SendKeyMsgKC(obj.KeyAction.UP, 17); // Ctrl
247
- obj.SendKeyMsgKC(obj.KeyAction.UP, 18); // Alt
248
- obj.SendKeyMsgKC(obj.KeyAction.UP, 91); // Left-Windows
249
- obj.SendKeyMsgKC(obj.KeyAction.UP, 92); // Right-Windows
250
- obj.SendKeyMsgKC(obj.KeyAction.UP, 16); // Shift
251
- obj.send(String.fromCharCode(0x00, 0x0E, 0x00, 0x04));
252
- break;
253
- case 11: // GetDisplays (TODO)
254
- var selectedDisplay = 0, displays = {}, dcount = (view[4] << 8) + view[5];
255
- if (dcount > 0) {
256
- // Many displays present
257
- selectedDisplay = (view[6 + (dcount * 2)] << 8) + view[7 + (dcount * 2)];
258
- for (var i = 0; i < dcount; i++) {
259
- var disp = (view[6 + (i * 2)] << 8) + view[7 + (i * 2)];
260
- if (disp == 65535) { displays[disp] = 'All Displays'; } else { displays[disp] = 'Display ' + disp; }
261
- }
262
- }
263
- //console.log('Get Displays', displays, selectedDisplay, rstr2hex(str));
264
- obj.displays = displays; obj.selectedDisplay = selectedDisplay;
265
- if (obj.onDisplayinfo != null) { obj.onDisplayinfo(obj, displays, selectedDisplay); }
266
- break;
267
- case 12: // SetDisplay
268
- //console.log('SetDisplayConfirmed');
269
- break;
270
- case 14: // KVM_INIT_TOUCH
271
- obj.touchenabled = 1;
272
- obj.TouchArray = {};
273
- if (obj.onTouchEnabledChanged != null) obj.onTouchEnabledChanged(obj.touchenabled);
274
- break;
275
- case 15: // KVM_TOUCH
276
- obj.TouchArray = {};
277
- break;
278
- case 17: // MNG_KVM_MESSAGE
279
- var str = String.fromCharCode.apply(null, view.slice(4));
280
- console.log('Got KVM Message: ' + str);
281
- if (obj.onMessage != null) obj.onMessage(str, obj);
282
- break;
283
- case 18: // MNG_KVM_KEYSTATE
284
- if ((cmdsize != 5) || (obj.KeyboardState == view[4])) break;
285
- obj.KeyboardState = view[4]; // 1 = NumLock, 2 = ScrollLock, 4 = CapsLock
286
- if (obj.onKeyboardStateChanged) { obj.onKeyboardStateChanged(obj, obj.KeyboardState); }
287
- console.log('MNG_KVM_KEYSTATE:' + ((obj.KeyboardState & 1) ? ' NumLock' : '') + ((obj.KeyboardState & 2) ? ' ScrollLock' : '') + ((obj.KeyboardState & 4) ? ' CapsLock' : ''));
288
- break;
289
- case 65: // Alert
290
- var str = String.fromCharCode.apply(null, view.slice(4));
291
- if (str[0] != '.') {
292
- console.log(str); //alert('KVM: ' + str);
293
- if (obj.parent && obj.parent.setConsoleMessage) { obj.parent.setConsoleMessage(str); }
294
- } else {
295
- console.log('KVM: ' + str.substring(1));
296
- }
297
- break;
298
- case 82: // DISPLAY LOCATION & SIZE
299
- if ((cmdsize < 4) || (((cmdsize - 4) % 10) != 0)) break;
300
- var screenCount = ((cmdsize - 4) / 10), screenInfo = {}, ptr = 4;
301
- for (var i = 0; i < screenCount; i++) { screenInfo[(view[ptr + 0] << 8) + view[ptr + 1]] = { x: ((view[ptr + 2] << 8) + view[ptr + 3]), y: ((view[ptr + 4] << 8) + view[ptr + 5]), w: ((view[ptr + 6] << 8) + view[ptr + 7]), h: ((view[ptr + 8] << 8) + view[ptr + 9]) }; ptr += 10; }
302
- //console.log('ScreenInfo', JSON.stringify(screenInfo, null, 2));
303
- break;
304
- case 87: // MNG_KVM_INPUT_LOCK
305
- if (cmdsize != 5) break;
306
- if ((obj.RemoteInputLock == null) || (obj.RemoteInputLock !== (view[4] != 0))) {
307
- obj.RemoteInputLock = (view[4] != 0);
308
- if (obj.onRemoteInputLockChanged) { obj.onRemoteInputLockChanged(obj, obj.RemoteInputLock); }
309
- }
310
- break;
311
- case 88: // MNG_KVM_MOUSE_CURSOR
312
- if ((cmdsize != 5) || (obj.stopInput)) break;
313
- var cursorNum = view[4];
314
- if (cursorNum > mouseCursors.length) { cursorNum = 0; }
315
- xMouseCursorCurrent = mouseCursors[cursorNum];
316
- if (xMouseCursorActive) { obj.CanvasId.style.cursor = xMouseCursorCurrent; }
317
- break;
318
- default:
319
- console.log('Unknown command', cmd, cmdsize);
320
- break;
321
- }
322
-
323
- }
324
-
325
- // Keyboard and Mouse I/O.
326
- obj.MouseButton = { "NONE": 0x00, "LEFT": 0x02, "RIGHT": 0x08, "MIDDLE": 0x20 };
327
- obj.KeyAction = { "NONE": 0, "DOWN": 1, "UP": 2, "SCROLL": 3, "EXUP": 4, "EXDOWN": 5, "DBLCLICK": 6 };
328
- obj.InputType = { "KEY": 1, "MOUSE": 2, "CTRLALTDEL": 10, "TOUCH": 15, "KEYUNICODE": 85 };
329
- obj.Alternate = 0;
330
-
331
- var convertKeyCodeTable = {
332
- "Pause": 19,
333
- "CapsLock": 20,
334
- "Space": 32,
335
- "Quote": 222,
336
- "Minus": 189,
337
- "NumpadMultiply": 106,
338
- "NumpadAdd": 107,
339
- "PrintScreen": 44,
340
- "Comma": 188,
341
- "NumpadSubtract": 109,
342
- "NumpadDecimal": 110,
343
- "Period": 190,
344
- "Slash": 191,
345
- "NumpadDivide": 111,
346
- "Semicolon": 186,
347
- "Equal": 187,
348
- "OSLeft": 91,
349
- "BracketLeft": 219,
350
- "OSRight": 91,
351
- "Backslash": 220,
352
- "BracketRight": 221,
353
- "ContextMenu": 93,
354
- "Backquote": 192,
355
- "NumLock": 144,
356
- "ScrollLock": 145,
357
- "Backspace": 8,
358
- "Tab": 9,
359
- "Enter": 13,
360
- "NumpadEnter": 13,
361
- "Escape": 27,
362
- "Delete": 46,
363
- "Home": 36,
364
- "PageUp": 33,
365
- "PageDown": 34,
366
- "ArrowLeft": 37,
367
- "ArrowUp": 38,
368
- "ArrowRight": 39,
369
- "ArrowDown": 40,
370
- "End": 35,
371
- "Insert": 45,
372
- "F1": 112,
373
- "F2": 113,
374
- "F3": 114,
375
- "F4": 115,
376
- "F5": 116,
377
- "F6": 117,
378
- "F7": 118,
379
- "F8": 119,
380
- "F9": 120,
381
- "F10": 121,
382
- "F11": 122,
383
- "F12": 123,
384
- "ShiftLeft": 16,
385
- "ShiftRight": 16,
386
- "ControlLeft": 17,
387
- "ControlRight": 17,
388
- "AltLeft": 18,
389
- "AltRight": 18,
390
- "MetaLeft": 91,
391
- "MetaRight": 92,
392
- "VolumeMute": 181
393
- //"LaunchMail":
394
- //"LaunchApp1":
395
- //"LaunchApp2":
396
- //"BrowserStop":
397
- //"MediaStop":
398
- //"MediaTrackPrevious":
399
- //"MediaTrackNext":
400
- //"MediaPlayPause":
401
- //"MediaSelect":
402
- }
403
-
404
- function convertKeyCode(e) {
405
- if (e.code.startsWith('Key') && e.code.length == 4) { return e.code.charCodeAt(3); }
406
- if (e.code.startsWith('Digit') && e.code.length == 6) { return e.code.charCodeAt(5); }
407
- if (e.code.startsWith('Numpad') && e.code.length == 7) { return e.code.charCodeAt(6) + 48; }
408
- return convertKeyCodeTable[e.code];
409
- }
410
-
411
- var extendedKeyTable = ['ShiftRight', 'AltRight', 'ControlRight', 'Home', 'End', 'Insert', 'Delete', 'PageUp', 'PageDown', 'NumpadDivide', 'NumpadEnter', 'NumLock', 'Pause'];
412
- obj.SendKeyMsg = function (action, event) {
413
- if (action == null) return;
414
- if (!event) { event = window.event; }
415
-
416
- var extendedKey = false; // Test feature, add ?extkeys=1 to url to use.
417
-
418
- if ((obj.UseExtendedKeyFlag || (urlargs.extkeys == 1)) && (typeof event.code == 'string') && (event.code.startsWith('Arrow') || (extendedKeyTable.indexOf(event.code) >= 0))) {
419
- extendedKey = true;
420
- }
421
-
422
- if (obj.isWindowsBrowser) {
423
- if( obj.checkAltGr(obj, event, action) ) {
424
- return;
425
- };
426
- }
427
-
428
- if ((extendedKey == false) && event.code && (event.code.startsWith('NumPad') == false) && (obj.localKeyMap == false)) {
429
- // Convert "event.code" into a scancode. This works the same regardless of the keyboard language.
430
- // Older browsers will not support this.
431
- var kc = convertKeyCode(event);
432
- if (kc != null) { obj.SendKeyMsgKC(action, kc, extendedKey); }
433
- } else {
434
- // Use this keycode, this works best with "US-EN" keyboards.
435
- // Older browser support this.
436
- var kc = event.keyCode;
437
- if (kc == 0x3B) { kc = 0xBA; } // Fix the ';' key
438
- else if (kc == 173) { kc = 189; } // Fix the '-' key for Firefox
439
- else if (kc == 61) { kc = 187; } // Fix the '=' key for Firefox
440
- obj.SendKeyMsgKC(action, kc, extendedKey);
441
- }
442
- }
443
-
444
- const ControlLeftKc = 17;
445
- const AltGrKc = 225;
446
- //return true: Key is alredy handled.
447
- obj.checkAltGr = function (obj, event, action) {
448
- // Windows doesn't have a proper AltGr, but handles it using
449
- // fake Ctrl+Alt. However the remote end might not be Windows,
450
- // so we need to merge those into a single AltGr event. We
451
- // detect this case by seeing the two key events directly after
452
- // each other with a very short time between them (<50ms).
453
- if (obj._altGrArmed) {
454
- obj._altGrArmed = false;
455
- clearTimeout(obj._altGrTimeout);
456
-
457
- if ((event.code === "AltRight") && ((event.timeStamp - obj._altGrCtrlTime) < 50)) {
458
- //AltGr detected.
459
- obj.SendKeyMsgKC( action, AltGrKc, false);
460
- return true;
461
- }
462
- }
463
-
464
- // Possible start of AltGr sequence?
465
- if ((event.code === "ControlLeft") && !(ControlLeftKc in obj.pressedKeys)) {
466
- obj._altGrArmed = true;
467
- obj._altGrCtrlTime = event.timeStamp;
468
- if( action == 1 ) {
469
- obj._altGrTimeout = setTimeout(obj._handleAltGrTimeout.bind(obj), 100);
470
- return true;
471
- }
472
- }
473
- return false;
474
- }
475
-
476
- obj._handleAltGrTimeout = function () { //Windows and no Ctrl+Alt -> send only Ctrl.
477
- obj._altGrArmed = false;
478
- clearTimeout(obj._altGrTimeout);
479
- obj.SendKeyMsgKC( 1, ControlLeftKc, false); // (KeyDown, "ControlLeft", false)
480
- }
481
-
482
- // Send remote input lock. 0 = Unlock, 1 = Lock, 2 = Query
483
- obj.SendRemoteInputLock = function (code) { obj.send(String.fromCharCode(0x00, 87, 0x00, 0x05, code)); }
484
-
485
- obj.SendMessage = function (msg) {
486
- if (obj.State == 3) obj.send(String.fromCharCode(0x00, 0x11) + obj.shortToStr(4 + msg.length) + msg); // 0x11 = 17 MNG_KVM_MESSAGE
487
- }
488
-
489
- obj.SendKeyMsgKC = function (action, kc, extendedKey) {
490
- if (obj.State != 3) return;
491
- if (typeof action == 'object') { for (var i in action) { obj.SendKeyMsgKC(action[i][0], action[i][1], action[i][2]); } }
492
- else {
493
- if (action == 1) { // Key Down
494
- if (obj.pressedKeys.indexOf(kc) == -1) { obj.pressedKeys.unshift(kc); } // Add key press to start of array
495
- } else if (action == 2) { // Key Up
496
- var i = obj.pressedKeys.indexOf(kc);
497
- if (i != -1) { obj.pressedKeys.splice(i, 1); } // Remove the key press from the pressed array
498
- }
499
- if (obj.debugmode > 0) { console.log('Sending Key ' + kc + ', action ' + action); }
500
-
501
- var up = (action - 1);
502
- if (extendedKey) { if (up == 1) { up = 3; } else { up = 4; } }
503
- obj.send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, up, kc));
504
- }
505
- }
506
-
507
- obj.SendStringUnicode = function (str) {
508
- if (obj.State != 3) return;
509
- for (var i = 0; i < str.length; i++) {
510
- obj.send(String.fromCharCode(0x00, obj.InputType.KEYUNICODE, 0x00, 0x07, 0) + ShortToStr(str.charCodeAt(i)));
511
- obj.send(String.fromCharCode(0x00, obj.InputType.KEYUNICODE, 0x00, 0x07, 1) + ShortToStr(str.charCodeAt(i)));
512
- }
513
- }
514
-
515
- obj.SendKeyUnicode = function (action, val) {
516
- if (obj.State != 3) return;
517
- if (obj.debugmode > 0) { console.log('Sending UnicodeKey ' + val + ', action ' + action); }
518
- obj.send(String.fromCharCode(0x00, obj.InputType.KEYUNICODE, 0x00, 0x07, (action - 1)) + ShortToStr(val));
519
- }
520
-
521
- obj.sendcad = function() { obj.SendCtrlAltDelMsg(); }
522
-
523
- obj.SendCtrlAltDelMsg = function () {
524
- if (obj.State == 3) { obj.send(String.fromCharCode(0x00, obj.InputType.CTRLALTDEL, 0x00, 0x04)); }
525
- }
526
-
527
- obj.SendEscKey = function () {
528
- if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, 0x00, 0x1B, 0x00, obj.InputType.KEY, 0x00, 0x06, 0x01, 0x1B));
529
- }
530
-
531
- obj.SendStartMsg = function () {
532
- obj.SendKeyMsgKC(obj.KeyAction.EXDOWN, 0x5B); // L-Windows
533
- obj.SendKeyMsgKC(obj.KeyAction.EXUP, 0x5B); // L-Windows
534
- }
535
-
536
- obj.SendCharmsMsg = function () {
537
- obj.SendKeyMsgKC(obj.KeyAction.EXDOWN, 0x5B); // L-Windows
538
- obj.SendKeyMsgKC(obj.KeyAction.DOWN, 67); // C
539
- obj.SendKeyMsgKC(obj.KeyAction.UP, 67); // C
540
- obj.SendKeyMsgKC(obj.KeyAction.EXUP, 0x5B); // L-Windows
541
- }
542
-
543
- obj.SendTouchMsg1 = function (id, flags, x, y) {
544
- if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(14) + String.fromCharCode(0x01, id) + obj.intToStr(flags) + obj.shortToStr(x) + obj.shortToStr(y));
545
- }
546
-
547
- obj.SendTouchMsg2 = function (id, flags) {
548
- var msg = '';
549
- var flags2;
550
- var str = "TOUCHSEND: ";
551
- for (var k in obj.TouchArray) {
552
- if (k == id) { flags2 = flags; } else {
553
- if (obj.TouchArray[k].f == 1) { flags2 = 0x00010000 | 0x00000002 | 0x00000004; obj.TouchArray[k].f = 3; str += "START" + k; } // POINTER_FLAG_DOWN
554
- else if (obj.TouchArray[k].f == 2) { flags2 = 0x00040000; str += "STOP" + k; } // POINTER_FLAG_UP
555
- else flags2 = 0x00000002 | 0x00000004 | 0x00020000; // POINTER_FLAG_UPDATE
556
- }
557
- msg += String.fromCharCode(k) + obj.intToStr(flags2) + obj.shortToStr(obj.TouchArray[k].x) + obj.shortToStr(obj.TouchArray[k].y);
558
- if (obj.TouchArray[k].f == 2) delete obj.TouchArray[k];
559
- }
560
- if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(5 + msg.length) + String.fromCharCode(0x02) + msg);
561
- if (Object.keys(obj.TouchArray).length == 0 && obj.touchtimer != null) { clearInterval(obj.touchtimer); obj.touchtimer = null; }
562
- }
563
-
564
- obj.SendMouseMsg = function (Action, event) {
565
- if (obj.State != 3) return;
566
- if (Action != null && obj.Canvas != null) {
567
- if (!event) { var event = window.event; }
568
-
569
- var ScaleFactorHeight = (obj.Canvas.canvas.height / obj.CanvasId.clientHeight);
570
- var ScaleFactorWidth = (obj.Canvas.canvas.width / obj.CanvasId.clientWidth);
571
- var Offsets = obj.GetPositionOfControl(obj.Canvas.canvas);
572
- var X = ((event.pageX - Offsets[0]) * ScaleFactorWidth);
573
- var Y = ((event.pageY - Offsets[1]) * ScaleFactorHeight);
574
- if (event.addx) { X += event.addx; }
575
- if (event.addy) { Y += event.addy; }
576
-
577
- if (X >= 0 && X <= obj.Canvas.canvas.width && Y >= 0 && Y <= obj.Canvas.canvas.height) {
578
- var Button = 0;
579
- var Delta = 0;
580
- if (Action == obj.KeyAction.UP || Action == obj.KeyAction.DOWN) {
581
- if (event.which) { ((event.which == 1) ? (Button = obj.MouseButton.LEFT) : ((event.which == 2) ? (Button = obj.MouseButton.MIDDLE) : (Button = obj.MouseButton.RIGHT))); }
582
- else if (typeof event.button == 'number') { ((event.button == 0) ? (Button = obj.MouseButton.LEFT) : ((event.button == 1) ? (Button = obj.MouseButton.MIDDLE) : (Button = obj.MouseButton.RIGHT))); }
583
- }
584
- else if (Action == obj.KeyAction.SCROLL) {
585
- if (event.detail) { Delta = (-1 * (event.detail * 120)); } else if (event.wheelDelta) { Delta = (event.wheelDelta * 3); }
586
- }
587
-
588
- // Swap mouse buttons if needed
589
- if (obj.SwapMouse === true) {
590
- if (Button == obj.MouseButton.LEFT) { Button = obj.MouseButton.RIGHT; }
591
- else if (Button == obj.MouseButton.RIGHT) { Button = obj.MouseButton.LEFT; }
592
- }
593
-
594
- // Reverse mouse wheel if needed
595
- if (obj.ReverseMouseWheel) { Delta = -1 * Delta; }
596
-
597
- var MouseMsg = "";
598
- if (Action == obj.KeyAction.DBLCLICK) {
599
- MouseMsg = String.fromCharCode(0x00, obj.InputType.MOUSE, 0x00, 0x0A, 0x00, 0x88, ((X / 256) & 0xFF), (X & 0xFF), ((Y / 256) & 0xFF), (Y & 0xFF));
600
- } else if (Action == obj.KeyAction.SCROLL) {
601
- var deltaHigh = 0, deltaLow = 0;
602
- if (Delta < 0) { deltaHigh = (255 - (Math.abs(Delta) >> 8)); deltaLow = (255 - (Math.abs(Delta) & 0xFF)); } else { deltaHigh = (Delta >> 8); deltaLow = (Delta & 0xFF); }
603
- MouseMsg = String.fromCharCode(0x00, obj.InputType.MOUSE, 0x00, 0x0C, 0x00, 0x00, ((X / 256) & 0xFF), (X & 0xFF), ((Y / 256) & 0xFF), (Y & 0xFF), deltaHigh, deltaLow);
604
- } else {
605
- MouseMsg = String.fromCharCode(0x00, obj.InputType.MOUSE, 0x00, 0x0A, 0x00, ((Action == obj.KeyAction.DOWN) ? Button : ((Button * 2) & 0xFF)), ((X / 256) & 0xFF), (X & 0xFF), ((Y / 256) & 0xFF), (Y & 0xFF));
606
- }
607
-
608
- if (obj.Action == obj.KeyAction.NONE) {
609
- if (obj.Alternate == 0 || obj.ipad) { obj.send(MouseMsg); obj.Alternate = 1; } else { obj.Alternate = 0; }
610
- } else {
611
- obj.send(MouseMsg);
612
- }
613
- }
614
- }
615
- }
616
-
617
- obj.GetDisplayNumbers = function () { obj.send(String.fromCharCode(0x00, 0x0B, 0x00, 0x04)); } // Get Terminal display
618
- obj.SetDisplay = function (number) { /*console.log('Set display', number);*/ obj.send(String.fromCharCode(0x00, 0x0C, 0x00, 0x06, number >> 8, number & 0xFF)); } // Set Terminal display
619
- obj.intToStr = function (x) { return String.fromCharCode((x >> 24) & 0xFF, (x >> 16) & 0xFF, (x >> 8) & 0xFF, x & 0xFF); }
620
- obj.shortToStr = function (x) { return String.fromCharCode((x >> 8) & 0xFF, x & 0xFF); }
621
-
622
- obj.onResize = function () {
623
- if (obj.ScreenWidth == 0 || obj.ScreenHeight == 0) return;
624
- if ((obj.Canvas.canvas.width == obj.ScreenWidth) && (obj.Canvas.canvas.height == obj.ScreenHeight)) return;
625
- if (obj.FirstDraw) {
626
- obj.Canvas.canvas.width = obj.ScreenWidth;
627
- obj.Canvas.canvas.height = obj.ScreenHeight;
628
- obj.Canvas.fillRect(0, 0, obj.ScreenWidth, obj.ScreenHeight);
629
- if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
630
- }
631
- obj.FirstDraw = false;
632
- if (obj.debugmode > 1) { console.log("onResize: " + obj.ScreenWidth + " x " + obj.ScreenHeight); }
633
- }
634
-
635
- obj.xxMouseInputGrab = false;
636
- obj.xxKeyInputGrab = false;
637
- obj.xxMouseMove = function (e) { if (obj.State == 3) obj.SendMouseMsg(obj.KeyAction.NONE, e); if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
638
- obj.xxMouseUp = function (e) { if (obj.State == 3) obj.SendMouseMsg(obj.KeyAction.UP, e); if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
639
- obj.xxMouseDown = function (e) { if (obj.State == 3) obj.SendMouseMsg(obj.KeyAction.DOWN, e); if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
640
- obj.xxMouseDblClick = function (e) { if (obj.State == 3) obj.SendMouseMsg(obj.KeyAction.DBLCLICK, e); if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
641
- obj.xxDOMMouseScroll = function (e) { if (obj.State == 3) { obj.SendMouseMsg(obj.KeyAction.SCROLL, e); return false; } return true; }
642
- obj.xxMouseWheel = function (e) { if (obj.State == 3) { obj.SendMouseMsg(obj.KeyAction.SCROLL, e); return false; } return true; }
643
- obj.xxKeyUp = function (e) {
644
- if ((e.key != 'Dead') && (obj.State == 3)) {
645
- if ((typeof e.key == 'string') && (e.key.length == 1) && (e.ctrlKey != true) && (e.altKey != true) && (obj.remoteKeyMap == false)) {
646
- obj.SendKeyUnicode(obj.KeyAction.UP, e.key.charCodeAt(0));
647
- } else {
648
- obj.SendKeyMsg(obj.KeyAction.UP, e);
649
- }
650
- }
651
- if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false;
652
- }
653
- obj.xxKeyDown = function (e) {
654
- if ((e.key != 'Dead') && (obj.State == 3)) {
655
- if (!((typeof e.key == 'string') && (e.key.length == 1) && (e.ctrlKey != true) && (e.altKey != true) && (obj.remoteKeyMap == false))) {
656
- obj.SendKeyMsg(obj.KeyAction.DOWN, e);
657
- if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false;
658
- }
659
- }
660
- }
661
- obj.xxKeyPress = function (e) {
662
- if ((e.key != 'Dead') && (obj.State == 3)) {
663
- if ((typeof e.key == 'string') && (e.key.length == 1) && (e.ctrlKey != true) && (e.altKey != true) && (obj.remoteKeyMap == false)) {
664
- obj.SendKeyUnicode(obj.KeyAction.DOWN, e.key.charCodeAt(0));
665
- } // else { obj.SendKeyMsg(obj.KeyAction.DOWN, e); }
666
- }
667
- if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false;
668
- }
669
-
670
- // Key handlers
671
- obj.handleKeys = function (e) {
672
- //console.log('keypress', e.code, e.key, e.keyCode, (e.key.length == 1) ? e.key.charCodeAt(0) : 0);
673
- if (obj.stopInput == true || desktop.State != 3) return false;
674
- return obj.xxKeyPress(e);
675
- }
676
- obj.handleKeyUp = function (e) {
677
- //console.log('keyup', e.code, e.key, e.keyCode, (e.key.length == 1)?e.key.charCodeAt(0):0);
678
- if (obj.stopInput == true || desktop.State != 3) return false;
679
- if (obj.firstUpKeys.length < 5) {
680
- obj.firstUpKeys.push(e.keyCode);
681
- if ((obj.firstUpKeys.length == 5)) { var j = obj.firstUpKeys.join(','); if ((j == '16,17,91,91,16') || (j == '16,17,18,91,92')) { obj.stopInput = true; } }
682
- }
683
- return obj.xxKeyUp(e);
684
- }
685
- obj.handleKeyDown = function (e) {
686
- //console.log('keydown', e.code, e.key, e.keyCode, (e.key.length == 1) ? e.key.charCodeAt(0) : 0);
687
- if (obj.stopInput == true || desktop.State != 3) return false;
688
- return obj.xxKeyDown(e);
689
- }
690
-
691
- // Release the CTRL, ALT, SHIFT keys if they are pressed.
692
- obj.handleReleaseKeys = function () {
693
- var p = JSON.parse(JSON.stringify(obj.pressedKeys)); // Clone the pressed array
694
- for (var i in p) { obj.SendKeyMsgKC(obj.KeyAction.UP, p[i]); } // Release all keys
695
- }
696
-
697
- // Mouse handlers
698
- obj.mousedblclick = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseDblClick(e); }
699
- obj.mousedown = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseDown(e); }
700
- obj.mouseup = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseUp(e); }
701
- obj.mousemove = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseMove(e); }
702
- obj.mousewheel = function (e) { if (obj.stopInput == true) return false; return obj.xxMouseWheel(e); }
703
-
704
- obj.xxMsTouchEvent = function (evt) {
705
- if (evt.originalEvent.pointerType == 4) return; // If this is a mouse pointer, ignore this event. Touch & pen are ok.
706
- if (evt.preventDefault) evt.preventDefault();
707
- if (evt.stopPropagation) evt.stopPropagation();
708
- if (evt.type == 'MSPointerDown' || evt.type == 'MSPointerMove' || evt.type == 'MSPointerUp') {
709
- var flags = 0;
710
- var id = evt.originalEvent.pointerId % 256;
711
- var X = evt.offsetX * (Canvas.canvas.width / obj.CanvasId.clientWidth);
712
- var Y = evt.offsetY * (Canvas.canvas.height / obj.CanvasId.clientHeight);
713
-
714
- if (evt.type == 'MSPointerDown') flags = 0x00010000 | 0x00000002 | 0x00000004; // POINTER_FLAG_DOWN
715
- else if (evt.type == 'MSPointerMove') {
716
- //if (obj.TouchArray[id] && MuchTheSame(obj.TouchArray[id].x, X) && MuchTheSame(obj.TouchArray[id].y, Y)) return;
717
- flags = 0x00020000 | 0x00000002 | 0x00000004; // POINTER_FLAG_UPDATE
718
- }
719
- else if (evt.type == 'MSPointerUp') flags = 0x00040000; // POINTER_FLAG_UP
720
-
721
- if (!obj.TouchArray[id]) obj.TouchArray[id] = { x: X, y : Y };
722
- obj.SendTouchMsg2(id, flags)
723
- if (evt.type == 'MSPointerUp') delete obj.TouchArray[id];
724
- } else {
725
- alert(evt.type);
726
- }
727
- return true;
728
- }
729
-
730
- obj.xxTouchStart = function (e) {
731
- if (obj.State != 3) return;
732
- if (e.preventDefault) e.preventDefault();
733
- if (obj.touchenabled == 0 || obj.touchenabled == 1) {
734
- if (e.originalEvent.touches.length > 1) return;
735
- var t = e.originalEvent.touches[0];
736
- e.which = 1;
737
- obj.LastX = e.pageX = t.pageX;
738
- obj.LastY = e.pageY = t.pageY;
739
- obj.SendMouseMsg(KeyAction.DOWN, e);
740
- } else {
741
- var Offsets = obj.GetPositionOfControl(Canvas.canvas);
742
- for (var i in e.originalEvent.changedTouches) {
743
- if (!e.originalEvent.changedTouches[i].identifier) continue;
744
- var id = e.originalEvent.changedTouches[i].identifier % 256;
745
- if (!obj.TouchArray[id]) { obj.TouchArray[id] = { x: (e.originalEvent.touches[i].pageX - Offsets[0]) * (Canvas.canvas.width / obj.CanvasId.clientWidth), y: (e.originalEvent.touches[i].pageY - Offsets[1]) * (Canvas.canvas.height / obj.CanvasId.clientHeight), f: 1 }; }
746
- }
747
- if (Object.keys(obj.TouchArray).length > 0 && touchtimer == null) { obj.touchtimer = setInterval(function () { obj.SendTouchMsg2(256, 0); }, 50); }
748
- }
749
- }
750
-
751
- obj.xxTouchMove = function (e) {
752
- if (obj.State != 3) return;
753
- if (e.preventDefault) e.preventDefault();
754
- if (obj.touchenabled == 0 || obj.touchenabled == 1) {
755
- if (e.originalEvent.touches.length > 1) return;
756
- var t = e.originalEvent.touches[0];
757
- e.which = 1;
758
- obj.LastX = e.pageX = t.pageX;
759
- obj.LastY = e.pageY = t.pageY;
760
- obj.SendMouseMsg(obj.KeyAction.NONE, e);
761
- } else {
762
- var Offsets = obj.GetPositionOfControl(Canvas.canvas);
763
- for (var i in e.originalEvent.changedTouches) {
764
- if (!e.originalEvent.changedTouches[i].identifier) continue;
765
- var id = e.originalEvent.changedTouches[i].identifier % 256;
766
- if (obj.TouchArray[id]) {
767
- obj.TouchArray[id].x = (e.originalEvent.touches[i].pageX - Offsets[0]) * (obj.Canvas.canvas.width / obj.CanvasId.clientWidth);
768
- obj.TouchArray[id].y = (e.originalEvent.touches[i].pageY - Offsets[1]) * (obj.Canvas.canvas.height / obj.CanvasId.clientHeight);
769
- }
770
- }
771
- }
772
- }
773
-
774
- obj.xxTouchEnd = function (e) {
775
- if (obj.State != 3) return;
776
- if (e.preventDefault) e.preventDefault();
777
- if (obj.touchenabled == 0 || obj.touchenabled == 1) {
778
- if (e.originalEvent.touches.length > 1) return;
779
- e.which = 1;
780
- e.pageX = LastX;
781
- e.pageY = LastY;
782
- obj.SendMouseMsg(KeyAction.UP, e);
783
- } else {
784
- for (var i in e.originalEvent.changedTouches) {
785
- if (!e.originalEvent.changedTouches[i].identifier) continue;
786
- var id = e.originalEvent.changedTouches[i].identifier % 256;
787
- if (obj.TouchArray[id]) obj.TouchArray[id].f = 2;
788
- }
789
- }
790
- }
791
-
792
- obj.GrabMouseInput = function () {
793
- if (obj.xxMouseInputGrab == true) return;
794
- var c = obj.CanvasId;
795
- c.onmousemove = obj.xxMouseMove;
796
- c.onmouseup = obj.xxMouseUp;
797
- c.onmousedown = obj.xxMouseDown;
798
- c.touchstart = obj.xxTouchStart;
799
- c.touchmove = obj.xxTouchMove;
800
- c.touchend = obj.xxTouchEnd;
801
- c.MSPointerDown = obj.xxMsTouchEvent;
802
- c.MSPointerMove = obj.xxMsTouchEvent;
803
- c.MSPointerUp = obj.xxMsTouchEvent;
804
- if (navigator.userAgent.match(/mozilla/i)) c.DOMMouseScroll = obj.xxDOMMouseScroll; else c.onmousewheel = obj.xxMouseWheel;
805
- obj.xxMouseInputGrab = true;
806
- }
807
-
808
- obj.UnGrabMouseInput = function () {
809
- if (obj.xxMouseInputGrab == false) return;
810
- var c = obj.CanvasId;
811
- c.onmousemove = null;
812
- c.onmouseup = null;
813
- c.onmousedown = null;
814
- c.touchstart = null;
815
- c.touchmove = null;
816
- c.touchend = null;
817
- c.MSPointerDown = null;
818
- c.MSPointerMove = null;
819
- c.MSPointerUp = null;
820
- if (navigator.userAgent.match(/mozilla/i)) c.DOMMouseScroll = null; else c.onmousewheel = null;
821
- obj.xxMouseInputGrab = false;
822
- }
823
-
824
- obj.GrabKeyInput = function () {
825
- if (obj.xxKeyInputGrab == true) return;
826
- document.onkeyup = obj.xxKeyUp;
827
- document.onkeydown = obj.xxKeyDown;
828
- document.onkeypress = obj.xxKeyPress;c
829
- obj.xxKeyInputGrab = true;
830
- }
831
-
832
- obj.UnGrabKeyInput = function () {
833
- if (obj.xxKeyInputGrab == false) return;
834
- document.onkeyup = null;
835
- document.onkeydown = null;
836
- document.onkeypress = null;
837
- obj.xxKeyInputGrab = false;
838
- }
839
-
840
- obj.GetPositionOfControl = function (Control) {
841
- var Position = Array(2);
842
- Position[0] = Position[1] = 0;
843
- while (Control) { Position[0] += Control.offsetLeft; Position[1] += Control.offsetTop; Control = Control.offsetParent; }
844
- return Position;
845
- }
846
-
847
- obj.crotX = function (x, y) {
848
- if (obj.rotation == 0) return x;
849
- if (obj.rotation == 1) return y;
850
- if (obj.rotation == 2) return obj.Canvas.canvas.width - x;
851
- if (obj.rotation == 3) return obj.Canvas.canvas.height - y;
852
- }
853
-
854
- obj.crotY = function (x, y) {
855
- if (obj.rotation == 0) return y;
856
- if (obj.rotation == 1) return obj.Canvas.canvas.width - x;
857
- if (obj.rotation == 2) return obj.Canvas.canvas.height - y;
858
- if (obj.rotation == 3) return x;
859
- }
860
-
861
- obj.rotX = function (x, y) {
862
- if (obj.rotation == 0 || obj.rotation == 1) return x;
863
- if (obj.rotation == 2) return x - obj.Canvas.canvas.width;
864
- if (obj.rotation == 3) return x - obj.Canvas.canvas.height;
865
- }
866
-
867
- obj.rotY = function (x, y) {
868
- if (obj.rotation == 0 || obj.rotation == 3) return y;
869
- if (obj.rotation == 1) return y - obj.Canvas.canvas.width;
870
- if (obj.rotation == 2) return y - obj.Canvas.canvas.height;
871
- }
872
-
873
- obj.tcanvas = null;
874
- obj.setRotation = function (x) {
875
- while (x < 0) { x += 4; }
876
- var newrotation = x % 4;
877
- if (newrotation == obj.rotation) return true;
878
- var rw = obj.Canvas.canvas.width;
879
- var rh = obj.Canvas.canvas.height;
880
- if (obj.rotation == 1 || obj.rotation == 3) { rw = obj.Canvas.canvas.height; rh = obj.Canvas.canvas.width; }
881
-
882
- // Copy the canvas, put it back in the correct direction
883
- if (obj.tcanvas == null) obj.tcanvas = document.createElement('canvas');
884
- var tcanvasctx = obj.tcanvas.getContext('2d');
885
- tcanvasctx.setTransform(1, 0, 0, 1, 0, 0);
886
- tcanvasctx.canvas.width = rw;
887
- tcanvasctx.canvas.height = rh;
888
- tcanvasctx.rotate((obj.rotation * -90) * Math.PI / 180);
889
- if (obj.rotation == 0) tcanvasctx.drawImage(obj.Canvas.canvas, 0, 0);
890
- if (obj.rotation == 1) tcanvasctx.drawImage(obj.Canvas.canvas, -obj.Canvas.canvas.width, 0);
891
- if (obj.rotation == 2) tcanvasctx.drawImage(obj.Canvas.canvas, -obj.Canvas.canvas.width, -obj.Canvas.canvas.height);
892
- if (obj.rotation == 3) tcanvasctx.drawImage(obj.Canvas.canvas, 0, -obj.Canvas.canvas.height);
893
-
894
- // Change the size and orientation and copy the canvas back into the rotation
895
- if (obj.rotation == 0 || obj.rotation == 2) { obj.Canvas.canvas.height = rw; obj.Canvas.canvas.width = rh; }
896
- if (obj.rotation == 1 || obj.rotation == 3) { obj.Canvas.canvas.height = rh; obj.Canvas.canvas.width = rw; }
897
- obj.Canvas.setTransform(1, 0, 0, 1, 0, 0);
898
- obj.Canvas.rotate((newrotation * 90) * Math.PI / 180);
899
- obj.rotation = newrotation;
900
- obj.Canvas.drawImage(obj.tcanvas, obj.rotX(0, 0), obj.rotY(0, 0));
901
-
902
- obj.ScreenWidth = obj.Canvas.canvas.width;
903
- obj.ScreenHeight = obj.Canvas.canvas.height;
904
- if (obj.onScreenSizeChange != null) { console.log('s4', obj.ScreenWidth, obj.ScreenHeight); obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
905
- return true;
906
- }
907
-
908
- obj.StartRecording = function () {
909
- if (obj.recordedData != null) return;
910
- // Take a screen shot and save it to file
911
- obj.CanvasId['toBlob'](function (blob) {
912
- var fileReader = new FileReader();
913
- fileReader.readAsArrayBuffer(blob);
914
- fileReader.onload = function (event) {
915
- // This is an ArrayBuffer, convert it to a string array
916
- var binary = '', bytes = new Uint8Array(fileReader.result), length = bytes.byteLength;
917
- for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
918
- obj.recordedData = [];
919
- obj.recordedStart = Date.now();
920
- obj.recordedSize = 0;
921
- obj.recordedData.push(recordingEntry(1, 0, JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, time: new Date().toLocaleString(), protocol: 2 }))); // Metadata (nodeid: obj.nodeid)
922
- obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(7) + obj.shortToStr(8) + obj.shortToStr(obj.ScreenWidth) + obj.shortToStr(obj.ScreenHeight))); // Screen width and height
923
- // Save a screenshot
924
- var cmdlen = (8 + binary.length);
925
- if (cmdlen > 65000) {
926
- // Jumbo Packet
927
- obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(27) + obj.shortToStr(8) + obj.intToStr(cmdlen) + obj.shortToStr(3) + obj.shortToStr(0) + obj.shortToStr(0) + obj.shortToStr(0) + binary));
928
- } else {
929
- // Normal packet
930
- obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(3) + obj.shortToStr(cmdlen) + obj.shortToStr(0) + obj.shortToStr(0) + binary));
931
- }
932
- };
933
- });
934
- }
935
-
936
- obj.StopRecording = function () {
937
- if (obj.recordedData == null) return;
938
- var r = obj.recordedData;
939
- r.push(recordingEntry(3, 0, 'MeshCentralMCREC'));
940
- delete obj.recordedData;
941
- delete obj.recordedStart;
942
- delete obj.recordedSize;
943
- return r;
944
- }
945
-
946
- function recordingEntry(type, flags, data) {
947
- // Header: Type (2) + Flags (2) + Size(4) + Time(8)
948
- // Type (1 = Header, 2 = Network Data), Flags (1 = Binary, 2 = User), Size (4 bytes), Time (8 bytes)
949
- var now = Date.now();
950
- if (typeof data == 'number') {
951
- obj.recordedSize += data;
952
- return obj.shortToStr(type) + obj.shortToStr(flags) + obj.intToStr(data) + obj.intToStr(now >> 32) + obj.intToStr(now & 32);
953
- } else {
954
- obj.recordedSize += data.length;
955
- return obj.shortToStr(type) + obj.shortToStr(flags) + obj.intToStr(data.length) + obj.intToStr(now >> 32) + obj.intToStr(now & 32) + data;
956
- }
957
- }
958
-
959
- // Private method
960
- obj.MuchTheSame = function (a, b) { return (Math.abs(a - b) < 4); }
961
- obj.Debug = function (msg) { console.log(msg); }
962
- obj.getIEVersion = function () { var r = -1; if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"); if (re.exec(ua) != null) r = parseFloat(RegExp.$1); } return r; }
963
- obj.haltEvent = function (e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
964
-
965
- return obj;
966
-}
\ No newline at end of file
1
+function isWindowsBrowser(){return navigator&&!!/win/i.exec(navigator.platform)}Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,t){return new Uint8Array(Array.prototype.slice.call(this,e,t))}});var CreateAgentRemoteDesktop=function(e,t){var p={},S=("string"==typeof(p.CanvasId=e)&&(p.CanvasId=Q(e)),p.Canvas=p.CanvasId.getContext("2d"),p.scrolldiv=t,p.State=0,p.PendingOperations=[],p.tilesReceived=0,p.TilesDrawn=0,p.KillDraw=0,p.ipad=!1,p.tabletKeyboardVisible=!1,p.LastX=0,p.LastY=0,p.touchenabled=0,p.submenuoffset=0,p.touchtimer=null,p.TouchArray={},p.connectmode=0,p.connectioncount=0,p.rotation=0,p.protocol=2,p.debugmode=0,p.firstUpKeys=[],p.stopInput=!1,p.localKeyMap=!0,p.remoteKeyMap=!1,p.pressedKeys=[],p._altGrArmed=!1,p._altGrTimeout=0,p.isWindowsBrowser=isWindowsBrowser(),p.sessionid=0,p.oldie=!1,p.ImageType=1,p.CompressionLevel=50,p.ScalingLevel=1024,p.FrameRateTimer=100,p.SwapMouse=!1,p.UseExtendedKeyFlag=!0,p.FirstDraw=!1,p.onRemoteInputLockChanged=null,p.RemoteInputLock=null,p.onKeyboardStateChanged=null,p.KeyboardState=0,p.ScreenWidth=960,p.ScreenHeight=701,p.width=960,p.height=960,p.displays=null,p.selectedDisplay=null,p.onScreenSizeChange=null,p.onMessage=null,p.onConnectCountChanged=null,p.onDebugMessage=null,p.onTouchEnabledChanged=null,p.onDisplayinfo=null,!(p.accumulator=null)),v="default",C=(p.mouseCursorActive=function(e){S!=e&&(S=e,p.CanvasId.style.cursor=1==e?v:"default")},["default","progress","crosshair","pointer","help","text","no-drop","move","nesw-resize","ns-resize","nwse-resize","w-resize","alias","wait","none","not-allowed","col-resize","row-resize","copy","zoom-in","zoom-out"]),a=(p.Start=function(){p.State=0,p.accumulator=null},p.Stop=function(){p.setRotation(0),p.UnGrabKeyInput(),p.UnGrabMouseInput(),p.touchenabled=0,null!=p.onScreenSizeChange&&p.onScreenSizeChange(p,p.ScreenWidth,p.ScreenHeight,p.CanvasId),p.Canvas.clearRect(0,0,p.CanvasId.width,p.CanvasId.height)},p.xxStateChange=function(e){p.State!=e&&(p.State=e,p.CanvasId.style.cursor="default",0===e)&&p.Stop()},p.send=function(e){2<p.debugmode&&console.log("KSend("+e.length+"): "+rstr2hex(e)),null!=p.parent&&p.parent.send(e)},p.ProcessPictureMsg=function(e,t,n){for(var o=new Image,a=(o.xcount=p.tilesReceived++,p.tilesReceived),r=e.slice(4),s=0,i=[];5e4<r.byteLength-s;)i.push(String.fromCharCode.apply(null,r.slice(s,s+5e4))),s+=5e4;i.push(0<s?String.fromCharCode.apply(null,r.slice(s)):String.fromCharCode.apply(null,r)),o.src="data:image/jpeg;base64,"+btoa(i.join("")),o.onload=function(){if(null!=p.Canvas&&p.KillDraw<a&&0!=p.State)for(p.PendingOperations.push([a,2,o,t,n]);p.DoPendingOperations(););else p.PendingOperations.push([a,0])},o.error=function(){console.log("DecodeTileError")}},p.DoPendingOperations=function(){if(0!=p.PendingOperations.length){for(var e=0;e<p.PendingOperations.length;e++){var t=p.PendingOperations[e];if(t[0]==p.TilesDrawn+1)return null!=p.onPreDrawImage&&p.onPreDrawImage(),1==t[1]?p.ProcessCopyRectMsg(t[2]):2==t[1]&&(p.Canvas.drawImage(t[2],p.rotX(t[3],t[4]),p.rotY(t[3],t[4])),delete t[2]),p.PendingOperations.splice(e,1),p.TilesDrawn++,p.TilesDrawn==p.tilesReceived&&p.KillDraw<p.TilesDrawn&&(p.KillDraw=p.TilesDrawn=p.tilesReceived=0),!0}p.oldie&&0<p.PendingOperations.length&&p.TilesDrawn++}return!1},p.ProcessCopyRectMsg=function(e){var t=((255&e.charCodeAt(0))<<8)+(255&e.charCodeAt(1)),n=((255&e.charCodeAt(2))<<8)+(255&e.charCodeAt(3)),o=((255&e.charCodeAt(4))<<8)+(255&e.charCodeAt(5)),a=((255&e.charCodeAt(6))<<8)+(255&e.charCodeAt(7)),r=((255&e.charCodeAt(8))<<8)+(255&e.charCodeAt(9)),e=((255&e.charCodeAt(10))<<8)+(255&e.charCodeAt(11));p.Canvas.drawImage(Canvas.canvas,t,n,r,e,o,a,r,e)},p.SendUnPause=function(){1<p.debugmode&&console.log("SendUnPause"),p.send(String.fromCharCode(0,8,0,5,0))},p.SendPause=function(){1<p.debugmode&&console.log("SendPause"),p.send(String.fromCharCode(0,8,0,5,1))},p.SendCompressionLevel=function(e,t,n,o){p.ImageType=e,t&&(p.CompressionLevel=t),n&&(p.ScalingLevel=n),o&&(p.FrameRateTimer=o),p.send(String.fromCharCode(0,5,0,10,e,p.CompressionLevel)+p.shortToStr(p.ScalingLevel)+p.shortToStr(p.FrameRateTimer))},p.SendRefresh=function(){p.send(String.fromCharCode(0,6,0,4))},p.ProcessScreenMsg=function(e,t){if(0<p.debugmode&&console.log("ScreenSize: "+e+" x "+t),p.ScreenWidth!=e||p.ScreenHeight!=t){for(p.Canvas.setTransform(1,0,0,1,0,0),p.rotation=0,p.FirstDraw=!0,p.ScreenWidth=p.width=e,p.ScreenHeight=p.height=t,p.KillDraw=p.tilesReceived;0<p.PendingOperations.length;)p.PendingOperations.shift();p.SendCompressionLevel(p.ImageType),p.SendUnPause(),p.SendRemoteInputLock(2),null!=p.onScreenSizeChange&&p.onScreenSizeChange(p,p.ScreenWidth,p.ScreenHeight,p.CanvasId)}},p.ProcessBinaryCommand=function(e,t,n){var o,a;3!=e&&4!=e&&7!=e||(o=(n[4]<<8)+n[5],a=(n[6]<<8)+n[7]),2<p.debugmode&&console.log("CMD",e,t,o,a);let r="";for(let e=0;e<n.length;e+=1e4)r+=String.fromCharCode.apply(null,n.slice(e,e+1e4));switch(null!=p.recordedData&&(65e3<t?p.recordedData.push(f(2,1,p.shortToStr(27)+p.shortToStr(8)+p.intToStr(t)+p.shortToStr(e)+p.shortToStr(0)+p.shortToStr(0)+p.shortToStr(0)+r)):p.recordedData.push(f(2,1,r))),e){case 3:p.FirstDraw&&p.onResize(),p.ProcessPictureMsg(n.slice(4),o,a);break;case 7:p.ProcessScreenMsg(o,a),p.SendKeyMsgKC(p.KeyAction.UP,16),p.SendKeyMsgKC(p.KeyAction.UP,17),p.SendKeyMsgKC(p.KeyAction.UP,18),p.SendKeyMsgKC(p.KeyAction.UP,91),p.SendKeyMsgKC(p.KeyAction.UP,92),p.SendKeyMsgKC(p.KeyAction.UP,16),p.send(String.fromCharCode(0,14,0,4));break;case 11:var s=0,i={},c=(n[4]<<8)+n[5];if(0<c)for(var s=(n[6+2*c]<<8)+n[7+2*c],u=0;u<c;u++){var l=(n[6+2*u]<<8)+n[7+2*u];i[l]=65535==l?"All Displays":"Display "+l}p.displays=i,p.selectedDisplay=s,null!=p.onDisplayinfo&&p.onDisplayinfo(p,i,s);break;case 12:break;case 14:p.touchenabled=1,p.TouchArray={},null!=p.onTouchEnabledChanged&&p.onTouchEnabledChanged(p.touchenabled);break;case 15:p.TouchArray={};break;case 17:var d=String.fromCharCode.apply(null,n.slice(4));console.log("Got KVM Message: "+d),null!=p.onMessage&&p.onMessage(d,p);break;case 18:5==t&&p.KeyboardState!=n[4]&&(p.KeyboardState=n[4],p.onKeyboardStateChanged&&p.onKeyboardStateChanged(p,p.KeyboardState),console.log("MNG_KVM_KEYSTATE:"+(1&p.KeyboardState?" NumLock":"")+(2&p.KeyboardState?" ScrollLock":"")+(4&p.KeyboardState?" CapsLock":"")));break;case 65:"."!=(d=String.fromCharCode.apply(null,n.slice(4)))[0]?(console.log(d),p.parent&&p.parent.setConsoleMessage&&p.parent.setConsoleMessage(d)):console.log("KVM: "+d.substring(1));break;case 82:if(!(t<4||(t-4)%10!=0))for(var h=(t-4)/10,g=4,u=0;u<h;u++)(n[g+0]<<8)+n[g+1],g+=10;break;case 87:5!=t||null!=p.RemoteInputLock&&p.RemoteInputLock===(0!=n[4])||(p.RemoteInputLock=0!=n[4],p.onRemoteInputLockChanged&&p.onRemoteInputLockChanged(p,p.RemoteInputLock));break;case 88:5!=t||p.stopInput||(s=n[4],v=C[s=C.length<s?0:s],S&&(p.CanvasId.style.cursor=v));break;default:console.log("Unknown command",e,t)}},p.MouseButton={NONE:0,LEFT:2,RIGHT:8,MIDDLE:32},p.KeyAction={NONE:0,DOWN:1,UP:2,SCROLL:3,EXUP:4,EXDOWN:5,DBLCLICK:6},p.InputType={KEY:1,MOUSE:2,CTRLALTDEL:10,TOUCH:15,KEYUNICODE:85},p.Alternate=0,{Pause:19,CapsLock:20,Space:32,Quote:222,Minus:189,NumpadMultiply:106,NumpadAdd:107,PrintScreen:44,Comma:188,NumpadSubtract:109,NumpadDecimal:110,Period:190,Slash:191,NumpadDivide:111,Semicolon:186,Equal:187,OSLeft:91,BracketLeft:219,OSRight:91,Backslash:220,BracketRight:221,ContextMenu:93,Backquote:192,NumLock:144,ScrollLock:145,Backspace:8,Tab:9,Enter:13,NumpadEnter:13,Escape:27,Delete:46,Home:36,PageUp:33,PageDown:34,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,End:35,Insert:45,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,MetaLeft:91,MetaRight:92,VolumeMute:181});var r=["ShiftRight","AltRight","ControlRight","Home","End","Insert","Delete","PageUp","PageDown","NumpadDivide","NumpadEnter","NumLock","Pause"];p.SendKeyMsg=function(e,t){var n,o;null==e||(t=t||window.event,n=!1,(p.UseExtendedKeyFlag||1==urlargs.extkeys)&&"string"==typeof t.code&&(t.code.startsWith("Arrow")||0<=r.indexOf(t.code))&&(n=!0),p.isWindowsBrowser&&p.checkAltGr(p,t,e))||(0==n&&t.code&&0==t.code.startsWith("NumPad")&&0==p.localKeyMap?null!=(o=(o=t).code.startsWith("Key")&&4==o.code.length?o.code.charCodeAt(3):o.code.startsWith("Digit")&&6==o.code.length?o.code.charCodeAt(5):o.code.startsWith("Numpad")&&7==o.code.length?o.code.charCodeAt(6)+48:a[o.code])&&p.SendKeyMsgKC(e,o,n):(59==(o=t.keyCode)?o=186:173==o?o=189:61==o&&(o=187),p.SendKeyMsgKC(e,o,n)))};function f(e,t,n){var o=Date.now();return"number"==typeof n?(p.recordedSize+=n,p.shortToStr(e)+p.shortToStr(t)+p.intToStr(n)+p.intToStr(o>>32)+p.intToStr(32&o)):(p.recordedSize+=n.length,p.shortToStr(e)+p.shortToStr(t)+p.intToStr(n.length)+p.intToStr(o>>32)+p.intToStr(32&o)+n)}return p.checkAltGr=function(e,t,n){return e._altGrArmed&&(e._altGrArmed=!1,clearTimeout(e._altGrTimeout),"AltRight"===t.code)&&t.timeStamp-e._altGrCtrlTime<50?(e.SendKeyMsgKC(n,225,!1),!0):!("ControlLeft"!==t.code||17 in e.pressedKeys||(e._altGrArmed=!0,e._altGrCtrlTime=t.timeStamp,1!=n)||(e._altGrTimeout=setTimeout(e._handleAltGrTimeout.bind(e),100),0))},p._handleAltGrTimeout=function(){p._altGrArmed=!1,clearTimeout(p._altGrTimeout),p.SendKeyMsgKC(1,17,!1)},p.SendRemoteInputLock=function(e){p.send(String.fromCharCode(0,87,0,5,e))},p.SendMessage=function(e){3==p.State&&p.send(String.fromCharCode(0,17)+p.shortToStr(4+e.length)+e)},p.SendKeyMsgKC=function(e,t,n){if(3==p.State)if("object"==typeof e)for(var o in e)p.SendKeyMsgKC(e[o][0],e[o][1],e[o][2]);else{1==e?-1==p.pressedKeys.indexOf(t)&&p.pressedKeys.unshift(t):2==e&&-1!=(o=p.pressedKeys.indexOf(t))&&p.pressedKeys.splice(o,1),0<p.debugmode&&console.log("Sending Key "+t+", action "+e);var a=e-1;n&&(a=1==a?3:4),p.send(String.fromCharCode(0,p.InputType.KEY,0,6,a,t))}},p.SendStringUnicode=function(e){if(3==p.State)for(var t=0;t<e.length;t++)p.send(String.fromCharCode(0,p.InputType.KEYUNICODE,0,7,0)+ShortToStr(e.charCodeAt(t))),p.send(String.fromCharCode(0,p.InputType.KEYUNICODE,0,7,1)+ShortToStr(e.charCodeAt(t)))},p.SendKeyUnicode=function(e,t){3==p.State&&(0<p.debugmode&&console.log("Sending UnicodeKey "+t+", action "+e),p.send(String.fromCharCode(0,p.InputType.KEYUNICODE,0,7,e-1)+ShortToStr(t)))},p.sendcad=function(){p.SendCtrlAltDelMsg()},p.SendCtrlAltDelMsg=function(){3==p.State&&p.send(String.fromCharCode(0,p.InputType.CTRLALTDEL,0,4))},p.SendEscKey=function(){3==p.State&&p.send(String.fromCharCode(0,p.InputType.KEY,0,6,0,27,0,p.InputType.KEY,0,6,1,27))},p.SendStartMsg=function(){p.SendKeyMsgKC(p.KeyAction.EXDOWN,91),p.SendKeyMsgKC(p.KeyAction.EXUP,91)},p.SendCharmsMsg=function(){p.SendKeyMsgKC(p.KeyAction.EXDOWN,91),p.SendKeyMsgKC(p.KeyAction.DOWN,67),p.SendKeyMsgKC(p.KeyAction.UP,67),p.SendKeyMsgKC(p.KeyAction.EXUP,91)},p.SendTouchMsg1=function(e,t,n,o){3==p.State&&p.send(String.fromCharCode(0,p.InputType.TOUCH)+p.shortToStr(14)+String.fromCharCode(1,e)+p.intToStr(t)+p.shortToStr(n)+p.shortToStr(o))},p.SendTouchMsg2=function(e,t){var n,o,a="";for(o in p.TouchArray)o==e?n=t:1==p.TouchArray[o].f?(n=65542,p.TouchArray[o].f=3,0):2==p.TouchArray[o].f?(n=262144,0):n=131078,a+=String.fromCharCode(o)+p.intToStr(n)+p.shortToStr(p.TouchArray[o].x)+p.shortToStr(p.TouchArray[o].y),2==p.TouchArray[o].f&&delete p.TouchArray[o];3==p.State&&p.send(String.fromCharCode(0,p.InputType.TOUCH)+p.shortToStr(5+a.length)+String.fromCharCode(2)+a),0==Object.keys(p.TouchArray).length&&null!=p.touchtimer&&(clearInterval(p.touchtimer),p.touchtimer=null)},p.SendMouseMsg=function(e,t){var n,o,a,r,s,i;3==p.State&&null!=e&&null!=p.Canvas&&(t=t||window.event,a=p.Canvas.canvas.height/p.CanvasId.clientHeight,n=p.Canvas.canvas.width/p.CanvasId.clientWidth,o=p.GetPositionOfControl(p.Canvas.canvas),n=(t.pageX-o[0])*n,o=(t.pageY-o[1])*a,t.addx&&(n+=t.addx),t.addy&&(o+=t.addy),0<=n)&&n<=p.Canvas.canvas.width&&0<=o&&o<=p.Canvas.canvas.height&&(r=a=0,e==p.KeyAction.UP||e==p.KeyAction.DOWN?t.which?a=1==t.which?p.MouseButton.LEFT:2==t.which?p.MouseButton.MIDDLE:p.MouseButton.RIGHT:"number"==typeof t.button&&(a=0==t.button?p.MouseButton.LEFT:1==t.button?p.MouseButton.MIDDLE:p.MouseButton.RIGHT):e==p.KeyAction.SCROLL&&(t.detail?r=120*t.detail*-1:t.wheelDelta&&(r=3*t.wheelDelta)),!0===p.SwapMouse&&(a==p.MouseButton.LEFT?a=p.MouseButton.RIGHT:a==p.MouseButton.RIGHT&&(a=p.MouseButton.LEFT)),p.ReverseMouseWheel&&(r*=-1),t="",t=e==p.KeyAction.DBLCLICK?String.fromCharCode(0,p.InputType.MOUSE,0,10,0,136,n/256&255,255&n,o/256&255,255&o):e==p.KeyAction.SCROLL?(i=r<(i=s=0)?(s=255-(Math.abs(r)>>8),255-(255&Math.abs(r))):(s=r>>8,255&r),String.fromCharCode(0,p.InputType.MOUSE,0,12,0,0,n/256&255,255&n,o/256&255,255&o,s,i)):String.fromCharCode(0,p.InputType.MOUSE,0,10,0,e==p.KeyAction.DOWN?a:2*a&255,n/256&255,255&n,o/256&255,255&o),p.Action==p.KeyAction.NONE?0==p.Alternate||p.ipad?(p.send(t),p.Alternate=1):p.Alternate=0:p.send(t))},p.GetDisplayNumbers=function(){p.send(String.fromCharCode(0,11,0,4))},p.SetDisplay=function(e){p.send(String.fromCharCode(0,12,0,6,e>>8,255&e))},p.intToStr=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},p.shortToStr=function(e){return String.fromCharCode(e>>8&255,255&e)},p.onResize=function(){0==p.ScreenWidth||0==p.ScreenHeight||p.Canvas.canvas.width==p.ScreenWidth&&p.Canvas.canvas.height==p.ScreenHeight||(p.FirstDraw&&(p.Canvas.canvas.width=p.ScreenWidth,p.Canvas.canvas.height=p.ScreenHeight,p.Canvas.fillRect(0,0,p.ScreenWidth,p.ScreenHeight),null!=p.onScreenSizeChange)&&p.onScreenSizeChange(p,p.ScreenWidth,p.ScreenHeight,p.CanvasId),p.FirstDraw=!1,1<p.debugmode&&console.log("onResize: "+p.ScreenWidth+" x "+p.ScreenHeight))},p.xxMouseInputGrab=!1,p.xxKeyInputGrab=!1,p.xxMouseMove=function(e){return 3==p.State&&p.SendMouseMsg(p.KeyAction.NONE,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxMouseUp=function(e){return 3==p.State&&p.SendMouseMsg(p.KeyAction.UP,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxMouseDown=function(e){return 3==p.State&&p.SendMouseMsg(p.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxMouseDblClick=function(e){return 3==p.State&&p.SendMouseMsg(p.KeyAction.DBLCLICK,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxDOMMouseScroll=function(e){return 3!=p.State||(p.SendMouseMsg(p.KeyAction.SCROLL,e),!1)},p.xxMouseWheel=function(e){return 3!=p.State||(p.SendMouseMsg(p.KeyAction.SCROLL,e),!1)},p.xxKeyUp=function(e){return"Dead"!=e.key&&3==p.State&&("string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&0==p.remoteKeyMap?p.SendKeyUnicode(p.KeyAction.UP,e.key.charCodeAt(0)):p.SendKeyMsg(p.KeyAction.UP,e)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxKeyDown=function(e){if("Dead"!=e.key&&3==p.State&&("string"!=typeof e.key||1!=e.key.length||1==e.ctrlKey||1==e.altKey||0!=p.remoteKeyMap))return p.SendKeyMsg(p.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.xxKeyPress=function(e){return"Dead"!=e.key&&3==p.State&&"string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&0==p.remoteKeyMap&&p.SendKeyUnicode(p.KeyAction.DOWN,e.key.charCodeAt(0)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p.handleKeys=function(e){return 1!=p.stopInput&&3==desktop.State&&p.xxKeyPress(e)},p.handleKeyUp=function(e){var t;return 1!=p.stopInput&&3==desktop.State&&(p.firstUpKeys.length<5&&(p.firstUpKeys.push(e.keyCode),5!=p.firstUpKeys.length||"16,17,91,91,16"!=(t=p.firstUpKeys.join(","))&&"16,17,18,91,92"!=t||(p.stopInput=!0)),p.xxKeyUp(e))},p.handleKeyDown=function(e){return 1!=p.stopInput&&3==desktop.State&&p.xxKeyDown(e)},p.handleReleaseKeys=function(){var e,t=JSON.parse(JSON.stringify(p.pressedKeys));for(e in t)p.SendKeyMsgKC(p.KeyAction.UP,t[e])},p.mousedblclick=function(e){return 1!=p.stopInput&&p.xxMouseDblClick(e)},p.mousedown=function(e){return 1!=p.stopInput&&p.xxMouseDown(e)},p.mouseup=function(e){return 1!=p.stopInput&&p.xxMouseUp(e)},p.mousemove=function(e){return 1!=p.stopInput&&p.xxMouseMove(e)},p.mousewheel=function(e){return 1!=p.stopInput&&p.xxMouseWheel(e)},p.xxMsTouchEvent=function(e){var t,n,o,a;if(4!=e.originalEvent.pointerType)return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),"MSPointerDown"==e.type||"MSPointerMove"==e.type||"MSPointerUp"==e.type?(t=0,n=e.originalEvent.pointerId%256,o=e.offsetX*(Canvas.canvas.width/p.CanvasId.clientWidth),a=e.offsetY*(Canvas.canvas.height/p.CanvasId.clientHeight),"MSPointerDown"==e.type?t=65542:"MSPointerMove"==e.type?t=131078:"MSPointerUp"==e.type&&(t=262144),p.TouchArray[n]||(p.TouchArray[n]={x:o,y:a}),p.SendTouchMsg2(n,t),"MSPointerUp"==e.type&&delete p.TouchArray[n]):alert(e.type),!0},p.xxTouchStart=function(e){if(3==p.State)if(e.preventDefault&&e.preventDefault(),0==p.touchenabled||1==p.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,p.LastX=e.pageX=t.pageX,p.LastY=e.pageY=t.pageY,p.SendMouseMsg(KeyAction.DOWN,e))}else{var n,o,a=p.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,p.TouchArray[o]||(p.TouchArray[o]={x:(e.originalEvent.touches[n].pageX-a[0])*(Canvas.canvas.width/p.CanvasId.clientWidth),y:(e.originalEvent.touches[n].pageY-a[1])*(Canvas.canvas.height/p.CanvasId.clientHeight),f:1}));0<Object.keys(p.TouchArray).length&&null==touchtimer&&(p.touchtimer=setInterval(function(){p.SendTouchMsg2(256,0)},50))}},p.xxTouchMove=function(e){if(3==p.State)if(e.preventDefault&&e.preventDefault(),0==p.touchenabled||1==p.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,p.LastX=e.pageX=t.pageX,p.LastY=e.pageY=t.pageY,p.SendMouseMsg(p.KeyAction.NONE,e))}else{var n,o,a=p.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,p.TouchArray[o])&&(p.TouchArray[o].x=(e.originalEvent.touches[n].pageX-a[0])*(p.Canvas.canvas.width/p.CanvasId.clientWidth),p.TouchArray[o].y=(e.originalEvent.touches[n].pageY-a[1])*(p.Canvas.canvas.height/p.CanvasId.clientHeight))}},p.xxTouchEnd=function(e){if(3==p.State)if(e.preventDefault&&e.preventDefault(),0==p.touchenabled||1==p.touchenabled)1<e.originalEvent.touches.length||(e.which=1,e.pageX=LastX,e.pageY=LastY,p.SendMouseMsg(KeyAction.UP,e));else for(var t in e.originalEvent.changedTouches)e.originalEvent.changedTouches[t].identifier&&(t=e.originalEvent.changedTouches[t].identifier%256,p.TouchArray[t])&&(p.TouchArray[t].f=2)},p.GrabMouseInput=function(){var e;1!=p.xxMouseInputGrab&&((e=p.CanvasId).onmousemove=p.xxMouseMove,e.onmouseup=p.xxMouseUp,e.onmousedown=p.xxMouseDown,e.touchstart=p.xxTouchStart,e.touchmove=p.xxTouchMove,e.touchend=p.xxTouchEnd,e.MSPointerDown=p.xxMsTouchEvent,e.MSPointerMove=p.xxMsTouchEvent,e.MSPointerUp=p.xxMsTouchEvent,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=p.xxDOMMouseScroll:e.onmousewheel=p.xxMouseWheel,p.xxMouseInputGrab=!0)},p.UnGrabMouseInput=function(){var e;0!=p.xxMouseInputGrab&&((e=p.CanvasId).onmousemove=null,e.onmouseup=null,e.onmousedown=null,e.touchstart=null,e.touchmove=null,e.touchend=null,e.MSPointerDown=null,e.MSPointerMove=null,e.MSPointerUp=null,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=null:e.onmousewheel=null,p.xxMouseInputGrab=!1)},p.GrabKeyInput=function(){1!=p.xxKeyInputGrab&&(document.onkeyup=p.xxKeyUp,document.onkeydown=p.xxKeyDown,document.onkeypress=p.xxKeyPress,c,p.xxKeyInputGrab=!0)},p.UnGrabKeyInput=function(){0!=p.xxKeyInputGrab&&(document.onkeyup=null,document.onkeydown=null,document.onkeypress=null,p.xxKeyInputGrab=!1)},p.GetPositionOfControl=function(e){var t=Array(2);for(t[0]=t[1]=0;e;)t[0]+=e.offsetLeft,t[1]+=e.offsetTop,e=e.offsetParent;return t},p.crotX=function(e,t){return 0==p.rotation?e:1==p.rotation?t:2==p.rotation?p.Canvas.canvas.width-e:3==p.rotation?p.Canvas.canvas.height-t:void 0},p.crotY=function(e,t){return 0==p.rotation?t:1==p.rotation?p.Canvas.canvas.width-e:2==p.rotation?p.Canvas.canvas.height-t:3==p.rotation?e:void 0},p.rotX=function(e,t){return 0==p.rotation||1==p.rotation?e:2==p.rotation?e-p.Canvas.canvas.width:3==p.rotation?e-p.Canvas.canvas.height:void 0},p.rotY=function(e,t){return 0==p.rotation||3==p.rotation?t:1==p.rotation?t-p.Canvas.canvas.width:2==p.rotation?t-p.Canvas.canvas.height:void 0},p.tcanvas=null,p.setRotation=function(e){for(;e<0;)e+=4;var t,n,o,a=e%4;return a!=p.rotation&&(t=p.Canvas.canvas.width,n=p.Canvas.canvas.height,1!=p.rotation&&3!=p.rotation||(t=p.Canvas.canvas.height,n=p.Canvas.canvas.width),null==p.tcanvas&&(p.tcanvas=document.createElement("canvas")),(o=p.tcanvas.getContext("2d")).setTransform(1,0,0,1,0,0),o.canvas.width=t,o.canvas.height=n,o.rotate(-90*p.rotation*Math.PI/180),0==p.rotation&&o.drawImage(p.Canvas.canvas,0,0),1==p.rotation&&o.drawImage(p.Canvas.canvas,-p.Canvas.canvas.width,0),2==p.rotation&&o.drawImage(p.Canvas.canvas,-p.Canvas.canvas.width,-p.Canvas.canvas.height),3==p.rotation&&o.drawImage(p.Canvas.canvas,0,-p.Canvas.canvas.height),0!=p.rotation&&2!=p.rotation||(p.Canvas.canvas.height=t,p.Canvas.canvas.width=n),1!=p.rotation&&3!=p.rotation||(p.Canvas.canvas.height=n,p.Canvas.canvas.width=t),p.Canvas.setTransform(1,0,0,1,0,0),p.Canvas.rotate(90*a*Math.PI/180),p.rotation=a,p.Canvas.drawImage(p.tcanvas,p.rotX(0,0),p.rotY(0,0)),p.ScreenWidth=p.Canvas.canvas.width,p.ScreenHeight=p.Canvas.canvas.height,null!=p.onScreenSizeChange)&&(console.log("s4",p.ScreenWidth,p.ScreenHeight),p.onScreenSizeChange(p,p.ScreenWidth,p.ScreenHeight,p.CanvasId)),!0},p.StartRecording=function(){null==p.recordedData&&p.CanvasId.toBlob(function(e){var s=new FileReader;s.readAsArrayBuffer(e),s.onload=function(e){for(var t="",n=new Uint8Array(s.result),o=n.byteLength,a=0;a<o;a++)t+=String.fromCharCode(n[a]);p.recordedData=[],p.recordedStart=Date.now(),p.recordedSize=0,p.recordedData.push(f(1,0,JSON.stringify({magic:"MeshCentralRelaySession",ver:1,time:(new Date).toLocaleString(),protocol:2}))),p.recordedData.push(f(2,1,p.shortToStr(7)+p.shortToStr(8)+p.shortToStr(p.ScreenWidth)+p.shortToStr(p.ScreenHeight)));var r=8+t.length;65e3<r?p.recordedData.push(f(2,1,p.shortToStr(27)+p.shortToStr(8)+p.intToStr(r)+p.shortToStr(3)+p.shortToStr(0)+p.shortToStr(0)+p.shortToStr(0)+t)):p.recordedData.push(f(2,1,p.shortToStr(3)+p.shortToStr(r)+p.shortToStr(0)+p.shortToStr(0)+t))}})},p.StopRecording=function(){var e;if(null!=p.recordedData)return(e=p.recordedData).push(f(3,0,"MeshCentralMCREC")),delete p.recordedData,delete p.recordedStart,delete p.recordedSize,e},p.MuchTheSame=function(e,t){return Math.abs(e-t)<4},p.Debug=function(e){console.log(e)},p.getIEVersion=function(){var e,t=-1;return t="Microsoft Internet Explorer"==navigator.appName&&(e=navigator.userAgent,null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(e))?parseFloat(RegExp.$1):t},p.haltEvent=function(e){return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},p}
\ No newline at end of file
public/scripts/agent-desktop-0.0.2.js
-1
@@ -155,7 +155,6 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
155
if (Msg[1] == 1) { obj.ProcessCopyRectMsg(Msg[2]); }
156
else if (Msg[1] == 2) { obj.Canvas.drawImage(Msg[2], obj.rotX(Msg[3], Msg[4]), obj.rotY(Msg[3], Msg[4])); delete Msg[2]; }
157
obj.PendingOperations.splice(i, 1);
158
- delete Msg;
158
obj.TilesDrawn++;
159
if ((obj.TilesDrawn == obj.tilesReceived) && (obj.KillDraw < obj.TilesDrawn)) { obj.KillDraw = obj.TilesDrawn = obj.tilesReceived = 0; }
160
return true;
translate/translate.js
+3
-1
@@ -64,6 +64,7 @@ var minifyMeshCentralSourceFiles = [
64
"../views/agentinvite.handlebars",
65
"../views/invite.handlebars",
66
"../views/default.handlebars",
67
+ "../views/default3.handlebars",
68
"../views/default-mobile.handlebars",
69
"../views/download.handlebars",
70
"../views/download2.handlebars",
@@ -452,7 +453,8 @@ function startEx(argv) {
453
removeScriptTypeAttributes: true,
454
removeTagWhitespace: true,
455
preserveLineBreaks: false,
455
- useShortDoctype: true
456
+ useShortDoctype: true,
457
+ log: function(a) { if (typeof a !== 'string') { console.log(a); } } // Log errors from UglifyJS to console output
458
});
459
} catch (ex) {
460
console.log(ex);
views/default-mobile.handlebars
+2
-2
@@ -1325,7 +1325,7 @@
1325
var logoutControls = JSON.parse(decodeURIComponent('{{{logoutControls}}}'));
1326
var authCookieRenewTimer = null;
1327
var webRelayPort = parseInt('{{{webRelayPort}}}');
1328
- var hidePowerTimeline = {{{hidePowerTimeline}}};
1328
+ var hidePowerTimeline = '{{{hidePowerTimeline}}}';
1329
var webRelayDns = '{{{webRelayDns}}}';
1330
var meshserver = null;
1331
var xdr = null;
@@ -4267,7 +4267,7 @@
4267
4268
// Draw device power bars. The bars are 766px wide.
4269
function drawDeviceTimeline() {
4270
- if (currentNode.mtype == 3 || hidePowerTimeline) { QH('p10html2', '<br />'); return; }
4270
+ if (currentNode.mtype == 3 || hidePowerTimeline === 'true') { QH('p10html2', '<br />'); return; }
4271
var timeline = null, now = Date.now();
4272
if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
4273
views/default.handlebars
+6
-6
@@ -1553,8 +1553,8 @@
1553
var sessionTime = parseInt('{{{sessiontime}}}');
1554
var webRelayPort = parseInt('{{{webRelayPort}}}');
1555
var webRelayDns = '{{{webRelayDns}}}';
1556
- var hidePowerTimeline = {{{hidePowerTimeline}}};
1557
- var showNotesPanel = {{{showNotesPanel}}};
1556
+ var hidePowerTimeline = '{{{hidePowerTimeline}}}';
1557
+ var showNotesPanel = '{{{showNotesPanel}}}';
1558
var sessionRefreshTimer = null;
1559
var domain = '{{{domain}}}';
1560
var domainUrl = '{{{domainurl}}}';
@@ -3027,7 +3027,7 @@
3027
}
3028
}else{
3029
Q('notesPanelArea').innerHTML = (message.notes && marked && DOMPurify) ? DOMPurify.sanitize(marked.parse(decodeURIComponent(message.notes), { breaks: true }), { USE_PROFILES: { html: true } }) : '';
3030
- if (showNotesPanel && message.notes) { QV('notesPanel',true); }else{ QV('notesPanel', false); }
3030
+ if ((showNotesPanel === 'true') && message.notes) { QV('notesPanel',true); }else{ QV('notesPanel', false); }
3031
}
3032
break;
3033
}
@@ -8243,7 +8243,7 @@
8243
if (noteid == null) { noteid = encodeURIComponentEx('p'+userinfo._id); }
8244
var x = '<textarea id=d2devNotes ro=' + readonly + ' noteid=' + noteid + ' readonly style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea>';
8245
if (noteid.startsWith('node%2F%2F')) { x += ' <span style=font-size:10px>' + "Device group notes can be viewed and changed by other device group administrators." + '</span>'; }
8246
- if (showNotesPanel) { x += ' <span style=font-size:10px><a target=_blank href=\'https://www.markdownguide.org/cheat-sheet/\'>' + "Markdown syntax supported" + '</a></span>'; }
8246
+ if (showNotesPanel === 'true') { x += ' <span style=font-size:10px><a target=_blank href=\'https://www.markdownguide.org/cheat-sheet/\'>' + "Markdown syntax supported" + '</a></span>'; }
8247
setDialogMode(2, "Notes", 3, showNotesEx, x, noteid);
8248
meshserver.send({ action: 'getNotes', id: decodeURIComponent(noteid) });
8249
}
@@ -8251,7 +8251,7 @@
8251
function showNotesEx(buttons, tag) {
8252
Q('notesPanelArea').innerHTML = (marked && DOMPurify) ? DOMPurify.sanitize(marked.parse(Q('d2devNotes').value, { breaks: true }), { USE_PROFILES: { html: true } }) : Q('d2devNotes').value;
8253
meshserver.send({ action: 'setNotes', id: decodeURIComponent(tag), notes: encodeURIComponentEx(Q('d2devNotes').value) });
8254
- if (showNotesPanel && Q('d2devNotes').value != '') { QV('notesPanel',true); }else{ QV('notesPanel', false); }
8254
+ if ((showNotesPanel === 'true') && Q('d2devNotes').value != '') { QV('notesPanel',true); }else{ QV('notesPanel', false); }
8255
}
8256
8257
function openIpKvmRemoteControl(nodeid) {
@@ -8672,7 +8672,7 @@
8672
8673
// Draw device power bars. The bars are 766px wide.
8674
function drawDeviceTimeline() {
8675
- if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19) || (currentNode.mtype == 3) || (hidePowerTimeline)) return;
8675
+ if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19) || (currentNode.mtype == 3) || (hidePowerTimeline === 'true')) return;
8676
var timeline = null, now = Date.now();
8677
if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
8678
views/default3.handlebars
+8
-8
@@ -1540,7 +1540,7 @@
1540
<div class="areaHead d-flex align-items-center flex-wrap p-1">
1541
<div class="d-flex align-items-center">
1542
<input value="Refresh" type="button" class="btn btn-primary btn-sm me-2" onclick="refreshServerTimelineStats()" />
1543
- <div class="form-check"><input class="form-check-input me-1" type=checkbox id=p40log onclick="updateServerTimelineHours()" / /><label class="form-check-label" for="p40log">Log-X</label></div>
1543
+ <div class="form-check"><input class="form-check-input me-1" type=checkbox id=p40log onclick="updateServerTimelineHours()" /><label class="form-check-label" for="p40log">Log-X</label></div>
1544
</div>
1545
<div class="toright2 d-flex align-items-center ms-auto">
1546
<select id=p40server style="display:none" onchange=updateServerTimelineStats()></select>
@@ -1980,8 +1980,8 @@
1980
var sessionTime = parseInt('{{{sessiontime}}}');
1981
var webRelayPort = parseInt('{{{webRelayPort}}}');
1982
var webRelayDns = '{{{webRelayDns}}}';
1983
- var hidePowerTimeline = {{{ hidePowerTimeline }}};
1984
- var showNotesPanel = {{{ showNotesPanel }}};
1983
+ var hidePowerTimeline = '{{{hidePowerTimeline}}}';
1984
+ var showNotesPanel = '{{{showNotesPanel}}}';
1985
var sessionRefreshTimer = null;
1986
var domain = '{{{domain}}}';
1987
var domainUrl = '{{{domainurl}}}';
@@ -2010,7 +2010,7 @@
2010
var footerBar = (getstore('footerBar', '1') == '1');
2011
var sessionActivity = Date.now();
2012
var updateSessionTimer = null;
2013
- var pluginHandlerBuilder = {{{ pluginHandler }}};
2013
+ var pluginHandlerBuilder = {{{pluginHandler}}};
2014
var pluginHandler = null;
2015
if (pluginHandlerBuilder != null) { pluginHandler = new pluginHandlerBuilder(); }
2016
var installedPluginList = null;
@@ -3482,7 +3482,7 @@
3482
}
3483
} else {
3484
Q('notesPanelArea').innerHTML = (message.notes && marked && DOMPurify) ? DOMPurify.sanitize(marked.parse(decodeURIComponent(message.notes), { breaks: true }), { USE_PROFILES: { html: true } }) : '';
3485
- if (showNotesPanel && message.notes) { QV('notesPanel', true); } else { QV('notesPanel', false); }
3485
+ if ((showNotesPanel === 'true') && message.notes) { QV('notesPanel', true); } else { QV('notesPanel', false); }
3486
}
3487
break;
3488
}
@@ -8919,7 +8919,7 @@
8919
if (noteid == null) { noteid = encodeURIComponentEx('p' + userinfo._id); }
8920
var x = '<textarea id=d2devNotes ro=' + readonly + ' noteid=' + noteid + ' readonly class="form-control" style=width:100%;height:200px;resize:none;overflow-y:scroll></textarea>';
8921
if (noteid.startsWith('node%2F%2F')) { x += '<span style=font-size:10px>' + "Device group notes can be viewed and changed by other device group administrators." + '<span>'; }
8922
- if (showNotesPanel) { x += ' <span style=font-size:10px><a target=_blank href=\'https://www.markdownguide.org/cheat-sheet/\'>' + "Markdown syntax supported" + '</a></span>'; }
8922
+ if (showNotesPanel === 'true') { x += ' <span style=font-size:10px><a target=_blank href=\'https://www.markdownguide.org/cheat-sheet/\'>' + "Markdown syntax supported" + '</a></span>'; }
8923
setModalContent('xxAddAgent', "Notes", x);
8924
showModal('xxAddAgentModal', 'idx_dlgOkButton', function () {
8925
showNotesEx(2, noteid);
@@ -8931,7 +8931,7 @@
8931
function showNotesEx(buttons, tag) {
8932
Q('notesPanelArea').innerHTML = (marked && DOMPurify) ? DOMPurify.sanitize(marked.parse(Q('d2devNotes').value, { breaks: true }), { USE_PROFILES: { html: true } }) : Q('d2devNotes').value;
8933
meshserver.send({ action: 'setNotes', id: decodeURIComponent(tag), notes: encodeURIComponentEx(Q('d2devNotes').value) });
8934
- if (showNotesPanel && Q('d2devNotes').value != '') { QV('notesPanel', true); } else { QV('notesPanel', false); }
8934
+ if ((showNotesPanel === 'true') && Q('d2devNotes').value != '') { QV('notesPanel', true); } else { QV('notesPanel', false); }
8935
}
8936
8937
function openIpKvmRemoteControl(nodeid) {
@@ -9376,7 +9376,7 @@
9376
9377
// Draw device power bars. The bars are 766px wide.
9378
function drawDeviceTimeline() {
9379
- if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19) || (currentNode.mtype == 3) || (hidePowerTimeline)) return;
9379
+ if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19) || (currentNode.mtype == 3) || (hidePowerTimeline === 'true')) return;
9380
var timeline = null, now = Date.now();
9381
if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
9382