Skip to content

Commit

Permalink
Cleanup/bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Dec 5, 2020
1 parent fc85913 commit 0ed6d86
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion html/mainPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h3>Scripting (beta)</h3>
<a href="#" onclick="clearPackets()">Clear</a>
<!-- <span id="hiddenPackets"></span> Removed for now -->
</div>
<div class="box clusterize-scroll">
<div class="box clusterize-scroll" id="packetcontainer">
<ul class="packetlist clusterize-content" id="packetlist">

</ul>
Expand Down
4 changes: 4 additions & 0 deletions html/mainPage/js/filteringLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets) {

const comparisonString = packet.hexIdString + ' ' + packet.meta.name + ' ' + JSON.stringify(packet.data)
return !comparisonString.includes(filter)
}

exports.packetCollapsed = function (packet, filter, hiddenPackets) {
return packet.meta.name === 'position'
}
14 changes: 12 additions & 2 deletions html/mainPage/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function wrappedClusterizeUpdate (htmlArray) {
for (const item of htmlArray) {
if (!item[0]
.match(/<li .* class=".*filter-hidden">/)) {

newArray.push(item)
}
}
Expand Down Expand Up @@ -337,12 +338,20 @@ window.openMenu = function (evt, MenuName, id) { // window. stops standardjs fro

document.body.addEventListener('contextmenu', (event) => {
let target = event.srcElement

if (target.tagName !== 'LI') {
target = target.parentElement
}

if (!target || target.tagName !== 'LI') {
return
};
}

// Don't allow right clicking in the filtering tab or on other places
if (target.parentElement.parentElement.id !== 'packetcontainer') {
return
}

sharedVars.ipcRenderer.send('contextMenu', JSON.stringify({
direction: target.className.split(' ')[1],
text: target.children[0].innerText + ' ' + target.children[1].innerText,
Expand All @@ -353,5 +362,6 @@ document.body.addEventListener('contextmenu', (event) => {
var clusterize = new Clusterize({
rows: sharedVars.allPacketsHTML,
scrollElem: sharedVars.packetList.parentElement,
contentElem: sharedVars.packetList
contentElem: sharedVars.packetList,
no_data_text: ''
})
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { app, BrowserWindow, ipcMain, clipboard, Menu } = require('electron')
app.allowRendererProcessReuse = true

const javaProxy = require('./proxy/java/proxy.js')
const bedrockProxy = require('./proxy/bedrock/proxy.js')
Expand All @@ -18,6 +19,11 @@ const osDataFolder = app.getPath('appData')
const dataFolder = setupDataFolder.setup(osDataFolder, resourcesPath)

function makeMenu (direction, text, id) {
if (direction !== 'clientbound' && direction !== 'serverbound') {
// This probably isn't a packet
return
}

let menuData = [
{
icon: resourcesPath + `icons/${direction}.png`,
Expand Down Expand Up @@ -142,7 +148,6 @@ ipcMain.on('copyToClipboard', (event, arg) => {

ipcMain.on('contextMenu', (event, arg) => {
const ipcMessage = JSON.parse(arg)
console.log(ipcMessage)
makeMenu(ipcMessage.direction, ipcMessage.text, ipcMessage.id).popup(BrowserWindow.getAllWindows()[0])
})

Expand Down
2 changes: 0 additions & 2 deletions src/packetHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ exports.init = function (window, passedIpcMain, passedProxy) {
ipcMain = passedIpcMain
proxy = passedProxy

console.log('init')

ipcMain.on('injectPacket', (event, arg) => {
const ipcMessage = JSON.parse(arg)
if (ipcMessage.direction === 'clientbound') {
Expand Down

0 comments on commit 0ed6d86

Please sign in to comment.