-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathapp.js
51 lines (35 loc) · 938 Bytes
/
app.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
50
51
const linkCategory = document.querySelector("#linkCategory");
const submitButton = document.querySelector("#submitButton");
let linkCategories = [];
let links = [];
linkCategory.addEventListener('keydown', function (event) {
if (event.keyCode === 188) {
event.preventDefault();
linkCategories.push(linkCategory.value);
linkCategory.value = '';
//Display the updated categories
displayLinkCategories();
}
})
function displayLinkCategories() {
console.log("Displaying Link Categories");
}
submitButton.addEventListener('click', (event) => {
//Stop form from submitting
event.preventDefault();
const title = linkTitle.value;
const url = linkUrl.value;
const categories = linkCategories;
const newLink = {
title,
url,
categories
}
//push new link to array
links.push(newLink);
linkTitle.value = '';
linkUrl.value = '';
linkCategory.value = '';
linkCategories = [];
displayLinkCategories();
});