-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.html
191 lines (166 loc) · 6.3 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Projek Buku Git</title>
<link href='//fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="css/base.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row top-title">
<div class="col-md-12"><h1>Projek Buku Git</h1></div>
</div>
<div class="row">
<div class="sidebar col-md-3">
<ul class="menu-root">
<li v-for="entry in toc" v-cloak>
<a href="#" @click="openPage(entry.slug)">{{ entry.title }}</a>
<ul class="menu-sub" v-if="entry.sub && entry.sub.length > 0">
<li v-for="sub in entry.sub" :class="{ 'hidden': isNotActiveMenu(entry) }">
<a href="#" @click="openPage(sub.slug)">{{ sub.title }}</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="col-md-9">
<div class="content">
<nav>
<ul class="pager">
<li class="previous" :class="{ 'disabled' : ! hasPreviousPage }"><a href="#" @click="previousPage"><span aria-hidden="true">←</span> Previous</a></li>
<li class="next" :class="{ 'disabled' : ! hasNextPage }"><a href="#" @click="nextPage">Next <span aria-hidden="true">→</span></a></li>
</ul>
</nav>
<div v-if="content != null">{{{ content | marked | shellScript }}}</div>
<div v-else class="jumbotron" v-cloak>
<h1>Error 404</h1>
<p>Page Not Found</p>
</div>
<nav>
<ul class="pager">
<li class="previous" :class="{ 'disabled' : ! hasPreviousPage }"><a href="#" @click="previousPage"><span aria-hidden="true">←</span> Previous</a></li>
<li class="next" :class="{ 'disabled' : ! hasNextPage }"><a href="#" @click="nextPage">Next <span aria-hidden="true">→</span></a></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- script src="lib/markdown.js"></script -->
<script src="js/jquery.min.js"></script>
<script src="js/shell.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/1.0.11/vue.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue-resource/0.5.1/vue-resource.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="toc.js"></script>
<script>
(function (toc) { "use strict"
var vue
Vue.use(VueResource)
function sanitize(name) {
return name.substr(2, name.length - 2).trim()
}
var glossary = (function () {
var prev = null
var glossary = {}
_.forEach(toc, function (entry) {
glossary[entry.slug] = {
title: entry.title,
prev: prev,
next: null
}
if (prev != null) {
glossary[prev].next = entry.slug
}
prev = entry.slug
_.forEach(entry.sub, function (sub) {
glossary[sub.slug] = {
title: sub.title,
prev: prev,
next: null
}
if (prev != null) {
glossary[prev].next = sub.slug
}
prev = sub.slug
})
})
return glossary
}())
var vue = new Vue({
el: 'body',
filters: {
marked: marked,
shellScript: shellScript
},
data: {
glossary: glossary,
toc: toc,
content: '',
page: 'pengenalan'
},
ready: function() {
var page = this.page
if (window.location.hash != '') {
page = sanitize(window.location.hash)
}
this.openPage(page)
},
computed: {
currentPageInfo: function () {
return this.glossary[this.page]
},
hasPreviousPage: function () {
return this.currentPageInfo.prev != null
},
hasNextPage: function () {
return this.currentPageInfo.next != null
}
},
methods: {
openPage: function (page) {
this.$http.get('content/'+page+'.md').then(function (response) {
this.setPage(page, response.data)
}, function () {
this.setPage(page, null)
})
},
setPage: function (page, content) {
this.page = page
this.content = content
document.title = this.currentPageInfo.title
window.location.hash = '!'+page
},
isActiveMenu: function (entry) {
return (this.page == entry.slug || _.filter(entry.sub, {'slug': this.page}).length > 0)
},
isNotActiveMenu: function (entry) {
return ! this.isActiveMenu(entry)
},
previousPage: function () {
var page = this.page
if (this.hasPreviousPage) {
page = this.currentPageInfo.prev
}
return this.openPage(page)
},
nextPage: function () {
var page = this.page
if (this.hasNextPage) {
page = this.currentPageInfo.next
}
return this.openPage(page)
}
}
})
})(toc);
</script>
</body>
</html>