mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
Enhance CyberChef workstation popup with dynamic file loading
- Implemented dynamic CyberChef HTML file discovery - Added flexible iframe loading mechanism - Improved CSS for CyberChef container - Removed verbose console logging - Simplified workstation interaction logic
This commit is contained in:
44
index.html
44
index.html
@@ -87,6 +87,18 @@
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#cyberchef-container {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#cyberchef-container iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/easystarjs@0.4.4/bin/easystar-0.4.4.js"></script>
|
||||
@@ -204,7 +216,7 @@
|
||||
|
||||
// creates the workstation
|
||||
function addCryptoWorkstation() {
|
||||
console.log('CyberChef: Adding crypto workstation...');
|
||||
// console.log('CyberChef: Adding crypto workstation...');
|
||||
const workstationData = {
|
||||
type: "workstation",
|
||||
name: "Crypto Analysis Station",
|
||||
@@ -220,11 +232,11 @@
|
||||
|
||||
// Override the default handleObjectInteraction for this specific item
|
||||
workstationSprite.customInteraction = function() {
|
||||
console.log('CyberChef: Workstation custom interaction triggered');
|
||||
// console.log('CyberChef: Workstation custom interaction triggered');
|
||||
// Create popup
|
||||
let popup = document.getElementById('laptop-popup');
|
||||
if (!popup) {
|
||||
console.log('CyberChef: Creating new popup...');
|
||||
// console.log('CyberChef: Creating new popup...');
|
||||
popup = document.createElement('div');
|
||||
popup.id = 'laptop-popup';
|
||||
popup.innerHTML = `
|
||||
@@ -234,13 +246,33 @@
|
||||
<span>CryptoWorkstation</span>
|
||||
<button class="close-btn">×</button>
|
||||
</div>
|
||||
<iframe src="assets/cyberchef/CyberChef_v10.19.4.html" frameborder="0"></iframe>
|
||||
<div id="cyberchef-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(popup);
|
||||
|
||||
// Add close button handler
|
||||
// Find the CyberChef file
|
||||
fetch('assets/cyberchef/')
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
// Use regex to find the CyberChef filename
|
||||
const match = html.match(/CyberChef_v[0-9.]+\.html/);
|
||||
if (match) {
|
||||
const cyberchefPath = `assets/cyberchef/${match[0]}`;
|
||||
// Create and append the iframe with the found path
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = cyberchefPath;
|
||||
iframe.frameBorder = "0";
|
||||
document.getElementById('cyberchef-container').appendChild(iframe);
|
||||
} else {
|
||||
console.error('Could not find CyberChef file');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error loading CyberChef:', error);
|
||||
});
|
||||
|
||||
popup.querySelector('.close-btn').addEventListener('click', () => {
|
||||
popup.style.display = 'none';
|
||||
});
|
||||
@@ -251,7 +283,7 @@
|
||||
|
||||
// Add to inventory directly
|
||||
addToInventory(workstationSprite);
|
||||
console.log('CyberChef: Workstation added to inventory');
|
||||
// console.log('CyberChef: Workstation added to inventory');
|
||||
}
|
||||
|
||||
// creates the game
|
||||
|
||||
Reference in New Issue
Block a user