From 5e2d5ba19d7e652ee96893eeb88358ee73b71aec Mon Sep 17 00:00:00 2001 From: Taylor Courage Date: Tue, 21 Jan 2025 11:13:04 -0500 Subject: [PATCH] Added clear button, slight reformatting of analyser.js --- analyser.js | 41 ++++++++++++++++++++++++++++++++++------- index.html | 2 +- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/analyser.js b/analyser.js index 118ca75..dfa54f3 100644 --- a/analyser.js +++ b/analyser.js @@ -7,6 +7,8 @@ var dataROA = []; var dataElong = []; var dataDelta = []; +///// START OF MATHS FUNCTIONS ///// + // This function gets the reduction of area with two provided sizes, and returns it function getReduction(startSize, finalSize) { 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); } +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() { 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() { outputVisible = 1; // set visible status to enabled outputTable = document.getElementById("output"); // Select our output data table @@ -237,13 +257,20 @@ function drawGraph() { }); } -function toMillimetres(size) { //convert to mm - size = Math.round((size * 100) * 25.4) / 100; - return size; +function clearScreen() { + // Reset variables back to defaults + 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; - return size; -} \ No newline at end of file + +///// START OF ALGORITHMS SECTION ///// \ No newline at end of file diff --git a/index.html b/index.html index 99f95a1..ebbe1f4 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,6 @@ -

 

Taylor Courage's

@@ -39,6 +38,7 @@

+