summaryrefslogtreecommitdiffstats
path: root/js/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/page.js')
-rw-r--r--js/page.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/js/page.js b/js/page.js
deleted file mode 100644
index 6177e41..0000000
--- a/js/page.js
+++ /dev/null
@@ -1,84 +0,0 @@
-var strip = function(data) { return data.split('.')[0] };
-
-render = {
- 'index' : function() {
- jQuery.get('data/metadata/hosts', function(raw) {
- var data = jsyaml.load(raw),
- hosts = [];
-
- for(var i=0; i < data.hosts.length; i++) {
- var entry = data.hosts[i];
- hosts.push({
- 'name' : strip(entry),
- 'uri' : entry
- });
- }
-
- $.Mustache.load('./templates/index.html').done(function () {
- $('#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}, 'Hostinfo: ' + uri, 'index.html?'+uri);
- return false;
- });
- });
- });
- },
-
- 'host' : function(uri) {
- jQuery.get('data/'+uri, function(raw) {
- var data = jsyaml.load(raw);
-
- data.name = strip(data.hostname);
- data.interfaces = _.map(
- _.groupBy(
- _.filter(data.addresses, function(x) {
- return typeof x.vserver == 'undefined';
- }),
- function(x) {
- return x.interface;
- }),
- function(obj, key) {
- obj.device = key;
- return obj;
- });
-
- $.Mustache.load('./templates/host.html').done(function () {
- $('#content').mustache('hostinfo', data, {method: 'html'});
-
- $("#index").click("hover", function(event){
- render.index();
- History.pushState({host: undefined}, 'Hostinfo: Overview', 'index.html');
- return false;
- });
- });
- });
- }
-};
-
-$(document).ready(function() {
- 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);
- document.title = 'Hostinfo: ' + host;
- History.replaceState({host: host}, 'Hostinfo: ' + host, 'index.html?' + host);
- }
- else {
- render.index();
- }
-});