Fire test against z3950.indexdata.com/marc instead.
[pazpar2-moved-to-github.git] / www / masterkey / js / client.js
index 2d262b1..d2e3985 100644 (file)
@@ -1,8 +1,18 @@
 /*
-** $Id: client.js,v 1.21 2007-04-30 03:35:57 quinn Exp $
+** $Id: client.js,v 1.23 2007-05-16 07:53:32 jakub Exp $
 ** MasterKey - pazpar2's javascript client .
 */
 
+// check for pz2.js
+if(typeof window.pz2 == "undefined"){
+    throw new Error("Client requires pz2.js library.");
+}
+
+// check for jQuery
+if(typeof window.jQuery == "undefined"){
+    throw new Error("Client requires requires jQuery library");
+}
+
 /* start with creating pz2 object and passing it event handlers*/
 var my_paz = new pz2({ 
                     "onshow": my_onshow,
@@ -61,8 +71,6 @@ function onFormSubmitEventHandler() {
     fireSearch();
     drawBreadcrumb();
     $('div.motd').empty();
-    $('div.content').show();
-    $("div.leftbar").show();
     return false;
 }
 
@@ -76,6 +84,8 @@ function my_errorhandler(err)
     switch (err.message) 
     {
         case 'QUERY': alert("Your query was not understood. Please rephrase."); break;
+        case 'NOTARGETS': alert("You are not allowed to search any targets."); break;
+        case 'HTTP': alert("There were problems with the connection."); break;
         default: alert(err.message);
     }
 }
@@ -86,6 +96,9 @@ function my_errorhandler(err)
 */
 function my_onshow(data)
 {
+    $('div.content').show();
+    $("div.leftbar").show();
+    
     var recsBody = $('div.records');
     recsBody.empty();
     
@@ -283,7 +296,7 @@ function drawDetailedRec(detailBox)
 
     var hdtarget;
     if( recLocation ) {
-        hdtarget = $('<tr><td class="item">Available at:</td></tr>');
+        hdtarget = $('<tr><td class="item" align="right">Available at:&nbsp;</td></tr>');
        detailTable.append(hdtarget);
 
        for(var i=0; i < recLocation.length; i++)
@@ -292,7 +305,13 @@ function drawDetailedRec(detailBox)
                hdtarget = $('<tr><td class="item">&nbsp;</td></tr>').appendTo(detailTable);
            var url = recLocation[i]["md-url"];
            var description = recLocation[i]["md-description"];
+           var date = recLocation[i]["md-date"];
+           var citation = recLocation[i]["md-citation"];
            hdtarget.append('<td><b>'+recLocation[i].name+'</b></td>');
+           if (date)
+               detailTable.append($('<tr><td align="right">Date:&nbsp;</td><td>'+date+'</td></tr>'));
+           if (citation)
+               detailTable.append($('<tr><td align="right" valign="top">Citation:&nbsp;</td><td>'+citation+'</td></tr>'));
            if (description)
                detailTable.append($('<tr><td>&nbsp</td><td>'+description+'</td></tr>'));
            if (url) {