function CometClient(url, queryString, callback) { this.url = url; this.queryString = queryString; this.callback = callback; } CometClient.prototype.connect = function() { var params = { url : this.url, queryString : this.queryString, callback : this.callback }; var xhr = new window.XMLHttpRequest(); window.setInterval(function() { var url = params['url']; xhr.open("POST", url, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { var jsonData = xhr.responseText; params['callback'](jsonData); } }; xhr.send(params['queryString']); }, 2000); } CometClient.prototype.close = function() { // not implemented } function ChartConfiguration(aepId, htmlElementId, renderer) { this.aepId = aepId; this.htmlElementId = htmlElementId; this.renderer = renderer; } function ChartClient() { this.observers = new Array(); this.lastPoll = new Date().getTime(); this.consoleLog = new Array(); } ChartClient.prototype.addObserver = function(observer) { this.observers.push(observer); } ChartClient.prototype.addLogLine = function(data) { var now = new Date(); var h = (now.getHours() < 10) ? "0" + now.getHours() : now.getHours(); var m = (now.getMinutes() < 10) ? "0" + now.getMinutes() : now.getMinutes(); var s = (now.getSeconds() < 10) ? "0" + now.getSeconds() : now.getSeconds(); var content = "[" + h + ":" + m + ":" + s + "] " + data; this.consoleLog.push(content); this.updateConsoleLog(); } ChartClient.prototype.startGraphLoader = function() { var url = "/synleaf/api/bootstrap/views"; var observerJSONtext = JSON.stringify(this.observers); var queryString = jQuery.param({ o: observerJSONtext }); var context = this; jQuery.post(url, queryString, function(data) { context.loadView(data, context); }); } ChartClient.prototype.loadView = function(data, context) { var response = JSON.parse(data); jQuery.each(response['jsFiles'], function(index, objValue) { jQuery('