Clean up code
This commit is contained in:
parent
cc2571dd50
commit
b4968f443c
1 changed files with 7 additions and 5 deletions
12
script.js
12
script.js
|
|
@ -25,7 +25,7 @@ let isWhite;
|
||||||
let isErase;
|
let isErase;
|
||||||
|
|
||||||
|
|
||||||
getGridDimensions();
|
resetGrid();
|
||||||
|
|
||||||
buttons.forEach((button) => {
|
buttons.forEach((button) => {
|
||||||
button.addEventListener ("click", changeColor);
|
button.addEventListener ("click", changeColor);
|
||||||
|
|
@ -43,19 +43,21 @@ function pickBackground() {
|
||||||
|
|
||||||
function resetGrid() {
|
function resetGrid() {
|
||||||
gridSlider.value = gridSlider.defaultValue;
|
gridSlider.value = gridSlider.defaultValue;
|
||||||
getGridDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGridDimensions() {
|
|
||||||
container.style.backgroundColor = "#ffffff";
|
container.style.backgroundColor = "#ffffff";
|
||||||
backColorPicker.value = "#ffffff";
|
backColorPicker.value = "#ffffff";
|
||||||
colorPicker.value = "#000000";
|
colorPicker.value = "#000000";
|
||||||
colorValue = "black";
|
colorValue = "black";
|
||||||
|
|
||||||
|
getGridDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGridDimensions() {
|
||||||
numGrid = gridSlider.value;
|
numGrid = gridSlider.value;
|
||||||
|
|
||||||
while (container.firstChild) {
|
while (container.firstChild) {
|
||||||
container.removeChild(container.lastChild);
|
container.removeChild(container.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
createGrid();
|
createGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue