Added additional init stuff, fixed event listener refs

This commit is contained in:
2025-08-12 16:10:23 -06:00
parent 149abb716a
commit d76a0fd6eb
2 changed files with 28 additions and 6 deletions

26
main.js
View File

@@ -139,10 +139,26 @@ for (var x = 0; x < 16; x++) {
thisPec.id = name;
clearPec(x);
app.gui.view.appendChild(thisPec);
thisPec.addEventListener("click", (p,x)=>{
app.currentPec = p;
app.currentPecIndex = x;
app.gui.library.root.classList.add("focused");
}, thisPec, x);
}
// Create our initial board
app.boards = [];
app.boards.push(new pecBoard());
app.currentBoard = app.boards[0];
repopGrid(app.currentBoard);
// Populate Library
app.library = [];
app.library.push(new pec("No",""));
app.library.push(new pec("Up",""));
app.library.push(new pec("More",""));
app.library.push(new pec("Drink",""));
app.library.push(new pec("Food",""));
// add more here
app.library.forEach((p,i)=>{
var newPec = document.createElement("span");
newPec.classList.add("pecSlot");
newPec.innerText = p.word;
newPec.id = "lPec"+i;
newPec.addEventListener("click", useThisPec);
app.gui.library.body.appendChild(newPec);
});