From 6483de5d9b01f3bc8c1b047c8f99fdda9a1f4ca6 Mon Sep 17 00:00:00 2001 From: Alexander Bass Date: Fri, 24 Jun 2022 08:24:01 -0400 Subject: [PATCH] fixed create menu stuff (again) --- www/scripts/interface/mainmenu/create.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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}%` }