-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
56 lines (51 loc) · 1.41 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
<html>
<head>
<title>My Awesome Hafcaf App</title>
<link rel="stylesheet" href="hafcaf.css">
</head>
<body>
<nav role="navigation">
<ul id="nav-list">
<li>
<a href="#home">Home</a>
</li>
<li>
<a href="#another-view">Page 2</a>
</li>
</ul>
</nav>
<main id="main-container" role="main">
<div id="another-view">
<h1>Page 2</h1>
<p>This is another view.</p>
</div>
<div id="home">
<h1>Home</h1>
<p>Static content is the best content.</p>
</div>
</main>
<script src="hafcaf.js" type="text/javascript"></script>
<script type="text/javascript">
var anotherView = {
id: 'another-view',
onRender: function () {
console.log('this view is "another-view"');
}
};
hafcaf.addRoute(anotherView);
var exampleDynamicView = {
id: 'page-3',
linkLabel: "Page 3",
innerHTML: "<h1>Page 3</h1><p>This page was added dynamically at run-time. It could have been loaded via fetch or AJAX if desired.</p><button id='backHomeButton'>Go back to Home page</button>",
onRender: function () {
console.log('page 3 rendered');
// demo of adding event listeners
document.getElementById('backHomeButton').addEventListener('click', function () {
window.location.hash = 'home';
});
}
};
hafcaf.addRoute(exampleDynamicView);
</script>
</body>
</html>