From 9848b90bd9eddf0324ffdc0d8f089c6c24683fe8 Mon Sep 17 00:00:00 2001 From: artem Date: Fri, 22 Feb 2008 15:28:41 +0000 Subject: - [DEV-118] added dashboard screen to monitoring (Artem) - [ZBX-206] merged rev.5367:5370 of 1.4/ (Artem) [fixed case sensitive hosts sorting] - [DEV-119] changes how users online are counted (Artem) - implemented patch [added y axis calculation type: "Calculated [Min=0]"] (Artem) - changes in schema.sql (Artem) - fixed JS lib, url class (Artem) - some other small fixes (Artem) git-svn-id: svn://svn.zabbix.com/trunk@5387 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/js/json.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 frontends/php/js/json.js (limited to 'frontends/php/js/json.js') diff --git a/frontends/php/js/json.js b/frontends/php/js/json.js new file mode 100644 index 00000000..797e314c --- /dev/null +++ b/frontends/php/js/json.js @@ -0,0 +1,105 @@ +// JavaScript Document +function callJSON(){ +// json.clean(); + json.createScript('dashboard.php?output=json'); + json.buildAll(); + json.addAll(); +} + +var json = { +scripts: new Array(), // array of existing scripts id's +nextId: 1, // id of next script tag + +head: '', // DOM Head obj + +initialize: function(){ + this.head = document.getElementsByTagName("head").item(0); +}, + +callBack: function(){ + if(this.callBack.arguments.length > 0) + alert(this.callBack.arguments[0]) + else + alert('callBack!'); +}, + +onetime: function(url){ + var onetimeid; + onetimeid = this.createScript(url); + this.buildScript(onetimeid); + this.addScript(onetimeid); +}, + +createScript: function(url){ + this.scripts[this.nextId] = { + 'id': this.nextId, + 'fullurl': url+'&jsscriptid='+this.nextId, + 'noCacheIE': '&noCacheIE=' + (new Date()).getTime(), + 'scriptId': 'JscriptId' + this.nextId, + 'status': 1 + }; +//SDI('create:' + this.nextId); + this.nextId++; +return (this.nextId-1); +}, + +buildScript: function(id){ + if(isset(id)){ + if(isset(this.scripts[id]) && !empty(this.scripts[id]) && (this.scripts[id].status == 1)){ + var scriptObj = document.createElement("script"); + + // Add script object attributes + scriptObj.setAttribute("type", "text/javascript"); + scriptObj.setAttribute("charset", "utf-8"); + + scriptObj.setAttribute("src", this.scripts[id].fullurl+this.scripts[id].noCacheIE); + + scriptObj.setAttribute("id", this.scripts[id].scriptId); + + this.scripts[id].scriptObj = scriptObj; + this.scripts[id].status = 2; + } + } +}, + +buildAll: function() { + for(var i=1; i < this.nextId; i++){ + this.buildScript(i); + } +}, + +addScript: function(id){ + if(isset(id)){ + if(isset(this.scripts[id]) && !empty(this.scripts[id]) && (this.scripts[id].status == 2)){ + this.head.appendChild(this.scripts[id].scriptObj); + this.scripts[id].status = 3; + } + } +}, + +addAll: function(){ + for(var i=1; i < this.nextId; i++){ + this.addScript(i); + } +}, + +removeScript: function(id){ + if(isset(id)){ + if(isset(this.scripts[id]) && !empty(this.scripts[id]) && (this.scripts[id].status == 3)){ +//SDI('remove:'+this.scripts[id].scriptId); + this.head.removeChild(this.scripts[id].scriptObj); + this.scripts[id] = null; + } + } +}, + +clean: function(){ + for(var i=1; i < this.nextId; i++){ + this.removeScript(i); + } + this.scripts = new Array(); + this.nextId = 1; +} +} + +json.initialize(); \ No newline at end of file -- cgit