replaced innerHTML with innerText

This commit is contained in:
Lauchmelder 2022-04-01 14:07:30 +02:00
parent fbf68d06d5
commit 4d67d66d8e
No known key found for this signature in database
GPG key ID: C2403C69D78F011D
2 changed files with 19 additions and 19 deletions

View file

@ -30,10 +30,10 @@ chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel", "enabled", "e
if(data.enabled)
{
if(data.enabledVocab)
vocabStyleSheet.innerHTML = vocabStyle
vocabStyleSheet.innerText = vocabStyle
if(data.enabledKanji)
kanjiStyleSheet.innerHTML = kanjiStyle
kanjiStyleSheet.innerText = kanjiStyle
}
const vocabulary = data.vocabulary
@ -81,15 +81,15 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// If everything is disabled, disable all stylsheets
if(!data.enabled)
{
vocabStyleSheet.innerHTML = ""
kanjiStyleSheet.innerHTML = ""
vocabStyleSheet.innerText = ""
kanjiStyleSheet.innerText = ""
return
}
// Otherwise set the kanji and vocab stylesheets depending on their settings
vocabStyleSheet.innerHTML = data.enabledVocab ? vocabStyle : ""
kanjiStyleSheet.innerHTML = data.enabledKanji ? kanjiStyle : ""
vocabStyleSheet.innerText = data.enabledVocab ? vocabStyle : ""
kanjiStyleSheet.innerText = data.enabledKanji ? kanjiStyle : ""
sendResponse(true)
})

View file

@ -12,31 +12,31 @@ chrome.storage.local.get(["level", "token", "enabled", "enabledVocab", "enabledK
// If no token is set, display exlamation mark and checkmark button
if(data.token === undefined)
{
statusField.innerHTML = String.fromCodePoint(0x2757)
submitButton.innerHTML = String.fromCodePoint(0x2705)
statusField.innerText = String.fromCodePoint(0x2757)
submitButton.innerText = String.fromCodePoint(0x2705)
submitButton.classList.add("no-token")
}
else // else display checkmark and reload button
{
statusField.innerHTML = String.fromCodePoint(0x2705)
submitButton.innerHTML = String.fromCodePoint(0x1F501)
statusField.innerText = String.fromCodePoint(0x2705)
submitButton.innerText = String.fromCodePoint(0x1F501)
}
// Display the users current WaniKani level
const levelSpan = document.getElementById("level")
levelSpan.innerHTML = data.level
levelSpan.innerText = data.level
// If the input field contains text that is not the current token, turn the
// button into a checkmark (else turn it into a repeat button)
inputField.addEventListener("input", () => {
if(inputField.value !== "" && inputField.value !== data.token)
{
submitButton.innerHTML = String.fromCodePoint(0x2705)
submitButton.innerText = String.fromCodePoint(0x2705)
submitButton.classList.add("new-token")
}
else
{
submitButton.innerHTML = String.fromCodePoint(0x1F501)
submitButton.innerText = String.fromCodePoint(0x1F501)
submitButton.classList.remove("new-token")
}
})
@ -60,25 +60,25 @@ submitButton.addEventListener( "click", () => {
if(submitButton.classList.contains("no-token"))
return
statusField.innerHTML = String.fromCodePoint(0x23F1)
statusField.innerText = String.fromCodePoint(0x23F1)
// Sync with wanikani
chrome.runtime.sendMessage("", {type: "sync"}, response => {
if(response.success)
{
statusField.innerHTML = String.fromCodePoint(0x2705)
errorField.innerHTML = ""
statusField.innerText = String.fromCodePoint(0x2705)
errorField.innerText = ""
// Update the users current WaniKani level
chrome.storage.local.get("level", (data) => {
const levelSpan = document.getElementById("level")
levelSpan.innerHTML = data.level
levelSpan.innerText = data.level
})
}
else
{
statusField.innerHTML = String.fromCodePoint(0x2757)
errorField.innerHTML = response.error
statusField.innerText = String.fromCodePoint(0x2757)
errorField.innerText = response.error
}
})
})