parent
7d8f813e2c
commit
5eda7ae889
|
|
@ -18,6 +18,11 @@
|
||||||
var notesElement = document.getElementById("notes");
|
var notesElement = document.getElementById("notes");
|
||||||
var notes = {};
|
var notes = {};
|
||||||
|
|
||||||
|
function disableFormInput() {
|
||||||
|
document.querySelectorAll(".form-input").forEach(el => el.disabled = true);
|
||||||
|
document.querySelectorAll(".btn").forEach(el => el.disabled = true);
|
||||||
|
}
|
||||||
|
|
||||||
function getData() {
|
function getData() {
|
||||||
// show loading window
|
// show loading window
|
||||||
Util.showModal("Loading...");
|
Util.showModal("Loading...");
|
||||||
|
|
@ -53,8 +58,10 @@ function getData() {
|
||||||
buttonSave.classList.add('btn-default');
|
buttonSave.classList.add('btn-default');
|
||||||
buttonSave.onclick = function() {
|
buttonSave.onclick = function() {
|
||||||
notes[i].note = textarea.value;
|
notes[i].note = textarea.value;
|
||||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
disableFormInput();
|
||||||
location.reload();
|
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||||
|
location.reload(); // reload so we see current data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
divColumn2.appendChild(buttonSave);
|
divColumn2.appendChild(buttonSave);
|
||||||
|
|
||||||
|
|
@ -64,8 +71,10 @@ function getData() {
|
||||||
buttonDelete.onclick = function() {
|
buttonDelete.onclick = function() {
|
||||||
notes[i].note = textarea.value;
|
notes[i].note = textarea.value;
|
||||||
notes.splice(i, 1);
|
notes.splice(i, 1);
|
||||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
disableFormInput();
|
||||||
location.reload(); // reload so we see current data
|
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||||
|
location.reload(); // reload so we see current data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
divColumn2.appendChild(buttonDelete);
|
divColumn2.appendChild(buttonDelete);
|
||||||
divColumn.appendChild(divColumn2);
|
divColumn.appendChild(divColumn2);
|
||||||
|
|
@ -77,8 +86,10 @@ function getData() {
|
||||||
document.getElementById("btnAdd").addEventListener("click", function() {
|
document.getElementById("btnAdd").addEventListener("click", function() {
|
||||||
const note = document.getElementById("note-new").value;
|
const note = document.getElementById("note-new").value;
|
||||||
notes.push({"note": note});
|
notes.push({"note": note});
|
||||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
disableFormInput();
|
||||||
location.reload(); // reload so we see current data
|
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||||
|
location.reload(); // reload so we see current data
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue