-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfactoids.js
49 lines (39 loc) · 1.3 KB
/
factoids.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const scoutingContainer = document.querySelector(".notes-container");
const makeButton = document.querySelector(".button");
let notes = document.querySelectorAll(".input-box");
//Shows saved notes
function showScoutFactoids() {
scoutingContainer.innerHTML = localStorage.getItem("notes");
}
showScoutFactoids();
document.getElementById("mapButton").addEventListener("click", () => {
window.location.href = "setup.html";
});
//Updates local memory when changes are made
function updateMem() {
localStorage.setItem("notes", scoutingContainer.innerHTML);
}
//Creates a blog
makeButton.addEventListener("click", ()=>{
let inputBox = document.createElement("p");
let img = document.createElement("img");
inputBox.className = "input-box";
inputBox.setAttribute("contenteditable", "true");
img.src = "images/TrashCan.png";
scoutingContainer.appendChild(inputBox).appendChild(img);
})
//Deletes a blog
scoutingContainer.addEventListener("click", function(e){
if(e.target.tagName === "IMG"){
e.target.parentElement.remove();
updateMem();
}
else if(e.target.tagName === "P") {
notes = document.querySelectorAll(".input-box");
notes.forEach(nt => {
nt.onkeyup = function() {
updateMem();
}
})
}
})