Skip to content

Commit

Permalink
fix firefox bug #15
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax authored Sep 18, 2024
1 parent d6d13bb commit 50c2264
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions public/assets/salam/script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,27 @@ elm_code.addEventListener('keydown', (event) => {
});

elm_code.addEventListener("input", () => {
localStorage.setItem("code", elm_code.value)
elm_copy_code.value = elm_code.value
runSalam(false);
localStorage.setItem("code", elm_code.value)
elm_copy_code.value = elm_code.value
runSalam(false);
});

elm_run_code.addEventListener("click", () => {
elm_copy_code.value = elm_code.value
runSalam(false)
elm_copy_code.value = elm_code.value
runSalam(false)
})

elm_refactor.addEventListener("click", () => {
runLint()
runLint()
})

elm_save.addEventListener("click", (e) => {
if (elm_title.classList.contains("hidden")){
e.preventDefault()
elm_title.classList.remove("hidden")
elm_title.classList.remove("w-0")
elm_title.classList.remove("p-0")
}
if (elm_title.classList.contains("hidden")){
e.preventDefault()
elm_title.classList.remove("hidden")
elm_title.classList.remove("w-0")
elm_title.classList.remove("p-0")
}
})

// Init
Expand All @@ -189,10 +189,14 @@ document.body.appendChild(script);

window.addEventListener('load', () => {
elm_code.focus();
if (elm_code.value.trim() === ""){
elm_code.value = localStorage?.getItem("code")
}
elm_copy_code.value = elm_code.value

if (elm_code.value.trim() === "") {
if (localStorage && localStorage.getItem) {
elm_code.value = localStorage.getItem("code");
}
}

elm_copy_code.value = elm_code.value;
});

// Cache
Expand Down

0 comments on commit 50c2264

Please sign in to comment.