refactor + documentation
This commit is contained in:
parent
0a69f12cb7
commit
97a173ad47
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Get stored word list from chrome storage
|
// Get stored word list from chrome storage
|
||||||
chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel"], (data) => {
|
chrome.storage.local.get(["vocabulary", "kanji", "validUserLevel"], (data) => {
|
||||||
|
// The users level is not valid, e.g. it exceeds the maximum allowed level
|
||||||
|
// WaniKani requires that devs check if users are actually allowed to access content of this level
|
||||||
if(!data.validUserLevel)
|
if(!data.validUserLevel)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
3
popup.js
3
popup.js
|
@ -1,10 +1,12 @@
|
||||||
const submitButton = document.getElementById("submit-token")
|
const submitButton = document.getElementById("submit-token")
|
||||||
const inputField = document.getElementById("token");
|
const inputField = document.getElementById("token");
|
||||||
|
|
||||||
|
// Set the wanikani token
|
||||||
submitButton.addEventListener( "click", () => {
|
submitButton.addEventListener( "click", () => {
|
||||||
chrome.storage.local.set({"token": inputField.value})
|
chrome.storage.local.set({"token": inputField.value})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Sync local data with wanikani
|
||||||
const downloadButton = document.getElementById("download")
|
const downloadButton = document.getElementById("download")
|
||||||
downloadButton.addEventListener("click", async () => {
|
downloadButton.addEventListener("click", async () => {
|
||||||
var loadingText = document.getElementById("loading")
|
var loadingText = document.getElementById("loading")
|
||||||
|
@ -18,6 +20,7 @@ downloadButton.addEventListener("click", async () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Display currently used wanikani level
|
||||||
chrome.storage.local.get("level", (data) => {
|
chrome.storage.local.get("level", (data) => {
|
||||||
const levelSpan = document.getElementById("level")
|
const levelSpan = document.getElementById("level")
|
||||||
levelSpan.innerHTML = data.level
|
levelSpan.innerHTML = data.level
|
||||||
|
|
Loading…
Reference in a new issue