Added clear button, slight reformatting of analyser.js

This commit is contained in:
Taylor Courage 2025-01-21 11:13:04 -05:00
parent 9d96a0b7cd
commit 5e2d5ba19d
2 changed files with 35 additions and 8 deletions

View File

@ -7,6 +7,8 @@ var dataROA = [];
var dataElong = []; var dataElong = [];
var dataDelta = []; var dataDelta = [];
///// START OF MATHS FUNCTIONS /////
// This function gets the reduction of area with two provided sizes, and returns it // This function gets the reduction of area with two provided sizes, and returns it
function getReduction(startSize, finalSize) { function getReduction(startSize, finalSize) {
var startArea = Math.PI * ((startSize / 2) * (startSize / 2)); var startArea = Math.PI * ((startSize / 2) * (startSize / 2));
@ -25,6 +27,20 @@ function getDelta(startSize, finalSize, angle) {
return ((startSize + finalSize) / (startSize - finalSize)) * Math.sin(angle); return ((startSize + finalSize) / (startSize - finalSize)) * Math.sin(angle);
} }
function toMillimetres(size) { //convert to mm
size = Math.round((size * 100) * 25.4) / 100;
return size;
}
function toInches(size) { //convert to inches
size = Math.round((size * 1000) / 25.4) / 1000;
return size;
}
///// END OF MATHS SECTION /////
///// START OF DISPLAY SECTION /////
function addReduction() { function addReduction() {
numDies ++; // Increment our die count numDies ++; // Increment our die count
@ -58,6 +74,10 @@ function removeReduction() { // function to remove the last row
} }
} }
///// END OF DISPLAY SECTION /////
///// START OF ALGORITHMS SECTION /////
function doMath() { function doMath() {
outputVisible = 1; // set visible status to enabled outputVisible = 1; // set visible status to enabled
outputTable = document.getElementById("output"); // Select our output data table outputTable = document.getElementById("output"); // Select our output data table
@ -237,13 +257,20 @@ function drawGraph() {
}); });
} }
function toMillimetres(size) { //convert to mm function clearScreen() {
size = Math.round((size * 100) * 25.4) / 100; // Reset variables back to defaults
return size; numDies = 2;
outputVisible = 0;
// Delete the table
outputTable = document.getElementById("output");
outputTable.innerHTML = "";
// Delete the output graph
outputGraph = document.getElementById("outputChart");
outputGraph.innerHTML = " ";
} }
function toInches(size) { //convert to inches
size = Math.round((size * 1000) / 25.4) / 1000; ///// START OF ALGORITHMS SECTION /////
return size;
}

View File

@ -11,7 +11,6 @@
</head> </head>
<body> <body>
<p>&nbsp;</p>
<div class="content"> <div class="content">
<div class="header"> <div class="header">
<p id="vanity">Taylor Courage's</p> <p id="vanity">Taylor Courage's</p>
@ -39,6 +38,7 @@
</table> </table>
<p></p> <p></p>
<button name="Calculate" id="calculateButton" onclick="doMath()">Recalculate</button> <button name="Calculate" id="calculateButton" onclick="doMath()">Recalculate</button>
<button name="Clear" id="clearButton" onclick="clearScreen()">Clear</button>
<script>addReduction()</script> <script>addReduction()</script>
<script>addReduction()</script> <script>addReduction()</script>