First commit of homework assistant. Only contains vocabulary base functionality

This commit is contained in:
P-A
2026-02-05 20:24:22 +01:00
parent 7233201881
commit 22dff8705d
15 changed files with 1012 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
class HomeworkElement extends HTMLElement {
static updateTexts(container) {
let textElements = container.querySelectorAll(".text")
console.log(textElements)
textElements.forEach((item, index) => {
let itemId = item.getAttribute("id")
let itemText = HomeworkSession.texts[itemId]
HomeworkElement.applyText(itemText, item, null)
})
}
static applyText(sourceText, targetElement, fallback = '') {
if(sourceText.length > 0) {
targetElement.innerHTML = sourceText
targetElement.innerHTML = targetElement.textContent.trim()
} else if(fallback == '') {
console.warn('Missing text in: ', sourceText)
} else {
targetElement.innerHTML = fallback
}
}
}
const HomeworkTypes = Object.freeze({
VOCABULARY_ENGLISH: "'English vocabulary'",
VOCABULARY_FRENCH: "'French vocabulary'",
VOCABULARY_GERMAN: "'German vocabulary'",
VOCABULARY_SPANISH: "'Spanish vocabulary'",
MATH: "'Math'"
})