Skip to content

Commit

Permalink
Add section highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Dec 22, 2020
1 parent 5368cce commit b8af0ff
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion html/js/jsonTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function toHtml (element, text, isLabel) {
'</span>'
}

const maxLength = 75
const maxLength = 50

function compactView(json) {
let out = ''
Expand Down
29 changes: 28 additions & 1 deletion html/mainPage/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
Expand All @@ -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 = '<div style="padding: 10px;">Loading packet data...</div>';
Expand Down
4 changes: 4 additions & 0 deletions html/mainPage/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,7 @@ div.error {
font-size: 90%;
color: red;
}

.packet.selected {
background: rgba(64, 127, 255, 0.15);
}
2 changes: 1 addition & 1 deletion html/startPage/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/proxy/bedrock/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit b8af0ff

Please sign in to comment.