var SKY = null; (function(){ var options = { url: "/", types: { } } var refreshTimer = null; var refreshInterval = null; var refreshList = []; var refreshCounter = 0; class SKYBase { constructor(){ this._html = $(); } html(html){ if (arguments.length) { this._html = html; return this; } return this._html; } on( evName, h ){ if (!self[evName]) self[evName] = []; self[evName].push(h); return this; } off( evName ){ self[evName] = [] return this; } fire( evName, p ){ if (self[evName]) self[evName].forEach( function(h){ h(p); } ); return this; } } function SkyAPI(){ this.options = function(o){ options = Object.assign(options, o); } /* Refresh API */ this.refresh = function( name, interval, f){ if (!interval) { 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; } function BytesToString(bytestring, sep = ":") { return Array.from( bytestring, function(b){ return ('0' + b.charCodeAt(0).toString(16)).slice(-2); }).join(sep); } function DecodeMAC(b64mac) { var smac = atob(b64mac); return BytesToString(smac); } function PopulateForm( o, options = {} ) { var opt = Object.assign( { top: null, transform: function(v){ return v; }, properties: {}, }, options ); for (const key in o) { var po = Object.assign( { transform: opt.transform, }, opt.properties[key]); var i = $("#" + key, opt.top); if (i.length) i.val( po.transform(o[key]) ); } }