Skip to content

Commit

Permalink
fixes bug where page hangs when too many 32mm feeders. adds popup if …
Browse files Browse the repository at this point in the history
…some tapes not allocated
  • Loading branch information
sphawes committed Oct 15, 2023
1 parent 2d51f79 commit 8a19efb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<script type="module" crossorigin src="./assets/index-9882dc94.js"></script>
<script type="module" crossorigin src="./assets/index-48da3bdc.js"></script>
<link rel="stylesheet" href="./assets/index-4b85fc06.css">
</head>
<body>
Expand Down
29 changes: 29 additions & 0 deletions math.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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;
}
}
}

Expand All @@ -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

Expand Down

0 comments on commit 8a19efb

Please sign in to comment.