When parsing detailed record the subject nodes are placed in an array.
[pazpar2-moved-to-github.git] / js / pz2.js
index 718c74d..36fc4f3 100644 (file)
--- a/js/pz2.js
+++ b/js/pz2.js
@@ -1,5 +1,5 @@
 /*
-** $Id: pz2.js,v 1.64 2007-10-31 10:29:01 jakub Exp $
+** $Id: pz2.js,v 1.66 2007-11-13 12:51:29 jakub Exp $
 ** pz2.js - pazpar2's javascript client library.
 */
 
@@ -534,8 +534,9 @@ pz2.prototype =
                                 != 'location' ) {
                                 var nodeName = 
                                     recordNode.childNodes[i].nodeName;
-                                var nodeText = 
-                                    recordNode.childNodes[i]
+                                var nodeText = '';
+                                if (recordNode.childNodes[i].firstChild)
+                                    nodeText = recordNode.childNodes[i]
                                         .firstChild.nodeValue;
                                 record[nodeName] = nodeText;                            
                             }
@@ -563,7 +564,21 @@ pz2.prototype =
                                         nodeText = 
                                             locationNodes[i].childNodes[j]
                                                 .firstChild.nodeValue;
-                                    record["location"][i][nodeName] = nodeText;                            
+                                    // this is stupid
+                                    if (nodeName == 'md-subject') {
+                                        if (record["location"][i]['nodeName']) {
+                                            record["location"][i][nodeName]
+                                                .push(nodeText)
+                                        } else {
+                                            record["location"][i][nodeName] 
+                                                = new Array();
+                                            record["location"][i][nodeName]
+                                                .push(nodeText)
+                                        }
+                                    } else {
+                                        record["location"][i][nodeName] 
+                                            = nodeText;
+                                    }
                                 }
                             }
                         }