broke out library to its own js file and implimented modules

This commit is contained in:
2025-08-18 16:50:40 -06:00
parent 5de0ea7f8a
commit 7b3aa42ef8
4 changed files with 20 additions and 11 deletions

View File

@@ -2,8 +2,7 @@
<head>
<title>librePECS</title>
<link href="main.css" rel="stylesheet" />
<script src="pecslib.js"></script>
</head>
<body></body>
<script src="main.js"></script>
<script type="module" src="main.js"></script>
</html>

13
library.js Normal file
View File

@@ -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 };

11
main.js
View File

@@ -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");

View File

@@ -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,