figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

commit 1c1d5b40a9cb2552065e9a9ee992fd3bb735c600
parent 89dfd0f3120e65e658b596519efbe7a6b80464ce
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Tue, 24 Sep 2019 15:28:36 -0700

Fully implementing Size Calculator, upgrading Javascript syntax, and swapping linter to JSHint

Diffstat:
A.jshintrc | 12++++++++++++
MconsecutiveNum/consecutiveNum.js | 33++++++++++++++++++---------------
MconsecutiveNum/index.html | 12+++++++-----
Mmain.css | 4++++
Mmatrix/index.html | 6+++---
Mmatrix/matrix.js | 11+++++++----
Msizecalc/index.html | 6+++++-
Msizecalc/sizecalc.js | 23++++++++++++++++-------
8 files changed, 72 insertions(+), 35 deletions(-)

diff --git a/.jshintrc b/.jshintrc @@ -0,0 +1,11 @@ +{ + "esversion": 9, + "curly": true, + "shadow": true, + "strict": true, + "unused": "strict", + "globals": { + "document": false, + "console": false + } +} +\ No newline at end of file diff --git a/consecutiveNum/consecutiveNum.js b/consecutiveNum/consecutiveNum.js @@ -3,7 +3,6 @@ function getSum(total, num) { return total + num; } -//STOPPED AT K function solveConsec(amount, sum, type) { "use strict"; var @@ -26,9 +25,9 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } else if (numSum < 0) { smallestNum = -1; @@ -43,9 +42,9 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } break; @@ -62,9 +61,9 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } else if (numSum < 0) { var d = 0; @@ -78,9 +77,9 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } break; @@ -95,9 +94,9 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } else if (numSum < 0) { var i = 0; @@ -111,11 +110,15 @@ function solveConsec(amount, sum, type) { } } if (allNums.reduce(getSum) > numSum) { - document.getElementById("out").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values." + document.getElementById("outText").innerHTML = "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; } else { - document.getElementById("out").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; + document.getElementById("outText").innerHTML = "Success! The " + numAmount + " consecutive numbers that equal " + numSum + " are " + allNums + "."; } } break; } -} -\ No newline at end of file +} +/* +Test values: +4 consequtive even integers equal 100 +*/ +\ No newline at end of file diff --git a/consecutiveNum/index.html b/consecutiveNum/index.html @@ -5,6 +5,7 @@ <title>FIGBERT Math - C.N.F.</title> <meta charset="utf-8"> <link href="../main.css" rel="stylesheet" type="text/css"> + <script src="consecutiveNum.js" type="text/javascript" async></script> </head> <body> <header> @@ -31,8 +32,10 @@ </fieldset> <input type="button" value="Solve" onclick="solveConsec(numSet.value, sumSet.value, numType.value)" id="setButton"> </fieldset> - <h3>Output:</h3> - <p id="out"></p> + <div id="out"> + <h3>Output:</h3> + <p id="outText"></p> + </div> </form> </main> <footer> @@ -45,5 +48,4 @@ <a href="../submit/" class="footer__text">Submit Code</a> </footer> </body> -</html> -<script src="consecutiveNum.js"></script> -\ No newline at end of file +</html> +\ No newline at end of file diff --git a/main.css b/main.css @@ -60,6 +60,10 @@ main { display: none; } +#out { + margin-left: 10px; +} + footer { font-size: calc(10px + 0.1vw); position: fixed; diff --git a/matrix/index.html b/matrix/index.html @@ -5,6 +5,7 @@ <title>FIGBERT Math - S.E.S.</title> <meta charset="utf-8"> <link href="../main.css" rel="stylesheet" type="text/css"> + <script src="matrix.js" type="text/javascript" async></script> </head> <body> <header> @@ -79,5 +80,4 @@ <a href="../submit/" class="footer__text">Submit Code</a> </footer> </body> -</html> -<script src="matrix.js"></script> -\ No newline at end of file +</html> +\ No newline at end of file diff --git a/matrix/matrix.js b/matrix/matrix.js @@ -48,7 +48,7 @@ function setUpMatrix(num) { allW = document.getElementsByClassName("w"), allZ = document.getElementsByClassName("z"), all = document.getElementsByClassName("a"); - if (num == 2) { + if (num === "2") { document.getElementById("equations").style.display = "block"; hide(allW); hide(allZ); @@ -56,7 +56,7 @@ function setUpMatrix(num) { document.getElementById("thirdEquation").style.display = "none"; document.getElementById("fourthEquation").style.display = "none"; reset(all); - } else if (num == 3) { + } else if (num === "3") { document.getElementById("equations").style.display = "block"; hide(allW); show(allZ); @@ -77,6 +77,7 @@ function setUpMatrix(num) { //answerTwo() accepts two simplified equations as input and outputs the x and y values function answerTwo(one, two) { + "use strict"; var y = two[2] / two[1], x = (one[2] - (one[1] * y)) / one[0]; @@ -85,6 +86,7 @@ function answerTwo(one, two) { //answerThree() accepts three simplified equations as input and outputs the x, y, and z values function answerThree(one, two, three) { + "use strict"; var z = three[3] / three[2], y = (two[3] - (two[2] * z)) / two[1], @@ -94,6 +96,7 @@ function answerThree(one, two, three) { //answerFour() accepts four simplified equations as input and outputs the w, x, y, and z values function answerFour(one, two, three, four) { + "use strict"; var z = four[4] / four[3], y = (three[4] - (three[3] * z)) / three[2], @@ -183,7 +186,7 @@ function solveFourMatrix(one, two, three, four) { //solveMatrix() uses a combination of other functions to simplify the matrix function solveMatrix(dimension) { "use strict"; - if (dimension == 2) { + if (dimension === "2") { var firstXY = [parseInt(document.getElementById("xOne").value), parseInt(document.getElementById("yOne").value), parseInt(document.getElementById("equalsOne").value)], secondXY = [parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("equalsTwo").value)], @@ -195,7 +198,7 @@ function solveMatrix(dimension) { document.getElementById("outTwo").innerHTML = "[" + answerXY[0] + ", " + answerXY[1] + ", " + answerXY[2] + "]"; document.getElementById("xValue").innerHTML = "x = " + valuesXY[0]; document.getElementById("yValue").innerHTML = "y = " + valuesXY[1]; - } else if (dimension == 3) { + } else if (dimension === "3") { var firstXYZ = [parseInt(document.getElementById("xOne").value), parseInt(document.getElementById("yOne").value), parseInt(document.getElementById("zOne").value), parseInt(document.getElementById("equalsOne").value)], secondXYZ = [parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("zTwo").value), parseInt(document.getElementById("equalsTwo").value)], diff --git a/sizecalc/index.html b/sizecalc/index.html @@ -17,7 +17,7 @@ <fieldset> <legend>Select mode</legend> <label for="angSize"><input id="angSize" type="radio" name="modeSelect" value="a">Angular Size (𝛼)</label><br> - <label for="realSize"><input id="realSize" type="radio" name="modeSelect" value="D">Real Size (D)</label><br> + <label for="realSize"><input id="realSize" type="radio" name="modeSelect" value="D">Real Size/Diameter (D)</label><br> <label for="distance"><input id="distance" type="radio" name="modeSelect" value="d">Distance (d)</label><br> <input type="button" value="Select" onclick="setUp(modeSelect.value)"> </fieldset> @@ -38,6 +38,10 @@ <input type="button" value="Solve" onclick="actionManager(angVal.value, sizeVal.value, distVal.value)"> </fieldset> </form> + <div id="out" class="hidden"> + <h3 id="title">Answer:</h3> + <p id="numOut"></p> + </div> </main> <footer> <a href="../" class="footer__text">Home</a> diff --git a/sizecalc/sizecalc.js b/sizecalc/sizecalc.js @@ -17,14 +17,13 @@ function hide(elements) { function reset(elements) { "use strict"; for (var a = 0; a < elements.length; a++) { - elements[a].value = "null"; + elements[a].value = ""; } } function setUp(selection) { "use strict"; type = selection; - console.log(type); document.getElementById("sizeIn").style.display = "block"; hide(document.getElementsByClassName("ins")); reset(document.getElementsByClassName("numinput")); @@ -35,6 +34,7 @@ function setUp(selection) { } else { show(document.getElementsByClassName("d")); } + document.getElementById("out").style.display = "none"; } function angularSize(size, distance) { @@ -55,10 +55,19 @@ function calcDistance(size, angle) { function actionManager(angle, size, distance) { "use strict"; if (type === "a") { - console.log(angularSize(size, distance)); + document.getElementById("out").style.display = "block"; + document.getElementById("numOut").innerHTML = "𝛼 = " + angularSize(size, distance); } else if (type === "D") { - console.log(realSize(angle, distance)); + document.getElementById("out").style.display = "block"; + document.getElementById("numOut").innerHTML = "D = " + realSize(angle, distance); } else { - console.log(calcDistance(size, angle)); + document.getElementById("out").style.display = "block"; + document.getElementById("numOut").innerHTML = "d = " + calcDistance(size, angle); } -} -\ No newline at end of file +} +/* +Test values: +𝛼 = 0.266513692671216 +D = 432168.6 +d = 92955810 +*/ +\ No newline at end of file