-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
73 lines (48 loc) · 2.18 KB
/
script.js
File metadata and controls
73 lines (48 loc) · 2.18 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function handleNote(){
var index = 0;
// get the new note once button is clicked
document.querySelector('.add-new-note').addEventListener('click', function (e) {
addNewNote();
});
function addNewNote() {
//get the placeholder tekst into note
var getText = document.querySelector('.textarea').value;
//reset the text area
document.querySelector('.textarea').value = '';
if (getText.length != 0) {
//create the note
var newNoteText = document.createTextNode(getText);
var newNote = document.createElement('DIV');
//add the class of bulma column to each note
newNote.classList.add("column", "box", "is-one-quarter", "newNote");
var newNotePar = document.createElement('P');
newNotePar.classList.add("note-p");
newNote.appendChild(newNotePar);
newNotePar.appendChild(newNoteText);
//create button to modify element with class "note-p"
var btn = document.createElement("BUTTON");
var t = document.createTextNode("modify note");
btn.classList.add("button", "modify-note");
btn.appendChild(t);
//append the new note to the div
var noteNode = document
.querySelector("#note-item")
.appendChild(newNote)
.appendChild(btn);
//add more html to the
noteNode.insertAdjacentHTML("afterend", '<a class="delete deletebtn"></a><p>change the background</p><div class="color-picker"><div id="pickPink"class="color-btn"></div><div id="pickYellow" class="color-btn"></div><div id="pickGreen"class="color-btn"></div></div>');
++index;
}
else {
alert('you did not put any note text. Please type into the text box.');
}
}
//TODO 3. function deleteNote
document.querySelector('.deletebtn').addEventListener('click', function (e) {
console.log('it is clicked');
})
};
handleNote();
//TODO 4. function modifyNote + button to modify it
//TODO 3. function deleteNote
//TODO 5. function pickNoteColor (pick from 4 colours)