diff --git a/csstest.html b/csstest.html
index 96d45b6..b54766b 100644
--- a/csstest.html
+++ b/csstest.html
@@ -3,4 +3,4 @@
title: "CSS Test"
---
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/js/cookieclicker.js b/js/cookieclicker.js
index 452ce3d..3deecaa 100644
--- a/js/cookieclicker.js
+++ b/js/cookieclicker.js
@@ -86,17 +86,17 @@ function upgradeClicker() {
cookieAmount -= clickerCost
recountCookies();
clickerLevel += 1;
- translate.setElementString(clickerLevelCounter, new TranslatableText("cookieclicker-clickerlevel", clickerLevel));
+ setElementString(clickerLevelCounter, new TranslatableText("cookieclicker-clickerlevel", clickerLevel));
clickerCost = Math.ceil(Math.pow(clickerCost / 1.3, 1.25));
- translate.setElementString(upgradeClickerButtonText, new TranslatableText("cookieclicker-clickerlevelbutton", clickerCost));
+ setElementString(upgradeClickerButtonText, new TranslatableText("cookieclicker-clickerlevelbutton", clickerCost));
}
}
function setCookieString(key, cookieAmount) {
- translate.setElementString(cookieCounter, new TranslatableText(key, cookieAmount));
+ setElementString(cookieCounter, new TranslatableText(key, cookieAmount));
}
function setWorkerString(key, workerAmount) {
- translate.setElementString(workerCounter, new TranslatableText(key, workerAmount));
+ setElementString(workerCounter, new TranslatableText(key, workerAmount));
}
\ No newline at end of file
diff --git a/js/senha.js b/js/senha.js
index 83c5b2f..1411c1b 100644
--- a/js/senha.js
+++ b/js/senha.js
@@ -82,7 +82,7 @@ function startNewGame(pAmountOfCharacters = 5) {
translate.translateString("senha-gamestarted", randomSequence).then(str => {
console.log(str);
});
- translate.setElementString(document.getElementById("valid-characters"), new TranslatableText("senha-validcharacters", validCharacters));
+ setElementString(document.getElementById("valid-characters"), new TranslatableText("senha-validcharacters", validCharacters));
amountOfCharactersInput.max = validCharacters.length;
updateKeyboard();
addNewCharacterSlotArray();
@@ -157,7 +157,7 @@ document.addEventListener("keyup", (event) => {
let charactersInSlotArray = getCharacterSlotArrayAsString();
if (!charactersInSlotArray.includes(' ') && !hasDuplicateLetters(charactersInSlotArray)) {
numberOfAttempts++;
- translate.setElementString(victoryText, new TranslatableText("senha-victory", numberOfAttempts));
+ setElementString(victoryText, new TranslatableText("senha-victory", numberOfAttempts));
if (charactersInSlotArray !== randomSequence) {
addNewGuessesArray(getCorrectInWrongPlace(charactersInSlotArray), getCorrectInCorrectPlace(charactersInSlotArray));
addNewCharacterSlotArray();
diff --git a/js/text.js b/js/text.js
index 1511ac0..7f7db24 100644
--- a/js/text.js
+++ b/js/text.js
@@ -101,4 +101,34 @@ function getTextFromJSON(jsonObject) {
console.log('Invalid text type: ' + key);
}
}
+}
+
+async function setElementString(element, text) {
+ if (text instanceof LiteralText || text instanceof TranslatableText) {
+ text = JSON.stringify(text);
+ }
+ element.dataset.string = text;
+ getTextFromJSON(text).get().then(str => {
+ element.innerHTML = str;
+ });
+}
+
+async function setElementPlaceholder(element, text) {
+ if (text instanceof LiteralText || text instanceof TranslatableText) {
+ text = JSON.stringify(text);
+ }
+ element.dataset.placeholder = text;
+ getTextFromJSON(text).get().then(str => {
+ element.placeholder = str;
+ });
+}
+
+async function setElementAriaLabel(element, text) {
+ if (text instanceof LiteralText || text instanceof TranslatableText) {
+ text = JSON.stringify(text);
+ }
+ element.dataset.ariaLabel = text;
+ getTextFromJSON(text).get().then(str => {
+ element.ariaLabel = str;
+ });
}
\ No newline at end of file
diff --git a/js/translate.js b/js/translate.js
index feab14d..97fc223 100644
--- a/js/translate.js
+++ b/js/translate.js
@@ -93,36 +93,6 @@ class Translate {
async getKeyWrapped(key, ...args) {
return "" + (await this.translateString(key, ...args)) + "";
}
-
- async setElementString(element, text) {
- if (text instanceof LiteralText || text instanceof TranslatableText) {
- text = JSON.stringify(text);
- }
- element.dataset.string = text;
- getTextFromJSON(text).get().then(str => {
- element.innerHTML = str;
- });
- }
-
- async setElementPlaceholder(element, text) {
- if (text instanceof LiteralText || text instanceof TranslatableText) {
- text = JSON.stringify(text);
- }
- element.dataset.placeholder = text;
- getTextFromJSON(text).get().then(str => {
- element.placeholder = str;
- });
- }
-
- async setElementAriaLabel(element, text) {
- if (text instanceof LiteralText || text instanceof TranslatableText) {
- text = JSON.stringify(text);
- }
- element.dataset.ariaLabel = text;
- getTextFromJSON(text).get().then(str => {
- element.ariaLabel = str;
- });
- }
}
var translate = new Translate();