diff options
Diffstat (limited to 'index.html')
-rw-r--r-- | index.html | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -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> |