56 lines
1.2 KiB
HTML
56 lines
1.2 KiB
HTML
|
<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);
|
||
|
list.innerHTML += `<ul>${el[3]} cuts for ${el[0]} x ${el[1]}`;
|
||
|
}
|
||
|
}));
|
||
|
}
|
||
|
calc();
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|