-
Ben Eltschig authoredUnverifiedd415856e
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
script.js 1.00 KiB
import {SkribblTopic,SkribblWord} from "./CustomElements.js";
(async()=>{
/**
* @typedef {{word:string,context?:string,description?:string,synonyms?:string[]}} Word
* @typedef {{type:"topic",name:string,words:Word[]}} Topic
* @type {{words:(Word|Topic)[],macros?:unknown}}
*/
const json = await (await fetch("../Skribbl.json")).json();
if (document.readyState=="loading"){
await new Promise(resolve=>{document.addEventListener("DOMContentLoaded",()=>resolve())})
}
const div = document.getElementById("Begriffe");
json.words.forEach(wordOrTopic=>{
if ("type" in wordOrTopic&&wordOrTopic.type=="topic"){
const topic = new SkribblTopic(wordOrTopic.name);
div.appendChild(topic);
wordOrTopic.words.forEach(word=>{
let element = new SkribblWord(word.word,{description:word.description,synonyms:word.synonyms,macros:json.macros});
topic.appendChild(element);
});
}else{
console.warn("ignoring top-level word:",wordOrTopic);
}
});
document.location.hash = document.location.hash;
})();