made normalize a little smarter.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 May 2005 22:48:42 +0000 (22:48 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 May 2005 22:48:42 +0000 (22:48 +0000)
keeping book pic alive until record id's are returned

git-svn-id: svn://svn.open-ils.org/ILS/trunk@735 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/util/webutils.js

index 06724e8..e2f2ae9 100644 (file)
@@ -320,8 +320,8 @@ AbstractRecordResultPage.prototype.displayRecord =
        var series = record.series();
        for( var s in  series ) {
                debug("Found series entry: " + series[s] );
-               this.seriesBox.addItem(
-                       this.mkSeriesLink(series[s]), series[s] );
+               var ss = normalize(series[s]);
+               this.seriesBox.addItem( this.mkSeriesLink(ss), ss );
        }
 
        /* requestBatch will only have one request in it when the current
index ddb0ff4..962b204 100644 (file)
@@ -281,16 +281,22 @@ MRResultPage.prototype.doSearch = function() {
                                        else throw E;
                                }
                                
+                               /*
                                var row = getById("hourglass_row");
-                               if(row)
-                                       row.parentNode.removeChild(row);
+                               if(row) row.parentNode.removeChild(row);
+                               */
 
                                if(obj.hitCount > 0) obj.buildNextLinks();
-                               else obj.noHits();
+                               else { 
+                                       var row = getById("hourglass_row");
+                                       if(row) row.parentNode.removeChild(row);
+                                       obj.noHits(); 
+                                       return; 
+                               }
 
                                obj.doMRSearch();       
                                debug("Kicking off the record id's request");
-                                                       }
+                       }
                );
                creq.send();
        }
@@ -317,6 +323,11 @@ MRResultPage.prototype.doMRSearch = function() {
        
        request.setCompleteCallback(
                function(req) {
+
+                       var row = getById("hourglass_row");
+                       if(row)
+                               row.parentNode.removeChild(row);
+
                        var result = req.getResultObject();
                        if(result == null) return;
                        result.count = obj.hitCount;
@@ -332,7 +343,6 @@ MRResultPage.prototype.doMRSearch = function() {
 
 MRResultPage.prototype.collectRecords = function() {
 
-       
        var i = this.searchOffset;
 
        var row = getById("hourglass_row");
@@ -373,7 +383,7 @@ MRResultPage.prototype.collectRecords = function() {
 
 MRResultPage.prototype.doCopyCount = function( record, search_id, page_id ) {
 
-       if(record == null) return;
+       if(record==null || !record) return;
 
        var copy_box    = getById("record_result_copy_count_box_" + page_id );
 
index 7f30c83..a0b8e3d 100644 (file)
@@ -57,20 +57,38 @@ function createAppTextNode(text) {
 
 
 
+/* split on spaces.  capitalize the first /\w/ character in
+       each substring */
 function normalize(val) {
+
        var newVal = '';
        val = val.split(' ');
-       for(var c=0; c < val.length; c++) {
-               var string = val[c];
+       var reg = /\w/;
+
+       for( var c = 0; c < val.length; c++) {
 
+               var string = val[c];
+               var cap = false;
                for(var x = 0; x != string.length; x++) {
-                       if(x==0)
-                               newVal += string.charAt(x).toUpperCase();
-                       else
-                               newVal += string.charAt(x).toLowerCase();
+
+                       if(!cap) {
+                               var ch = string.charAt(x);
+                               if(reg.exec(ch + "")) {
+                                       newVal += string.charAt(x).toUpperCase();
+                                       cap = true;
+                                       continue;
+                               }
+                       }
+
+                       newVal += string.charAt(x).toLowerCase();
                }
                if(c < (val.length-1)) newVal += " ";
        }
+
+       newVal = newVal.replace(/\s*\.\s*$/,'');
+       newVal = newVal.replace(/\s*\/\s*\/\s*$/,' / ');
+       newVal = newVal.replace(/\s*\/\s*$/,'');
+
        return newVal;
 }