-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (44 loc) · 1.67 KB
/
Copy pathmain.js
File metadata and controls
56 lines (44 loc) · 1.67 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
import {ArticlesDB} from './_database/material-apoio.js'
import exercises from "./_database/exercises.js";
import presentations from "./_database/presentations.js";
const articleTemplate = (el) => {
return `<a href="${el.href}" target="_blank" class="article_card" data-type="${el.category}">
<span class="article_card__title">${el.label}</span>
<span class="article_card__category">${el.category}</span>
</a>`;
};
const exerciseTemplate = (el) => {
return `<a href="${el.href}" data-exercise="${el.category}" target="_blank" class="presentation_card" data-type="Exercise">
<div class='presentation_card__wrapper'>
<span class="presentation_card__title">${el.label}</span>
</div>
</a>`;
};
const presentationTemplate = (el) => {
return `<a href="${el.href}" data-exercise="${el.category}" target="_blank" class="presentation_card" data-type="Presentation">
<div class='presentation_card__wrapper'>
<span class="presentation_card__title">${el.label}</span>
</div>
</a>`;
};
class Chapter {
show = false
data = this.data
populateData = (anchor, template) => {
const anchorElement = document.getElementById(anchor)
this.data.forEach(el => {
if (!el.hidden) {
anchorElement.innerHTML += template(el);
}
})
}
}
const Articles = new Chapter();
const Exercises = new Chapter();
const Presentations = new Chapter();
Articles.data = ArticlesDB;
Articles.populateData("articles", articleTemplate);
Exercises.data = exercises;
Exercises.populateData("exercises", exerciseTemplate);
Presentations.data = presentations;
Presentations.populateData("presentations", presentationTemplate);