-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
48 lines (41 loc) · 1.38 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>eRouter - Super easy uri router</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Super easy uri router <a target="_blank" id="home" href="https://github.com/frentsel/eRouter">GitHub</a></h1>
<ul>
<li><a href="#!/" class="active">Home</a></li>
<li><a href="#!/contact">Contact</a></li>
<li><a href="#!/product/first-product">Product 1</a></li>
<li><a href="#!/product/second-product/some-product-title/price-345">Product 2*</a></li>
</ul>
<div id="view"></div>
<footer>
<a href="https://github.com/frentsel/eRouter">Super easy hash router</a> © 2017
</footer>
<img id="loader" src="loading.gif">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="eRouter.js"></script>
<script>
const render = (view, params) => {
$('body').addClass('loading');
$('a').removeClass('active');
$(`a[href="${window.location.hash}"]`).addClass('active');
$("#view").load(`pages/${view}.html`, () => {
$('body').removeClass('loading');
$("#params").html(params ? JSON.stringify(params, null, 2) : "[]");
});
};
new eRouter({
index: (...params) => render('index', params),
contact: (...params) => render('contact', params),
product: (...params) => render('product', params),
notFound: (page) => render('notFound', page)
});
</script>
</body>
</html>