const outputContainer = document.getElementById("outputContainer"); const userInput = document.getElementById("userInput"); const initialMessage = document.getElementById("initialMessage"); const infoPopup = document.getElementById("infoPopup"); const popupText = document.getElementById("popupText"); const closeButton = document.getElementById("closeButton"); let lastCommandTime = 0; let fadeTimeout = null; function appendText(text, isNewCommand = false, isRisky = false) { // Create the message div const message = document.createElement("div"); message.innerHTML = `C:\\> ${text}`; // Apply risky styling if needed if (isRisky) { message.classList.add("risky"); } // Add the message to the container outputContainer.appendChild(message); // Ensure that the new message stays at the bottom outputContainer.scrollTop = outputContainer.scrollHeight; // Focus back to the input userInput.focus(); // Handle new command and fading if (isNewCommand) { // Clear any previous fade-out timeout clearTimeout(fadeTimeout); fadeTimeout = setTimeout(fadeOldMessages, 0); // Start fade-out in 5 seconds } } function fadeOldMessages() { const allMessages = outputContainer.getElementsByTagName("div"); const messageArray = Array.from(allMessages); // Remove all except the last command (the newest one) for (let i = 0; i < messageArray.length - 1; i++) { const message = messageArray[i]; message.classList.add("fade-out"); // Fade the previous message } // After the fade-out completes, remove the faded ones setTimeout(() => { // Remove all the faded messages const fadedMessages = outputContainer.getElementsByClassName("fade-out"); while (fadedMessages.length > 0) { fadedMessages[0].remove(); // Remove each faded message } }, 2000); // Time for fade-out to complete } function showTabFeatures(tab) { let output = ''; switch (tab) { case "main": output = ` 1. Main `; break; case "visuals": output = ` 2. Visuals `; break; case "misc": output = ` 3. Misc `; break; case "localplayer": output = ` 4. LocalPlayer `; break; case "settings": output = ` 5. Settings `; break; default: output = `'${tab}' is not recognized as an internal or external command, operable program or batch file.`; } appendText(output, true); // Mark it as a new command } function displayFishyInfo() { // Display information about Fishy in the popup const fishyInfo = ` Information about Fishy: `; popupText.innerHTML = fishyInfo; // Set the info text inside the popup infoPopup.classList.add("show"); // Show the popup with fade-in effect } function handleInput(input) { const trimmedInput = input.trim().toLowerCase(); if (trimmedInput === "help") { appendText(` Available options: 1. Main 2. Visuals 3. Misc 4. LocalPlayer 5. Settings Type 'info' for Fishy info. Select Number:`, true); } else if (["1", "main"].includes(trimmedInput)) { showTabFeatures("main"); } else if (["2", "visuals"].includes(trimmedInput)) { showTabFeatures("visuals"); } else if (["3", "misc"].includes(trimmedInput)) { showTabFeatures("misc"); } else if (["4", "localplayer"].includes(trimmedInput)) { showTabFeatures("localplayer"); } else if (["5", "settings"].includes(trimmedInput)) { showTabFeatures("settings"); } else if (trimmedInput === "clear") { clearConsole(); } else if (trimmedInput === "info") { displayFishyInfo(); // New 'info' command } else if (trimmedInput === "") { appendText("", true); // Do nothing if input is empty } else { appendText(`'${input}' is not recognized as an internal or external command, operable program or batch file.`, true, true); } } function clearConsole() { outputContainer.innerHTML = ''; // Clear everything inside the output container } function init() { appendText("Type Help"); initialMessage.style.display = 'none'; // Hide initial message after it's been shown once } userInput.addEventListener("keydown", function(event) { if (event.key === "Enter") { const input = userInput.value.trim(); if (input !== "") { handleInput(input); userInput.value = ""; // Clear the input after each command lastCommandTime = Date.now(); // Update the timestamp for the last command } } }); // Close the info popup when the button is clicked closeButton.addEventListener("click", function() { infoPopup.classList.remove("show"); // Hide the popup with fade-out effect }); init();