/* Function for managing game console */
function zoomIn() {
if (document.getElementById("myCanvas").width != 1200) {
document.getElementById("gameContainer").style.width = "100%"
document.getElementById("gameContainer").style.height = "100%";
document.getElementById("myCanvas").width = 1200;
document.getElementById("myCanvas").height = 800;
// document.getElementById("zoomInGameScreenInput").disabled = true;
// document.getElementById("zoomOutGameScreenInput").disabled = false;
document.getElementById("loadButtonGroup").style.width = "1200px";
maxAliensPerRow = 20;
myMainChaosMetrics.resize();
startYforHelp = 690;
}
}
function zoomOut() {
if (document.getElementById("myCanvas").width > 720) {
document.getElementById("myCanvas").width = 720;
document.getElementById("myCanvas").height = 480;
document.getElementById("gameContainer").style.width = "50%"
document.getElementById("gameContainer").style.height = "50%"
// document.getElementById("zoomInGameScreenInput").disabled = false;
// document.getElementById("zoomOutGameScreenInput").disabled = true;
document.getElementById("loadButtonGroup").style.width = "900px";
maxAliensPerRow = 12;
myMainChaosMetrics.resize();
startYforHelp = 400;
}
}
function controlAutoPilot() {
if (autoPilot) {
autoPilot = false;
$("#controlAutoPilotButton").text("Start");
chaos_report_switch = false;
} else {
autoPilot = true;
$("#controlAutoPilotButton").text("Stop");
}
}
function changeRandomFactor() {
randomFactor = $("#randomFactorInput").val();
$("#currentRandomFactor").text(randomFactor);
}
function showSpecialKeys() {
$('#showSpecialKeysModal').modal('show');
modal_opened = true;
}
function switchColorMode() {
let bodyElement = document.getElementById("kinvBody");
let buttonsLightElement = document.getElementsByClassName("btn-light");
let textkinv = document.getElementsByClassName("text-kinv");
let alertkinv = document.getElementsByClassName("alert-kinv");
if (current_color_mode == "light") {
bodyElement.style.backgroundColor = "#0a0a0a";
current_color_mode = "dark";
for (var i = 0; i < buttonsLightElement.length; i++) {
console.log("[COLOR-MODE-BUTTONS] Change color of " + buttonsLightElement[i].id);
document.getElementById(buttonsLightElement[i].id).style.backgroundColor = "#1ed931";
}
for (var i = 0; i < textkinv.length; i++) {
console.log("[COLOR-MODE-TEXT-KINV] Change color of " + textkinv[i].id);
document.getElementById(textkinv[i].id).style.color = "#1ed931";
}
for (var i = 0; i < alertkinv.length; i++) {
console.log("[COLOR-MODE-ALERT-KINV] Change color of " + alertkinv[i].id);
document.getElementById(alertkinv[i].id).style.color = "#1ed931";
document.getElementById(alertkinv[i].id).style.backgroundColor = "#0a0a0a";
document.getElementById(alertkinv[i].id).style.borderColor = "#ffffff";
}
document.getElementById("logTailRegex").style.backgroundColor = "#0a0a0a";
document.getElementById("logTailRegex").style.color = "#ffffff";
document.getElementById("switchColorModeLink").innerHTML = `
`;
return;
}
if (current_color_mode == "dark") {
bodyElement.style.backgroundColor = "#ffffff";
current_color_mode = "light";
for (var i = 0; i < buttonsLightElement.length; i++) {
console.log("[COLOR-MODE-BUTTONS] Change color of " + buttonsLightElement[i].id);
document.getElementById(buttonsLightElement[i].id).style.backgroundColor = "";
}
for (var i = 0; i < textkinv.length; i++) {
console.log("[COLOR-MODE-TEXT-KINV] Change color of " + textkinv[i].id);
document.getElementById(textkinv[i].id).style.color = "";
}
for (var i = 0; i < alertkinv.length; i++) {
console.log("[COLOR-MODE-ALERT-KINV] Change color of " + alertkinv[i].id);
document.getElementById(alertkinv[i].id).style.color = "";
document.getElementById(alertkinv[i].id).style.backgroundColor = "";
document.getElementById(alertkinv[i].id).style.borderColor = "";
}
document.getElementById("logTailRegex").style.backgroundColor = "";
document.getElementById("logTailRegex").style.color = "";
document.getElementById("switchColorModeLink").innerHTML = `
`;
}
}
function switchNamespace() {
if (namespaces_index < namespaces.length - 1) {
namespaces_index += 1;
}
else {
namespaces_index = 0;
}
namespace = namespaces[namespaces_index];
$('#currentGameNamespace').text(namespace);
$('#alert_placeholder').replaceWith(alert_div + 'Latest action: Change target namespace to ' + namespace + '');
aliens = [];
pods = [];
}
function createChaosProgramButton(name, lang) {
let btn = document.createElement("button");
let capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
console.log("[CREATE-CHAOS-PROGRAM] Creating button for " + name);
btn.innerHTML = capitalizedName;
btn.type = "button";
btn.name = "load" + capitalizedName;
btn.id = "load" + capitalizedName;
if (document.getElementById("load" + capitalizedName)) {
return;
}
btn.style = "padding: 0% 2%;"
btn.classList = "btn btn-light btn-sm";
btn.addEventListener("click", function () { loadPreset(name, lang); });
document.getElementById("loadButtonGroup").appendChild(btn);
document.getElementById("loadButtonGroup").scrollLeft = document.getElementById("loadButtonGroup").scrollWidth;
}
function deleteChaosProgramButton(name) {
let capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
document.getElementById("loadButtonGroup").removeChild(document.getElementById("load" + capitalizedName));
}
function setLogConsole() {
if (log_tail_switch) {
$("#logConsoleButton").text("Start Logs Tail");
$('#alert_placeholder3').replaceWith(alert_div_webtail + 'Stopping log tail...');
log_tail_switch = false;
disableLogTail();
} else {
$('#alert_placeholder3').replaceWith(alert_div_webtail + 'Starting log tail...');
$("#logConsoleButton").text("Stop Logs Tail");
log_tail_switch = true;
log_tail_div.style.display = "block";
log_tail_screen.style.display = "block"
setLogRegex();
enableLogTail();
getChaosJobsLogs();
}
}