diff --git a/www/scripts/interface/mainmenu/create.js b/www/scripts/interface/mainmenu/create.js index 9a8769b..284e7db 100644 --- a/www/scripts/interface/mainmenu/create.js +++ b/www/scripts/interface/mainmenu/create.js @@ -32,6 +32,10 @@ mineSlider.oninput = function() { } mineBox.addEventListener("input", function() { + mineBox.value = Math.abs(Math.round(mineBox.value.replace(/\D/g,''))) +}) + +mineBox.addEventListener("change", function() { updateCount(1) menuPicker.select(3) }) @@ -44,17 +48,19 @@ heightBox.addEventListener("input", function(){ heightBox.addEventListener("change", function(){ heightBox.value = util.clamp(heightBox.value, 8, 500) + updateCount(2) menuPicker.select(3) }) widthBox.addEventListener("input", function(){ - widthBox.value = util.clamp(Math.abs(Math.round(widthBox.value.replace(/\D/g,''))), 8, 500) + widthBox.value = Math.abs(Math.round(widthBox.value.replace(/\D/g,''))) updateCount(2) }) widthBox.addEventListener("change", function(){ widthBox.value = util.clamp(widthBox.value, 8, 500) + updateCount(2) menuPicker.select(3) }) @@ -105,10 +111,10 @@ function updateCount(mode) { if (mode === 0) { mines = Math.round((mineSlider.value/10) * (width*height) /100) + updateCount(2) } else if (mode === 1) { - mineBox.value = Math.abs(Math.round(mineBox.value)) mines = mineBox.value; updateCount(2) @@ -122,7 +128,7 @@ function updateCount(mode) { mines = min } percentage = Math.floor((mines / (width * height)) * 1000)/ 10 - mineBox.value = mines; + mineBox.value = mines; mineSlider.value = percentage * 10 updatePercentageLabel(percentage) } @@ -140,6 +146,7 @@ function minMines(width, height) { } function updatePercentageLabel(percentage) { + if (percentage !== percentage) {percentage = 0} mineSliderNumber.textContent = `${percentage}%` }