From 7b3aa42ef84148eba7cb0db917bf644faaf819c4 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Mon, 18 Aug 2025 16:50:40 -0600 Subject: [PATCH] broke out library to its own js file and implimented modules --- index.html | 3 +-- library.js | 13 +++++++++++++ main.js | 11 ++++------- pecslib.js | 4 ++-- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 library.js diff --git a/index.html b/index.html index d5e9fb3..02f2ddc 100644 --- a/index.html +++ b/index.html @@ -2,8 +2,7 @@ librePECS - - + diff --git a/library.js b/library.js new file mode 100644 index 0000000..64cbb91 --- /dev/null +++ b/library.js @@ -0,0 +1,13 @@ +import { pec } from './pecslib.js'; + +// Populate Library +var library = []; +library.push(new pec("No","images/cards_conversation_no.svg")); +library.push(new pec("Up","")); +library.push(new pec("More","")); +library.push(new pec("Drink","images/cards_food_thirsty.svg")); +library.push(new pec("Food","images/cards_food_hungry.svg")); +library.push(new pec("Toy","")); +// add more here + +export { library as library }; diff --git a/main.js b/main.js index 5ef3015..a9cd9a1 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,5 @@ +import { pecBoard, pec } from './pecslib.js'; + // gui object classes? // Why am I doing this? class auxillery_dialog { @@ -132,7 +134,6 @@ function repopBoards (current=0) { } } boardTab.innerText = name; - console.log(boardTab); } } @@ -204,12 +205,8 @@ repopBoards(0); repopGrid(app.currentBoard); // Populate Library -app.library = []; -app.library.push(new pec("No","images/cards_conversation_no.svg")); -app.library.push(new pec("Up","")); -app.library.push(new pec("More","")); -app.library.push(new pec("Drink","images/cards_food_thirsty.svg")); -app.library.push(new pec("Food","images/cards_food_hungry.svg")); +import { library as library } from './library.js'; +app.library = library; // add more here app.library.forEach((p,i)=>{ var newPec = document.createElement("span"); diff --git a/pecslib.js b/pecslib.js index 7cdbc81..40b4731 100644 --- a/pecslib.js +++ b/pecslib.js @@ -1,4 +1,4 @@ -class pec { +export class pec { // this is the object for the pecs themselves, this will be used both // to populate the library, and to occupy pecSlot objects constructor (word,image) { @@ -35,7 +35,7 @@ class pecSlot { // Do I actually need this? } -class pecBoard { +export class pecBoard { constructor (pecs=[]) { var initPecs = [ null,null,null,null,