Skip to content

Commit

Permalink
jarsh
Browse files Browse the repository at this point in the history
  • Loading branch information
SUPERDERP1 authored Dec 14, 2024
1 parent 62b4150 commit 364b4a0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="content-wrap">
<div id="content">
<h1 class="directoryTitle">main/</h1>
Expand All @@ -19,6 +20,7 @@ <h1 class="directoryTitle">main/</h1>
<input type="text" id="inputReader" placeholder="Enter command" />
<!--<button type="submit">Submit</button>-->
</form>
<p id="semicolonsDisplay"></p>
<script src="scripts/script.js"></script>
</body>
</html>
72 changes: 43 additions & 29 deletions scripts/script.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
// i hvvae no idea what im doing
const cmds = [];
let semicolons = 0;
const cmds = []; // Commands array
let semicolons = 0; // Semicolon counter

// Handle form submission
document.getElementById('inputForm').addEventListener("submit", (event) => {
event.preventDefault(); // Prevent the default form submission behavior
// Event listener for handling input submissions
document.getElementById("inputForm").addEventListener("submit", (event) => {
event.preventDefault(); // Prevent the default form submission

const inputField = document.getElementById('inputReader');
const input = inputField.value.trim(); // Get and trim the input value
const inputField = document.getElementById("inputReader");
const input = inputField.value.trim(); // Get the input value and trim spaces

if (input) {
cmds.push(input); // Add the command to the cmds array

// Check the entered command and update semicolons
if (input === "return;") {
semicolons += 1;
} else if (input === "console.log(i need semicolons);") {
semicolons += 3;
} else if (input === "let semicolons = semicolons + 5;") {
semicolons += 5;
} else if (input === "semicolons += 8;") {
semicolons += 8;
} else if (input === "function giveMoney() {semicolons += 10;}") {
semicolons += 12;
} else if (input === "if(money < 100000) {giveMoney();}") {
semicolons += 15;
// Check if the command matches any valid entry in the cmds array
if (cmds.includes(input)) {
// Process the command and update semicolons
if (input === "return;") {
semicolons += 1;
} else if (input === "console.log(i need semicolons);") {
semicolons += 3;
} else if (input === "let semicolons = semicolons + 5;") {
semicolons += 5;
} else if (input === "semicolons += 8;") {
semicolons += 8;
} else if (input === "function giveMoney() {semicolons += 10;}") {
semicolons += 12;
} else if (input === "if(money < 100000) {giveMoney();}") {
semicolons += 15;
} else if (input === "for(let i = 0; i < 10; i++) { semicolons += i; }") {
semicolons += 20;
} else if (input === "while(semicolons < 100) { semicolons += 5; }") {
semicolons += 25;
} else if (input === "if(a > b) { return a; } else { return b; }") {
semicolons += 18;
} else if (input === "switch(x) { case 1: semicolons += 10; break; default: semicolons += 5; }") {
semicolons += 22;
} else if (input === "class SemicolonMaster { constructor() { this.semicolons = 50; } }") {
semicolons += 30;
}
} else {
// Command not recognized; return false and log an error
console.error("Unknown command:", input);
return false;
}

// Clear the input field
inputField.value = '';
inputField.value = "";

// Log the current state
// Update the display
updateSemicolonsDisplay();
console.log("Current semicolons:", semicolons);
console.log("Commands array:", cmds);
}
});

// Function to add a new command programmatically
function addCmds(command) {
cmds.push(command);
}
// Function to update semicolon display dynamically
function updateSemicolonsDisplay() {
const display = document.getElementById("semicolonsDisplay");
display.textContent = `Semicolons: ${semicolons}`;
}

0 comments on commit 364b4a0

Please sign in to comment.