forked from ale958/Sweky
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGlossario.html
85 lines (70 loc) · 2.99 KB
/
Glossario.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SWEky - La wiki di SWE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script type="text/javascript" src="js/jquery.js"></script>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
<script>
$(function () {
$("#wrapper").load('commonBody.html', function () {
$("#glossario").attr("href", "#");
getGlossario();
$.getScript("js/index.js");
});
});
function sortFunction(a, b) {
return (a.word).localeCompare(b.word);
}
function getGlossario() {
$('#contento').append('<h2 class="page-header">Glossario</h2>');
$.getJSON('./src/glossary.json', function (json) {
let curLetter = 'Z';
let rowNum = 1;
let tabNum = 1;
let mydiv = '';
let arr = $.map(json, function (el) {
return el
});
arr.sort(sortFunction);
for (i = 0; i < arr.length; i++) {
if ((arr[i].word).charAt(0) != curLetter) {
if (mydiv != '')
mydiv += '</div> </div> </div>';
curLetter = (arr[i].word).charAt(0);
mydiv += '<div class="panel-group"><div class="panel panel-default"><div id="' + curLetter + '" class="panel-heading" data-toggle="collapse" href="#collapse' + tabNum + '"> <h3 class="panel-title">' + curLetter + '</h3> </div> <div id="collapse' + tabNum + '" class="panel-collapse collapse"> <dl class="list-group">'
rowNum = 1;
tabNum++;
}
if (rowNum % 2 == 0) {
mydiv += '<span class="list-group-item evenRow">'
} else mydiv += '<span class="list-group-item">'
mydiv += '<dt>' + arr[i].word + '</dt>';
mydiv += '<dd>' + arr[i].definition + '</dd></span>';
rowNum++;
}
;
mydiv += '</div> </div> </div>';
let html = $.parseHTML(mydiv);
$('#contento').append(html);
});
}
</script>
<style>
#glossario {
background-color: #47ADA3;
font-weight: bold;
}
</style>
</head>
<body>
<div id="wrapper">
</div>
</body>
</html>