Object.values = function(o) { var values = []; for(var property in o) { values.push(o[property]); } return values; } function encodeID( t ) { return ("" + t).replace( /[\.\/]/g, "_"); } /* function SKYAPI(baseurl){ this.baseurl = baseurl; this.refresh = [] this.setBaseURL = function(url){ this.baseurl = url; } this.addRefresh = function( rh, seconds = null ){ this.refresh.push( { interval: seconds ? seconds : 5, refresh: rh } ); } this.get = function(page, json, handler = null){ return this.__request("GET", page, json, handler); } this.post = function(page, json, handler = null){ return this.__request("POST", page, json, handler); } this.put = function(page, json, handler = null){ return this.__request("PUT", page, json, handler); } this.__request = function(method, page, json, handler = null){ if (page[0] == '/') page = page.substr(1); var x = new XMLHttpRequest(); if (handler != null) { x.onload = function(){ var responseText = x.responseText; if (json && !content) handler( JSON.parse( responseText ) ); else handler( responseText ); } } x.open(method, this.baseurl + page); if (json) x.send(JSON.stringify(json)); else x.send(); } this.getJson = function(page, handler){ var j = function(t){ handler(JSON.parse(t)); }; return this.get( page, null, j ); } this.call = function(endpoint,method,parameters = [], receiver = null){ var x = new XMLHttpRequest(); x.open("POST", this.baseurl + endpoint, (receiver != null)); x.setRequestHeader("content-type","application/json"); if (receiver) { x.onload = function(){ var r = JSON.parse(this.responseText).Result; receiver(r); } x.onerror = function(){ receiver(false); } } var methodCall = { "MethodName": method, "Parameters": parameters } x.send(JSON.stringify(methodCall)); if (!receiver) { var result = JSON.parse(x.responseText); if (result.Exception != null) throw result.Exception; return result.Result; } return x; } this.loadPage = function (page) { if (page[0] == '/') page = page.substr(1); var x = new XMLHttpRequest(); x.open("GET", this.baseurl + page); x.setRequestHeader("x-template-unframed","unframed"); x.onload = function() { $("#content").empty(); $("#content").append(this.responseText); history.pushState(null, page, skyapi().baseurl + page); } this.refresh = [] x.send(); return false; } this.fireOnLoad = function(element){ if (element.onload != null) { element.onload(); } for (var n=0;n 1000000000) return ((value / 1000000000) | 0) + "G"; if (value > 1000000) return ((value / 1000000) | 0) + "M"; if (value > 1000) return ((value / 1000) | 0) + "k"; return value; }