- request.get(
- {
- "command": "show",
- "session": this.sessionID,
- "start": this.currentStart,
- "num": this.currentNum,
- "sort": this.currentSort,
- "block": 1
- },
- function(data) {
- if ( data.getElementsByTagName("status")[0]
- .childNodes[0].nodeValue == "OK" ) {
- // first parse the status data send along with records
- // this is strictly bound to the format
- var activeClients =
- Number( data.getElementsByTagName("activeclients")[0]
- .childNodes[0].nodeValue );
- context.activeClients = activeClients;
- var show = {
- "activeclients": activeClients,
- "merged":
- Number( data.getElementsByTagName("merged")[0]
- .childNodes[0].nodeValue ),
- "total":
- Number( data.getElementsByTagName("total")[0]
- .childNodes[0].nodeValue ),
- "start":
- Number( data.getElementsByTagName("start")[0]
- .childNodes[0].nodeValue ),
- "num":
- Number( data.getElementsByTagName("num")[0]
- .childNodes[0].nodeValue ),
- "hits": []
- };
- // parse all the first-level nodes for all <hit> tags
- var hits = data.getElementsByTagName("hit");
- var hit = new Array();
- for (i = 0; i < hits.length; i++) {
- show.hits[i] = new Array();
- show.hits[i]['location'] = new Array();
- var locCount = 0;
- for ( j = 0; j < hits[i].childNodes.length; j++) {
- if ( hits[i].childNodes[j].nodeType
- == Node.ELEMENT_NODE ) {
- if (hits[i].childNodes[j].nodeName
- == 'location') {
- var locNode = hits[i].childNodes[j];
- var id = locNode.getAttribute('id');
- show.hits[i]['location'][locCount] = {
- "id": locNode.getAttribute("id"),
- "name": locNode.getAttribute("name")
- };
- locCount++;
- }
- else {
- var nodeName =
- hits[i].childNodes[j].nodeName;
- var nodeText = 'ERROR'
- if ( hits[i].childNodes[j].firstChild )
- nodeText =
- hits[i].childNodes[j]
- .firstChild.nodeValue;
- show.hits[i][nodeName] = nodeText;
- }
- }
- }
- }
- context.showCounter++;
- var delay = context.showTime;
- if (context.showCounter > context.showFastCount)
- delay += context.showCounter * context.dumpFactor;
- if ( activeClients > 0 )
- context.showTimer = setTimeout(
- function () {
- context.show();
- },
- delay);
+ var requestParameters =
+ {
+ "command": "show",
+ "session": this.sessionID,
+ "start": this.currentStart,
+ "num": this.currentNum,
+ "sort": this.currentSort,
+ "block": 1,
+ "type": this.showResponseType,
+ "windowid" : this.windowid
+ };
+ if (query_state)
+ requestParameters["query-state"] = query_state;
+ if (this.version && this.version > 0)
+ requestParameters["version"] = this.version;
+ request.safeGet(
+ requestParameters,
+ function(data, type) {
+ var show = null;
+ var activeClients = 0;
+ if (type === "json") {
+ show = {};
+ activeClients = Number(data.activeclients[0]);
+ show.activeclients = activeClients;
+ show.merged = Number(data.merged[0]);
+ show.total = Number(data.total[0]);
+ show.start = Number(data.start[0]);
+ show.num = Number(data.num[0]);
+ show.hits = data.hit;
+ } else if (data.getElementsByTagName("status")[0]
+ .childNodes[0].nodeValue == "OK") {
+ // first parse the status data send along with records
+ // this is strictly bound to the format
+ activeClients =
+ Number(data.getElementsByTagName("activeclients")[0]
+ .childNodes[0].nodeValue);
+ show = {
+ "activeclients": activeClients,
+ "merged":
+ Number( data.getElementsByTagName("merged")[0]
+ .childNodes[0].nodeValue ),
+ "total":
+ Number( data.getElementsByTagName("total")[0]
+ .childNodes[0].nodeValue ),
+ "start":
+ Number( data.getElementsByTagName("start")[0]
+ .childNodes[0].nodeValue ),
+ "num":
+ Number( data.getElementsByTagName("num")[0]
+ .childNodes[0].nodeValue ),
+ "hits": []
+ };
+ // parse all the first-level nodes for all <hit> tags
+ var hits = data.getElementsByTagName("hit");
+ for (i = 0; i < hits.length; i++)
+ show.hits[i] = Element_parseChildNodes(hits[i]);
+ } else {
+ context.throwError('Show failed. Malformed WS resonse.',
+ 114);
+ };
+
+ var approxNode = data.getElementsByTagName("approximation");
+ if (approxNode && approxNode[0] && approxNode[0].childNodes[0] && approxNode[0].childNodes[0].nodeValue)
+ show['approximation'] =
+ Number( approxNode[0].childNodes[0].nodeValue);
+