From 8a19efb3c104354bd8eeab40b9b7d5cf9b65a4d5 Mon Sep 17 00:00:00 2001 From: Stephen Hawes Date: Sun, 15 Oct 2023 13:47:24 -0400 Subject: [PATCH] fixes bug where page hangs when too many 32mm feeders. adds popup if some tapes not allocated --- dist/index.html | 2 +- math.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dist/index.html b/dist/index.html index 9001853..e09ed68 100644 --- a/dist/index.html +++ b/dist/index.html @@ -20,7 +20,7 @@ - + diff --git a/math.js b/math.js index a45bfa1..350ef8f 100644 --- a/math.js +++ b/math.js @@ -187,6 +187,7 @@ window.calculate = function () { console.log("current feeder width: " + width); console.log("best allocation of that width: " + Math.min(partsPerU[width], nonPriority[width])); console.log("best allocation of next width: " + Math.min(partsPerU[width+1], nonPriority[width+1])); + if(Math.min(partsPerU[width], nonPriority[width]) >= Math.min(partsPerU[width+1], nonPriority[width+1])){ //if there are U left to allocate if(uIndex < uSolve.length){ @@ -229,6 +230,9 @@ window.calculate = function () { // removing the amount of parts allocated nonPriority[width] = nonPriority[width] - Math.min(partsPerU[width], nonPriority[width]); } + else{ + break; + } } } @@ -237,6 +241,31 @@ window.calculate = function () { console.log("final usolve: " + uSolve) console.log("remaining nonprio: " + nonPriority) +// NOTIFYING ABOUT PARTS NOT ALLOCATED + + if(nonPriority[0] != 0 || nonPriority[1] != 0 || nonPriority[2] != 0 || nonPriority[3] != 0 || nonPriority[4] != 0 ){ + // something's not allocated + var message = "Not enough space for some tapes:\n"; + + if(nonPriority[0] != 0){ + message = message + "8mm: " + nonPriority[0] + "\n"; + } + if(nonPriority[1] != 0){ + message = message + "12mm: " + nonPriority[1] + "\n"; + } + if(nonPriority[2] != 0){ + message = message + "16mm: " + nonPriority[2] + "\n"; + } + if(nonPriority[3] != 0){ + message = message + "24mm: " + nonPriority[3] + "\n"; + } + if(nonPriority[4] != 0){ + message = message + "32mm: " + nonPriority[4] + "\n"; + } + alert(message); + } + + // DRAWING THREEJS