JS: Use generic array for stats data.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 28 Sep 2009 11:22:19 +0000 (13:22 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 28 Sep 2009 11:22:19 +0000 (13:22 +0200)
The stat response data is now stored in an array based on element names.
This allow us to not keep in "sync" with the Pazpar2 response which changed
from 1.0.13 to 1.1.0.

js/pz2.js

index f290eec..affff33 100644 (file)
--- a/js/pz2.js
+++ b/js/pz2.js
@@ -324,37 +324,9 @@ pz2.prototype =
                         Number( data.getElementsByTagName("activeclients")[0]
                                     .childNodes[0].nodeValue );
                     context.activeClients = activeClients;
-                    var stat = {
-                        "activeclients": activeClients,
-                        "hits": 
-                            Number( data.getElementsByTagName("hits")[0]
-                                        .childNodes[0].nodeValue ),
-                        "records": 
-                            Number( data.getElementsByTagName("records")[0]
-                                        .childNodes[0].nodeValue ),
-                        "clients": 
-                            Number( data.getElementsByTagName("clients")[0]
-                                        .childNodes[0].nodeValue ),
-                        "initializing": 
-                            Number( data.getElementsByTagName("initializing")[0]
-                                        .childNodes[0].nodeValue ),
-                        "searching": 
-                            Number( data.getElementsByTagName("searching")[0]
-                                        .childNodes[0].nodeValue ),
-                        "presenting": 
-                            Number( data.getElementsByTagName("presenting")[0]
-                                        .childNodes[0].nodeValue ),
-                        "idle": 
-                            Number( data.getElementsByTagName("idle")[0]
-                                        .childNodes[0].nodeValue ),
-                        "failed": 
-                            Number( data.getElementsByTagName("failed")[0]
-                                        .childNodes[0].nodeValue ),
-                        "error": 
-                            Number( data.getElementsByTagName("error")[0]
-                                        .childNodes[0].nodeValue )
-                    };
-                    
+
+                   var stat = Element_parseChildNodes(data.documentElement);
+
                     context.statCounter++;
                    var delay = context.statTime 
                         + context.statCounter * context.dumpFactor;