From 75b83e30ea251094f82153063c87778ceef313fe Mon Sep 17 00:00:00 2001 From: Mike Smith <89040888+smiggiddy@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:51:48 -0500 Subject: [PATCH] inventory skeleton --- calculator/js/script.js | 300 ++++++++++++++-------------- inventory/bun.lockb | Bin 0 -> 38942 bytes inventory/package.json | 8 + inventory/src/app.js | 31 +++ inventory/src/routes/indexRouter.js | 9 + 5 files changed, 198 insertions(+), 150 deletions(-) create mode 100755 inventory/bun.lockb create mode 100644 inventory/package.json create mode 100644 inventory/src/app.js create mode 100644 inventory/src/routes/indexRouter.js diff --git a/calculator/js/script.js b/calculator/js/script.js index 3c37b9a..702f78b 100644 --- a/calculator/js/script.js +++ b/calculator/js/script.js @@ -1,205 +1,205 @@ -let display = document.querySelector('.display'); -const buttons = document.querySelectorAll('.btn'); +let display = document.querySelector(".display"); +const buttons = document.querySelectorAll(".btn"); const ops = { - firstNum: String(), - secondNum: String(), - operator: undefined, - lastOperator: undefined, - numFlag: false, - onSecondNumber: false, - stringLength: 8, - periodClicked: false, - result: String(), + firstNum: String(), + secondNum: String(), + operator: undefined, + lastOperator: undefined, + numFlag: false, + onSecondNumber: false, + stringLength: 8, + periodClicked: false, + result: String(), - toggleNumFlag: function() { - this.numFlag = !this.numFlag - }, - clear: function(){ + toggleNumFlag: function () { + this.numFlag = !this.numFlag; + }, + clear: function () { this.firstNum = String(); this.secondNum = String(); this.operator = undefined; - this.numFlag = false; + this.numFlag = false; this.onSecondNumber = false; this.result = String(); display.textContent = "0"; - }, - appendNumber: function(num) { - if(num === "0" && display.textContent.trim() === "0") return - if(!ops.numFlag && ops.checkLength(ops.firstNum)) { - ops.firstNum += num; - updateDisplay(ops.firstNum); - } else if(this.numFlag) { - if (this.checkLength(ops.secondNum)) { - ops.secondNum += num; - updateDisplay(ops.secondNum); - } + }, + appendNumber: function (num) { + if (num === "0" && display.textContent.trim() === "0") return; + if (!ops.numFlag && ops.checkLength(ops.firstNum)) { + ops.firstNum += num; + updateDisplay(ops.firstNum); + } else if (this.numFlag) { + if (this.checkLength(ops.secondNum)) { + ops.secondNum += num; + updateDisplay(ops.secondNum); + } } - }, - checkLength: function(string) { + }, + checkLength: function (string) { return string.length < this.stringLength; - } + }, }; function add(x, y) { - return x + y; + return x + y; } function subtract(x, y) { - return x - y; + return x - y; } function multiply(x, y) { - return x * y; + return x * y; } function divede(x, y) { - if (x === 0) { - return 0 - } else if (y === 0) { - alert("Cannot divide by 0!"); - return "Error" - } - return x / y; + if (x === 0) { + return 0; + } else if (y === 0) { + alert("Cannot divide by 0!"); + return "Error"; + } + return x / y; } function operate(firstNum, secondNum, operator) { - switch (operator) { - case '+': - return add(firstNum, secondNum); - case '-': - return subtract(firstNum, secondNum); - case '*': - return multiply(firstNum, secondNum); - case '/': - return divede(firstNum, secondNum); - } + switch (operator) { + case "+": + return add(firstNum, secondNum); + case "-": + return subtract(firstNum, secondNum); + case "*": + return multiply(firstNum, secondNum); + case "/": + return divede(firstNum, secondNum); + } } function handleOperation() { - const first = Number(ops.firstNum); - const second = Number(ops.secondNum); - let result = operate(first, second, ops.operator); + const first = Number(ops.firstNum); + const second = Number(ops.secondNum); + console.log(`last operator: ${ops.operator}`); + let result = operate(first, second, ops.operator); - if (result === "error") { - ops.clear(); - return; - } + if (result === "Error") { + ops.clear(); + return; + } - result = roundThreeDecimals(result); - updateDisplay(result); - - // store result - ops.result = result; + result = roundThreeDecimals(result); + updateDisplay(result); - if (ops.lastOperator === '=') { - ops.firstNum = String(); - ops.secondNum = String(); - ops.numFlag = false; - ops.onSecondNumber = !ops.onSecondNumber; - } else { - ops.firstNum = ops.result; - ops.secondNum = ""; - ops.onSecondNumber = true; - } - // ops.operator = undefined; + // store result + ops.result = result; + + if (ops.operator === "=") { + ops.firstNum = String(); + ops.secondNum = String(); + ops.numFlag = false; + ops.onSecondNumber = false; + } else { + ops.firstNum = ops.result; + ops.secondNum = ""; + ops.operator = ""; + ops.onSecondNumber = true; + } + ops.operator = undefined; + ops.lastOperator = undefined; } function updateDisplay(displayValue) { - display.textContent = displayValue; + display.textContent = displayValue; } function roundThreeDecimals(number) { - if (!Number.isInteger(number) && Number.isFinite(number) - ) { - return parseFloat(number.toPrecision(3)); - } else { - return number; - } + if (!Number.isInteger(number) && Number.isFinite(number)) { + return parseFloat(number.toPrecision(3)); + } else { + return number; + } } function handleOperatorClick(operatorClicked) { - - ops.lastOperator = operatorClicked; - // TODO handle ops for = or clear - if (operatorClicked === 'cls') { - ops.clear(); - return; - } else if (operatorClicked === '=') { - ops.lastOperator = '='; - handleOperation(); - return; - } else if (operatorClicked === '+/-') { - negateNumber(); - return; - } else if (operatorClicked === '%') { - percentageNumber(); - return; - } else { - if(ops.secondNum && ops.numFlag){ - handleOperation(); - return; - } + ops.operator = operatorClicked; + // TODO handle ops for = or clear + if (operatorClicked === "cls") { + ops.clear(); + return; + } else if (operatorClicked === "=") { + if (ops.lastOperator) { + ops.operator = ops.lastOperator; } + handleOperation(); + return; + } else if (operatorClicked === "+/-") { + negateNumber(); + return; + } else if (operatorClicked === "%") { + percentageNumber(); + return; + } else { + if (ops.secondNum && ops.numFlag) { + ops.lastOperator = operatorClicked; + handleOperation(); + return; + } + } - - ops.operator = operatorClicked; - //TODO fix this conditional should be if numFlag and a check if = or additional ops - if(!ops.onSecondNumber ){ - ops.numFlag = true; - if (ops.result !== "" ) { - console.log('this is running the ops.result'); - ops.firstNum = ops.result; - ops.onSecondNumber = true; - return - } + //TODO fix this conditional should be if numFlag and a check if = or additional ops + if (!ops.onSecondNumber) { + ops.numFlag = true; + if (ops.result !== "") { + console.log("this is running the ops.result"); + ops.firstNum = ops.result; + ops.onSecondNumber = true; + return; } - ops.onSecondNumber = !ops.onSecondNumber; + } + // ops.onSecondNumber = !ops.onSecondNumber; } -function calculator(event){ - - if(event.target.dataset.ops === "") { - handleOperatorClick(event.target.value); - } else if (event.target.value === '.') { - if (display.textContent.includes('.')) { - return - } else { - ops.appendNumber(event.target.value) - } - - } else if(event.target.dataset.num === "") { - ops.appendNumber(event.target.value) +function calculator(event) { + if (event.target.dataset.ops === "") { + handleOperatorClick(event.target.value); + } else if (event.target.value === ".") { + if (display.textContent.includes(".")) { + return; + } else { + ops.appendNumber(event.target.value); } + } else if (event.target.dataset.num === "") { + ops.appendNumber(event.target.value); + } } -function negateNumber(){ - // returns a negated number - let negated; - if (!ops.numFlag || !ops.onSecondNumber) { - negated = Number(ops.firstNum) * -1; - ops.firstNum = String(negated); - } else { - negated = Number(ops.secondNum) * -1; - ops.secondNum = String(negated); - } - updateDisplay(negated); +function negateNumber() { + // returns a negated number + let negated; + if (!ops.numFlag || ops.secondNum === "") { + negated = Number(ops.firstNum) * -1; + ops.firstNum = String(negated); + } else { + negated = Number(ops.secondNum) * -1; + ops.secondNum = String(negated); + } + updateDisplay(negated); } function percentageNumber() { - let percent; - if ((!ops.numFlag || !ops.onSecondNumber)) { - percent = Number(ops.firstNum) / 100; - ops.firstNum = String(percent); - } else if (ops.result !== "" ) { - percent = Number(ops.result) / 100; - } else { - percent = Number(ops.secondNum) / 100; - ops.secondNum = String(percent); - } - updateDisplay(percent); + let percent; + if (!ops.numFlag || !ops.secondNum === "") { + percent = Number(ops.firstNum) / 100; + ops.firstNum = String(percent); + } else if (ops.result !== "") { + percent = Number(ops.result) / 100; + } else { + percent = Number(ops.secondNum) / 100; + ops.secondNum = String(percent); + } + updateDisplay(percent); } -buttons.forEach(btn => { - btn.addEventListener('click', calculator); +buttons.forEach((btn) => { + btn.addEventListener("click", calculator); }); diff --git a/inventory/bun.lockb b/inventory/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..6a514fa7ec15c6a8f41819df8a11828dad3c98cc GIT binary patch literal 38942 zcmeIbd0dR&`#(NqqD4uI>>1kKg0_hvRWM_kHg3e4guEXSvUP?t8lWXy}FWd3xS~ zTs;mqLft!@D+|I34)qE03k>G4{6cvlYym4mUsjUAVDOHfP`G}^c~8dWSq698ItN+z zOMBv#IN9`^&D~YXi^3-)uZ2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8v3k~yIVyn2CrjACXa2}zs;+8nSOl>&# z0mVPkC?;_&1pPp?y8skTC)CKG#=c)DZzh}P3wN$C+=GBW{n3Ke8}k5J<1y#~yZkth zw18|Z29S-%aKjUS^AUZ|131wUlqdd%E&4tPP@*G1!RJA!C70tLDhL#_d)$->D4I?{ zV|Y6urmn($0Kkbh1gLM8#9;8dDL`Pd z=%hC5`7yFb6>1iIf+C<_=+ zUCNss%;x%Vd|8xsuu}D53*fk=8+}tIU~W2rrW614`)hHi*)QdTVxomX3w9!}ngC4> zDV(?`;YOPRu<;nSuyCc>a-05UK2-bH#-N6~xFJftJOeBh;|`~=YhZK2c41U7htCfW z3k&55`0(x|xW#ubzh(r^UlXW(TX7u~@2apfiI1P;klNQ5hok8WP}&)wMfW92eS84~ zuc!nqwB#@O&@xzUf@`v=Fqz8^Y3Tu~DN`d6BB-t|u4hm$Jh3wTD6S8TINTM09wB^N J_W$1h{~!2ea>xJx literal 0 HcmV?d00001 diff --git a/inventory/package.json b/inventory/package.json new file mode 100644 index 0000000..bcfb118 --- /dev/null +++ b/inventory/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "ejs": "^3.1.10", + "express": "^4.21.2", + "express-validator": "^7.2.1", + "pg": "^8.13.1" + } +} \ No newline at end of file diff --git a/inventory/src/app.js b/inventory/src/app.js new file mode 100644 index 0000000..a8d9bad --- /dev/null +++ b/inventory/src/app.js @@ -0,0 +1,31 @@ +const express = require("express"); +const path = require("node:path"); + +const app = express(); +const port = 8080; + +const { indexRouter } = require("./routes/indexRouter"); +const assetsPath = path.join(path.dirname(__dirname), "public"); + +app.set("views", path.join(__dirname, "views")); +app.set(express.static(assetsPath)); + +app.use(express.urlencoded({ extended: true })); + +app.use("/", indexRouter); + +const server = app.listen(port, () => { + console.log(`Server started at ${port}`); +}); + +const gracefulShutdownHandler = (signal) => { + console.log(`Caught ${signal}, gracefully shutting down`); + + server.close(() => { + console.log("shutting down server."); + process.exit(); + }); +}; + +process.on("SIGINT", gracefulShutdownHandler); +process.on("SIGTERM", gracefulShutdownHandler); diff --git a/inventory/src/routes/indexRouter.js b/inventory/src/routes/indexRouter.js new file mode 100644 index 0000000..7302a08 --- /dev/null +++ b/inventory/src/routes/indexRouter.js @@ -0,0 +1,9 @@ +const { Router } = require("express"); + +const indexRouter = Router(); + +indexRouter.get("/", (req, res) => { + res.send("index"); +}); + +module.exports = { indexRouter };