forked from vapor/api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
94 lines (85 loc) · 2.68 KB
/
index.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
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html>
<head>
<title>Vapor API Docs</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
html, body {
height: 100%;
padding:; 0;
margin: 0;
}
.wrapper {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.main {
margin-top: -50px;
}
.title {
background-image: url(/api-docs.png);
width: 300px;
height: 74px;
background-size: 300px auto;
text-indent: -9999px;
margin-bottom: 0;
}
.nav {
}
</style>
</head>
<body>
<div class="wrapper">
<div class="main">
<h1 class="title">Vapor API Docs</h1>
<br>
<select class="nav">
<option>Choose module...</option>
</select>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var nav = $(".nav");
var tmp = $("<div>");
nav.on("change", function(e) {
var option = $(this).find("option:selected");
$(this).prop('selectedIndex',0);
window.location.href = option.attr("href");
});
tmp.load("/manifest.json", function() {
var modules = {};
var manifest = $.parseJSON(tmp.text());
$.each(manifest, function(i, val) {
if (modules[val.module] == null) {
modules[val.module] = [];
}
modules[val.module].push({
version: val.version,
href: "/" + val.repo + "/" + val.version + "/" + val.module + "/index.html"
});
});
$.each(modules, function(module, versions){
var group = $("<optgroup>");
group.attr("label", module);
$.each(versions.reverse(), function(i, doc) {
var opt = $("<option>");
opt.text(doc.version);
opt.attr("href", doc.href);
group.append(opt);
})
nav.append(group);
});
var items = nav.children("optgroup").sort(function(a, b) {
console.log($(a));
return $(a).attr("label").localeCompare($(b).attr("label"));
});
nav.children("optgroup").remove();
nav.append(items);
});
</script>
</body>
</html>