-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
87 lines (73 loc) · 1.9 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const myMiniProject = [
{
"name": "Lab 1",
"Type": "Lab",
},
{
"name": "Worksheet 1",
"Type": "Worksheet"
},
]
const projectByType = [
[
"Lab",
[]
],
[
"Worksheet",
[]
],
]
function getLink(project) {
const partialWord = project.split(" ")
let link = ""
for (word of partialWord) {
link += word.toLowerCase() + "-"
}
link = link.slice(0, link.length-1)
// Route to link
window.location.href = link + "/index.html"
}
const projectList = document.querySelector("#projectList")
// Klasifikasikan subject berdasar tipe
for (Type of projectByType) {
for (project of myMiniProject) {
if (project.Type == Type[0]) {
Type[1].push(project.name)
}
}
}
console.log(projectByType)
// Print HTML sesuai tipe
for (Type of projectByType) {
console.log(Type)
const monthTag = document.createElement('span')
monthTag.className = "tag"
monthTag.innerText = Type[0]
const newLine = document.createElement('br')
if (Type[1].length != 0) {
// Ketika ada isinya maka tag tipe dibuat
projectList.append(monthTag)
projectList.append(newLine)
for (project of Type[1]) {
const ahref = document.createElement('a')
ahref.src = project
const boxx = document.createElement('div')
boxx.className = "box is-me"
boxx.innerText = project
projectList.append(boxx)
}
}
}
setInterval(() => {
const allMiniProject = document.querySelectorAll('div')
for (miniProject of allMiniProject) {
console.log(miniProject)
if (miniProject.className == "box is-me") {
miniProject.addEventListener('click', function () {
console.log("EH")
getLink(this.innerText)
});
}
}
}, 1000)