Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
Don't copy ready game twice
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysdz committed Apr 7, 2018
1 parent 0bec0b6 commit 8ce86aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var legend = {
lastNum: 0,
elements: []
};
var gameReady = 0;

/**
* Creates and returns HTML `svg` tag with proper viewBox set
Expand Down Expand Up @@ -94,6 +95,9 @@ function resetColour(){
markedSquares[a].classList.add("a");
markedSquares[a].classList.remove("b");
markedSquares[a].setAttribute("fill", "transparent");
while(markedSquares[a].firstChild){ //remove title elements when clearing
markedSquares[a].removeChild(markedSquares[a].firstChild);
}
}
legend = {
lastNum: 0,
Expand Down Expand Up @@ -212,6 +216,7 @@ function fillSelected(borders){
listElem.appendChild(span);
listElem.setAttribute("name", elId);
document.getElementById("legend").appendChild(listElem);
gameReady = 1;
}
}

Expand All @@ -227,12 +232,14 @@ function preparePattern(){
}

function prepareGame(){
if(!gameReady) return true;
playImage.setAttribute("style", createImage.getAttribute("style"));
while(playImage.firstChild){
playImage.removeChild(playImage.firstChild);
}
let svgElem = createImage.firstChild;
playImage.appendChild(svgElem.cloneNode(true));
gameReady = 0;
}

function removeElem(event){
Expand Down

0 comments on commit 8ce86aa

Please sign in to comment.