tools.oit.cloud/board_calc.html

56 lines
1.2 KiB
HTML
Raw Normal View History

2024-07-09 02:50:49 -04:00
<html>
<head>
<style>
ul, li {
padding: 0;
}
</style>
</head>
<body>
<div>
<label for="length">Board Length</label>
<input name="length" value="114" />
</div>
<div>
<label for="width">Board Width</label>
<input name="width" value="6" />
</div>
<button type="submit" onclick="calc()">Calculate</button>
<ul id="list">
</ul>
<script type="text/javascript">
var list = document.querySelector('#list');
var length = document.querySelector('[name=length]');
var width = document.querySelector('[name=width]');
function calc() {
var l = length.value;
var w = width.value;
var a = [];
list.innerHTML = '';
for(var i = 2; i < l; i++) {
a.push([l/i, i * w, (l/i) / (i * w), i]);
}
a.sort(function(a, b) {
return a[2] > b[2];
});
console.log(a.filter(function(el) {
if(el[2] > 0.75 && el[2] < 1.25) {
console.log(el);
2024-07-09 02:57:25 -04:00
list.innerHTML += `<ul>${el[3]} cuts for ${el[0]} x ${el[1]} (ratio: ${el[2]})`;
2024-07-09 02:50:49 -04:00
}
}));
}
calc();
</script>
</body>
</html>