mirror of
https://forge.murkfall.net/bluesaxman/librePECS.git
synced 2026-03-13 10:14:20 -06:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
|
|
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) {
|
||
|
|
var me = this;
|
||
|
|
this.word = "string" == typeof word ? word : "Empty";
|
||
|
|
this.image = image; // Add image processing here
|
||
|
|
this.utterance = new SpeechSynthesisUtterance(this.word);
|
||
|
|
var root = document.createElement("div");
|
||
|
|
root.classList.add("pec");
|
||
|
|
var img = document.createElement("img");
|
||
|
|
img.src = me.image;
|
||
|
|
img.classList.add("pecImage");
|
||
|
|
root.appendChild(img);
|
||
|
|
var name = document.createElement("span");
|
||
|
|
name.classList.add("pecNane");
|
||
|
|
root.appendChild(name);
|
||
|
|
root.addEventListener("click",()=>{ window.speechSynthisis.speak(me.utterance); });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
class pecSlot {
|
||
|
|
// Do I actually need this?
|
||
|
|
}
|
||
|
|
|
||
|
|
class pecBoard {
|
||
|
|
constructor (pecs=[]) {
|
||
|
|
var initPecs = [
|
||
|
|
null,null,null,null,
|
||
|
|
null,null,null,null,
|
||
|
|
null,null,null,null,
|
||
|
|
null,null,null,null];
|
||
|
|
pecs.map((p,i)=>{ if (p instanceof pec) { initPecs[i] = p; } });
|
||
|
|
this.pecs = initPecs;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
class pecBook {
|
||
|
|
// I don't know if I need this one ether.
|
||
|
|
}
|