From b8af0ff84579baa567f80d7c8f099b5bd84c1d0b Mon Sep 17 00:00:00 2001 From: Heath123 Date: Tue, 22 Dec 2020 20:45:43 +0000 Subject: [PATCH] Add section highlight --- html/js/jsonTree.js | 2 +- html/mainPage/js/main.js | 29 ++++++++++++++++++++++++++++- html/mainPage/style.css | 4 ++++ html/startPage/script.js | 2 +- src/index.js | 2 -- src/proxy/bedrock/proxy.js | 7 +++++-- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/html/js/jsonTree.js b/html/js/jsonTree.js index 3aeabff..d695056 100644 --- a/html/js/jsonTree.js +++ b/html/js/jsonTree.js @@ -45,7 +45,7 @@ function toHtml (element, text, isLabel) { '' } -const maxLength = 75 +const maxLength = 50 function compactView(json) { let out = '' diff --git a/html/mainPage/js/main.js b/html/mainPage/js/main.js index 87ed8d1..52d691b 100644 --- a/html/mainPage/js/main.js +++ b/html/mainPage/js/main.js @@ -263,6 +263,7 @@ sharedVars.ipcRenderer.on('editAndResend', (event, arg) => { // Context menu }) function deselectPacket () { + removeOrAddSelection(currentPacket, false) currentPacket = undefined currentPacketType = undefined sharedVars.packetDom.getTreeElement().firstElementChild.innerHTML = 'No packet selected!' @@ -285,9 +286,35 @@ window.showAllPackets = function () { // window. stops standardjs from complaini const hexViewer = document.getElementById('hex-viewer') +function removeOrAddSelection (id, add) { + const fakeElement = document.createElement('div') + fakeElement.innerHTML = sharedVars.allPacketsHTML[currentPacket][0] + if (add) { + fakeElement.firstChild.classList.add('selected') + } else { + fakeElement.firstChild.classList.remove('selected') + } + sharedVars.allPacketsHTML[currentPacket] = [fakeElement.innerHTML] + + wrappedClusterizeUpdate(sharedVars.allPacketsHTML) + clusterize.refresh() +} + window.packetClick = function (id) { // window. stops standardjs from complaining + // Remove selection background from old selected packet + if (currentPacket) { + /* const previousPacket = document.getElementById('packet' + currentPacket) + // May not be in view + if (previousPacket) { + document.getElementById('packet' + currentPacket).classList.remove('selected') + } */ + removeOrAddSelection(currentPacket, false) + } + currentPacket = id - currentPacketType = document.getElementById('packet' + id).children[1].innerText + const element = document.getElementById('packet' + id) + currentPacketType = element.children[1].innerText + removeOrAddSelection(currentPacket, true) document.body.className = 'packetSelected' if (sharedVars.proxyCapabilities.jsonData) { // sidebar.innerHTML = '
Loading packet data...
'; diff --git a/html/mainPage/style.css b/html/mainPage/style.css index 6ac5c9d..da8ed54 100644 --- a/html/mainPage/style.css +++ b/html/mainPage/style.css @@ -254,3 +254,7 @@ div.error { font-size: 90%; color: red; } + +.packet.selected { + background: rgba(64, 127, 255, 0.15); +} \ No newline at end of file diff --git a/html/startPage/script.js b/html/startPage/script.js index 4e582ab..f1d3fe0 100644 --- a/html/startPage/script.js +++ b/html/startPage/script.js @@ -26,7 +26,7 @@ platformChange() loadSettings(platform) function loadSettings (newPlatform) { - loadSetting(newPlatform + 'LastVersion', 'version', 'version', '1.15.2') + loadSetting(newPlatform + 'LastVersion', 'version', 'version', '1.16.4') loadSetting(newPlatform + 'LastConnectAddress', 'connectAddress', 'connect-address', '127.0.0.1') loadSetting(newPlatform + 'LastConnectPort', 'connectPort', 'connect-port', platform === 'java' ? '25565' : '19132') loadSetting(newPlatform + 'LastListenPort', 'listenPort', 'listen-port', platform === 'java' ? '25566' : '19133') diff --git a/src/index.js b/src/index.js index fe389e5..1db92c4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,6 @@ const {app, BrowserWindow, ipcMain, clipboard, Menu} = require('electron') app.allowRendererProcessReuse = true -console.log('test') - const fs = require('fs') let proxy // Defined later when an option is chosen diff --git a/src/proxy/bedrock/proxy.js b/src/proxy/bedrock/proxy.js index c1f9924..818fed5 100644 --- a/src/proxy/bedrock/proxy.js +++ b/src/proxy/bedrock/proxy.js @@ -36,7 +36,8 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal // Poll for packets as the java module doesn't seem to support callbacks setInterval(function () { - for (const item of proxyPass.packetQueue.toArraySync()) { + const array = proxyPass.packetQueue.toArraySync() + for (const item of array) { const name = item.packetType.toStringSync().toLowerCase(); const data = JSON.parse(item.jsonData); @@ -58,7 +59,9 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal } exports.end = function () { - proxyPass.shutdownStaticSync(); + proxyPass.shutdownStatic(function(err, test) { + console.log(err, test) + }); } exports.writeToClient = function (meta, data) {