-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
74 lines (63 loc) · 2.24 KB
/
index.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
function renderTutorials(tutorialDictionary) {
for (const key in tutorialDictionary) {
const tutorial = tutorialDictionary[key];
console.log(tutorial);
console.log(key);
var tutorialDiv = $(
'<div id="tutorial_' + key + '" class="solution col-12 col-md-6"></div>'
);
var tutorialHeadlineDiv = $(
'<h2 id="tutorial_' + key + '_headline" class="solutionheadline"></h2>'
);
tutorialHeadlineDiv.text(tutorial.title);
var tutorialHeadSubtitle = $(
'<h3 id="tutorial_' +
key +
' class="solution col-12 col-md-6">prueba</h3>'
);
tutorialHeadSubtitle.text(tutorial.subtitle);
tutorialDiv.append(tutorialHeadlineDiv);
tutorialDiv.append(tutorialHeadSubtitle);
var solutionBodyDiv = $(
'<div id="solution_body_' + key + '" class="solutionbody"></div>'
);
var solutionSnippetDiv = $(
'<div id="tutorial_' + key + '_snippet" class="solutionsnippet"></div>'
);
if (tutorial.links.length > 0) {
var tutorialsLinksList = $(
'<ul class="list-group list-group-flush"></ul>'
);
for (let tutorialLinks = 0;tutorialLinks < tutorial.links.length;tutorialLinks++) {
let name = tutorial.links[tutorialLinks].name;
let link = tutorial.links[tutorialLinks].url;
let tutorialSite = $('<li class="list-group-item"></li>');
let tutorialSiteLink = $('<a href="' + link + '"/>');
tutorialSiteLink.text(name);
tutorialSite.append(tutorialSiteLink);
tutorialsLinksList.append(tutorialSite);
}
}
solutionSnippetDiv.text(tutorial.description);
solutionBodyDiv.append(solutionSnippetDiv);
solutionBodyDiv.append(tutorialsLinksList);
tutorialDiv.append(solutionBodyDiv);
$("#solutioncontent").append(tutorialDiv);
}
}
window.onpopstate = () => {
search();
};
async function main() {
let tutorialsJson = await $.ajax({
url: "tutorials.json?r=" + Math.random() * 10000,
});
console.log(tutorialsJson);
$("head").append(
'<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Sharp" rel="stylesheet">'
);
var flexDiv = $('<div id="solutioncontent" class="row"></div>');
$("#content").append(flexDiv);
renderTutorials(tutorialsJson);
}
main();