summaryrefslogtreecommitdiffstats
path: root/index.html
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-05-13 02:19:14 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-05-13 02:24:09 +0200
commitbf51125c3bbed47e6fa040f1f726fa0ea8627299 (patch)
tree54c910005cfb58699eebb6962b75c15572cb5523 /index.html
parent9236c30df74a27c987d8e82169bc7730141bfc63 (diff)
downloadwww-bf51125c3bbed47e6fa040f1f726fa0ea8627299.tar.gz
www-bf51125c3bbed47e6fa040f1f726fa0ea8627299.tar.bz2
www-bf51125c3bbed47e6fa040f1f726fa0ea8627299.zip
add html5 history
Diffstat (limited to 'index.html')
-rw-r--r--index.html37
1 files changed, 30 insertions, 7 deletions
diff --git a/index.html b/index.html
index 390a354..b75d6b1 100644
--- a/index.html
+++ b/index.html
@@ -44,6 +44,7 @@
<script src="js/js-yaml.min.js"></script>
<script src="js/jquery-2.0.0.min.js"></script>
+ <script src="js/jquery.history.js"></script>
<script src="js/jquery.mustache.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/mustache.js"></script>
@@ -67,11 +68,13 @@
}
$.Mustache.load('./templates/index.html').done(function () {
- $('#content').mustache('hosts', {'hosts':hosts});
+ $('#content').mustache('hosts', {'hosts':hosts}, {method: 'html'});
$("#hosts a").click("hover", function(event){
var uri = $(this).attr('data-uri');
render.host(uri);
+ History.pushState({host: uri}, $(this).attr('innerHtml'), 'index.html?'+uri);
+ return false;
});
});
});
@@ -88,20 +91,40 @@
}), function(obj, key) { obj.device = key; return obj; });
$.Mustache.load('./templates/host.html').done(function () {
- $('#content').mustache('hostinfo', data, {method:'html'});
- });
+ $('#content').mustache('hostinfo', data, {method: 'html'});
- $("#index").click("hover", function(event){
- render.index();
+ $("#index").click("hover", function(event){
+ render.index();
+ History.pushState({host: undefined}, 'Overview', 'index.html');
+ return false;
+ });
});
});
}
};
$(document).ready(function() {
- render.index();
- });
+ var History = window.History;
+ if (History.enabled) {
+ History.Adapter.bind(window,'statechange',function(){
+ var State = History.getState();
+ if (State.data.host) {
+ render.host(State.data.host);
+ }
+ else {
+ render.index();
+ }
+ });
+ }
+ var host = window.location.search.split('?')[1] || undefined;
+ if (host) {
+ render.host(host);
+ }
+ else {
+ render.index();
+ }
+ });
</script>
</head>
<body>