25 lines
911 B
JavaScript
25 lines
911 B
JavaScript
function saveOptions(event) {
|
|
event.preventDefault();
|
|
const serverUrl = document.querySelector("#server-url").value;
|
|
|
|
if (serverUrl.trim() === "") {
|
|
alert("URL сервера не может быть пустым!");
|
|
return;
|
|
}
|
|
|
|
browser.storage.sync.set({ serverUrl }).then(() => {
|
|
const status = document.querySelector("#status");
|
|
status.textContent = "Настройки сохранены!";
|
|
setTimeout(() => (status.textContent = ""), 2000);
|
|
});
|
|
}
|
|
|
|
function restoreOptions() {
|
|
browser.storage.sync.get("serverUrl").then((result) => {
|
|
const serverUrl = result.serverUrl || "http://localhost:5000/submit";
|
|
document.querySelector("#server-url").value = serverUrl;
|
|
});
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", restoreOptions);
|
|
document.querySelector("#settings-form").addEventListener("submit", saveOptions); |