opac pile of js updates, slowing adding tweeks
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 16 May 2005 16:08:15 +0000 (16:08 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 16 May 2005 16:08:15 +0000 (16:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@727 dcc99617-32d9-48b4-a31d-7c20da2025e4

12 files changed:
Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/AdvancedSearchPage.js
Open-ILS/src/javascript/opac/GlobalInit.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/opac/Page.js
Open-ILS/src/javascript/opac/RecordDetailPage.js
Open-ILS/src/javascript/opac/RecordResultPage.js
Open-ILS/src/javascript/opac/SearchBarFormChunk.js
Open-ILS/src/javascript/util/RemoteRequest.js
Open-ILS/src/javascript/widgets/Box.js
Open-ILS/src/javascript/widgets/ProgressBar.js
Open-ILS/src/javascript/widgets/Survey.js

index f5a54d0..06724e8 100644 (file)
@@ -21,7 +21,7 @@ AbstractRecordResultPage.prototype.init = function() {
 
        this.authorBox = new Box();
        this.authorBox.init("Relevant Authors", true, true, 15);
-       this.authorBox.sortByCount();
+       this.authorBox.sortByKey();
 
        this.subjectBox = new Box();
        this.subjectBox.init("Relevant Subjects", true, true, 15);
@@ -29,7 +29,7 @@ AbstractRecordResultPage.prototype.init = function() {
 
        this.seriesBox = new Box();
        this.seriesBox.init("Relevant Series", true, true, 15);
-       this.seriesBox.sortByCount();
+       this.seriesBox.sortByKey();
 
        this.sidebarBox         = getById("record_sidebar_box");
 
@@ -230,7 +230,7 @@ AbstractRecordResultPage.prototype.displayRecord =
 
 
        var pic_cell = title_row.insertCell(0);
-       this.buildRecordImage( pic_cell, record, page_id );
+       this.buildRecordImage( pic_cell, record, page_id, record.title());
 
        var title_cell = title_row.insertCell(title_row.cells.length);
        title_cell.id = "record_result_title_box_" + id;
@@ -253,6 +253,7 @@ AbstractRecordResultPage.prototype.displayRecord =
                title = normalize(record.title());
        }
 
+
        var author = "";
        if( record.author() ) {
                if(record.author().length > tlength) {
@@ -262,7 +263,7 @@ AbstractRecordResultPage.prototype.displayRecord =
                author = normalize(record.author());
        }
 
-       title_cell.appendChild(this.mkLink(record.doc_id(), "title", title ));
+       title_cell.appendChild(this.mkLink(record.doc_id(), "title", title, record.title() ));
        author_cell.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        author_cell.appendChild(this.mkLink(record.doc_id(), "author", author ));
 
@@ -340,6 +341,7 @@ AbstractRecordResultPage.prototype.mkAuthorLink = function(auth) {
                "&mr_search_location=" + this.searchLocation);
 
        href.appendChild(createAppTextNode(auth));
+       href.title = "Author search for " + auth;
        return href;
 }
 
@@ -347,6 +349,8 @@ AbstractRecordResultPage.prototype.mkSeriesLink = function(series) {
        var href = createAppElement("a");
        add_css_class(href,"record_result_sidebar_link");
 
+       debug("Series: " + series + " : " + encodeURIComponent(series));
+
        href.setAttribute("href",
                "?target=mr_result&mr_search_type=series&page=0&mr_search_query=" +
                encodeURIComponent(series) +
@@ -354,6 +358,7 @@ AbstractRecordResultPage.prototype.mkSeriesLink = function(series) {
                "&mr_search_location=" + this.searchLocation);
 
        href.appendChild(createAppTextNode(series));
+       href.title = "Series search for " + series;
        return href;
 }
 
@@ -366,6 +371,7 @@ AbstractRecordResultPage.prototype.mkSubjectLink = function(sub) {
                "&mr_search_depth=" + this.searchDepth +
                "&mr_search_location=" + this.searchLocation);
        href.appendChild(createAppTextNode(sub));
+       href.title = "Subject search for " + sub;
        return href;
 }
 
@@ -375,6 +381,7 @@ AbstractRecordResultPage.prototype.finalizePage = function() {
                return;
        this.finalized = true;
 
+
        this.subjectBox.finalize();
        this.authorBox.finalize();
        this.seriesBox.finalize();
@@ -420,6 +427,7 @@ AbstractRecordResultPage.prototype.finalizePage = function() {
 
        /* in case we're hidden */
        showMe(this.bigOlBox);
+       showMe(getById("hit_count_cell_2"));
 
 }
 
@@ -450,6 +458,7 @@ AbstractRecordResultPage.prototype.displayCopyCounts =
                cell.innerHTML = copy_counts[i].available + " / " + copy_counts[i].count;
                cell.setAttribute("rowspan","3");
                cell.rowSpan = 3;
+               cell.title = " Availabie Copies / Total Copies";
                titlerow.appendChild(cell);
        }
 
@@ -514,9 +523,15 @@ AbstractRecordResultPage.prototype.buildNextLinks = function() {
                max = this.hitCount;
 
        var hcell = getById("hit_count_cell");
+       var hcell2 = getById("hit_count_cell_2");
+       hideMe(hcell2);
+
+       var ident = "Titles";
+       if(instanceOf(this, MRResultPage))
+               ident = "Title Groups";
 
        hcell.appendChild(
-               createAppTextNode( "Displaying " + 
+               createAppTextNode( "Displaying " + ident + " " +
                ( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount));
 
        hcell.appendChild(createAppTextNode(" "));
@@ -536,7 +551,7 @@ AbstractRecordResultPage.prototype.buildNextLinks = function() {
        hcell.appendChild(span);
        hcell.appendChild(next);
 
-
+       hcell2.innerHTML = hcell.innerHTML;
        
 }
 
@@ -602,7 +617,7 @@ AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource) {
        c.childNodes[index].appendChild(pic);
 }
 
-AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id) {
+AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) {
 
        var isbn = record.isbn();
        if(isbn) isbn = isbn.replace(/\s+/,"");
@@ -636,7 +651,7 @@ AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record,
                add_css_class(d, "relevance");
                rankBox.appendChild(d);
 
-               rankBox.setAttribute("title", (100 - parseInt(per)) + "% Relevant");
+               rankBox.setAttribute("title", parseInt((100 - parseInt(per))) + "% Relevant");
        }
 
        /* use amazon for now */
@@ -662,7 +677,7 @@ AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record,
                big_div.style.left = 0;
 
 
-       var anch = this.mkLink(record.doc_id(), "img" );
+       var anch = this.mkLink(record.doc_id(), "img", title );
        anch.appendChild(big_pic);
        big_div.appendChild(anch);
        pic_cell.appendChild(big_div);
index 11e7432..0fbbc01 100644 (file)
@@ -29,8 +29,10 @@ AdvancedSearchPage.prototype.init = function() {
        this.tcnText                            = getById("adv_tcn_text");
        this.ISBNText                           = getById("adv_isbn_text");
        this.barcodeText                        = getById("adv_barcode_text");
+       var refinedButton                       = getById("adv_search_refined_submit");
 
        this.globalSearchButton.onclick = doGlobalSearch;
+       refinedButton.onclick = doGlobalSearch;
 }
 
 /* resets the page */
@@ -69,6 +71,49 @@ function doGlobalSearch() {
                return;
        }
 
+       var allWords = getById("adv_all_words").value;
+       var exactWords = getById("adv_exact_words").value;
+       var noneWords   = getById("adv_none_words").value;
+       var type = getById("adv_search_type").value;
+       if(allWords || exactWords || noneWords) {
+               var search_string = obj.buildRefinedSearch(allWords, exactWords, noneWords);
+               debug("Refined search string is [ " + search_string + " ] and type " + type);
+
+               url_redirect ([ 
+                               "target",                                       "mr_result",
+                               "mr_search_type",                       type,
+                               "mr_search_query",              search_string,
+                               "page",                                         0
+                               ]);
+
+       }
+
+}
+
+AdvancedSearchPage.prototype.buildRefinedSearch = 
+                       function(allWords, exactWords, noneWords) {
+       
+       var string = "";
+
+       if(allWords) {
+               string = allWords;
+       }
+
+       if(exactWords) {
+               if(exactWords.indexOf('"') > -1) 
+                       string += " " + exactWords;
+               else 
+                       string += " \"" + exactWords + "\"";
+               
+       }
+
+       if(noneWords) {
+               var words = noneWords.split(" ");
+               for(var i in words) 
+                       string += " -" + words[i];
+       }
+
+       return string;
 }
                
 
index 44e9406..863d6ce 100644 (file)
@@ -8,9 +8,15 @@ var globalOrgTreeWidgetBox             = null;
 var globalSelectedLocation             = null;
 var globalSearchDepth                  = null;
 var globalMenuManager                  = null;
+var locationStack                                      = new Array();
+
+var lastSearchString                           = null;
+var lastSearchType                             = null;
+
 
 var loaded = false;
 
+
 function isXUL() {
        try {
                if(IAMXUL)
@@ -20,11 +26,27 @@ function isXUL() {
        }
 }
 
+function addLocation(type, title) {
+       try { 
+               if(globalAppFrame) {
+                       var obj = new Object();
+                       obj.location = globalAppFrame.location.href;
+                       obj.title = title;
+                       locationStack[type] = obj;
+               }
+       } catch(E){}
+
+}
+
 
 function globalInit() {
 
        debug(" --- XUL IS " + isXUL() );
 
+
+       if( isXUL() && globalAppFrame )
+               globalAppFrame.document.body.style.background = "#FFF";
+
        var page_name = globalPageTarget;
 
        if(!page_name) 
@@ -36,18 +58,24 @@ function globalInit() {
 
                case "start":
                        globalPage = new OPACStartPage();
+                       addLocation("start", "Home");
+                       locationStack["advanced_search"] = null;
                        break;
 
                case  "advanced_search":
                        globalPage = new AdvancedSearchPage();
+                       addLocation("advanced_search", "Advanced Search");
+                       locationStack["start"] = null;
                        break;
 
                case  "mr_result":
                        globalPage = new MRResultPage();
+                       addLocation("mr_result", "Title Group Results");
                        break;
 
                case  "record_result":
                        globalPage = new RecordResultPage();
+                       addLocation("record_result", "Title Results");
                        break;
 
                case  "login":
@@ -64,6 +92,7 @@ function globalInit() {
 
                case "record_detail":
                        globalPage = new RecordDetailPage();
+                       addLocation("record_detail", "Title Details");
                        break;
 
                case  "about":
@@ -88,6 +117,7 @@ function globalInit() {
        globalPage.init();
        globalPage.setLocDisplay();
        globalPage.locationTree = globalOrgTreeWidget;
+       globalPage.setPageTrail();
 
        if(globalSearchBarChunk)
                globalSearchBarChunk.reset();
index 495df4a..fd86994 100644 (file)
@@ -29,6 +29,28 @@ MRResultPage.instance = function() {
        return new MRResultPage();
 }
 
+
+MRResultPage.prototype.setPageTrail = function() {
+
+       var box = getById("page_trail");
+       if(!box) return;
+
+       var d = this.buildTrailLink("start",true);
+       if(d) {
+               box.appendChild(d);
+       } else {
+               d = this.buildTrailLink("advanced_search", true);
+               if(d)
+                       box.appendChild(d);
+       }
+
+       box.appendChild(this.buildDivider());
+       box.appendChild(
+                       this.buildTrailLink("mr_result", false));
+       
+}
+
+
 MRResultPage.prototype.next = function() {
 
        var location = globalSelectedLocation;
@@ -95,10 +117,15 @@ MRResultPage.prototype.URLRefresh = function() {
                                ];
 }
 
-MRResultPage.prototype.mkLink = function(id, type, value) {
+MRResultPage.prototype.mkLink = function(id, type, value, title) {
 
        var href;
 
+       var t = title;
+       if(!t) t = value;
+
+       debug("T: " + t);
+
        switch(type) {
 
                case "title":
@@ -108,6 +135,7 @@ MRResultPage.prototype.mkLink = function(id, type, value) {
                                "?target=record_result&page=0&mrid=" + id + 
                                "&hits_per_page=" + this.hitsPerPage);
                        href.appendChild(createAppTextNode(value));
+                       href.title = "View titles for " + t + "";
                        break;
 
        case "img":
@@ -116,6 +144,7 @@ MRResultPage.prototype.mkLink = function(id, type, value) {
                        href.setAttribute("href",
                                "?target=record_result&page=0&mrid=" + id +
                                "&hits_per_page=" + this.hitsPerPage);
+                       href.title = "View titles for " + t + "";
                        break;
 
 
@@ -126,6 +155,7 @@ MRResultPage.prototype.mkLink = function(id, type, value) {
                                "?target=mr_result&mr_search_type=author&page=0&mr_search_query=" +
                             encodeURIComponent(value));
                        href.appendChild(createAppTextNode(value));
+                       href.title = "Author search for " + t + "";
                        break;
 
                default:
@@ -149,6 +179,9 @@ MRResultPage.prototype.doSearch = function() {
        var depth                       = paramObj.__mr_search_depth;
        var hitsper                     = paramObj.__hits_per_page;
 
+       lastSearchString = string;
+       lastSearchType = stype;
+
        if(hitsper)
                this.hitsPerPage = parseInt(hitsper);
 
@@ -243,6 +276,10 @@ MRResultPage.prototype.doSearch = function() {
                                        }
                                        else throw E;
                                }
+                               
+                               var row = getById("hourglass_row");
+                               if(row)
+                                       row.parentNode.removeChild(row);
 
                                if(obj.hitCount > 0) obj.buildNextLinks();
                                else obj.noHits();
@@ -272,7 +309,7 @@ MRResultPage.prototype.doMRSearch = function() {
                "open-ils.search", method,
                obj.stype, obj.string, 
                obj.searchLocation, 
-               obj.searchDepth, "100", obj.searchOffset );
+               obj.searchDepth, "50", obj.searchOffset );
        
        request.setCompleteCallback(
                function(req) {
@@ -294,6 +331,10 @@ MRResultPage.prototype.collectRecords = function() {
        
        var i = this.searchOffset;
 
+       var row = getById("hourglass_row");
+       if(row)
+               row.parentNode.removeChild(row);
+
        while( i < (this.searchOffset + this.hitsPerPage) ) {
                var id = this.recordIDs[i];
 
index 3096f38..0c045e2 100644 (file)
@@ -121,8 +121,8 @@ Page.prototype.resetRange = function() {
        
                        url_redirect( [ 
                                        "target",                                       "mr_result",
-                                       "mr_search_type",                       obj.stype,
-                                       "mr_search_query",              obj.string,
+                                       "mr_search_type",                       lastSearchType,
+                                       "mr_search_query",              lastSearchString,
                                        "mr_search_location",   location,
                                        "mr_search_depth",              globalSearchDepth,      
                                        "page",                                         0
@@ -132,3 +132,42 @@ Page.prototype.resetRange = function() {
 }
 
 
+
+
+
+Page.prototype.setPageTrail = function() {
+       debug("Falling back to Page.setPageTrail");
+}
+
+
+Page.prototype.buildTrailLink = function(type, active) {
+
+       var obj = locationStack[type];
+       if(obj == null) return;
+
+       var div = createAppElement("div");
+
+       if(active) {
+               add_css_class(div,"page_trail_word");
+               var a = createAppElement("a");
+               a.setAttribute("href", obj.location);
+               a.appendChild(createAppTextNode(obj.title));
+               a.title = obj.title;
+               div.appendChild(a);
+
+       } else {
+               add_css_class(div,"page_trail_word_inactive");
+               div.appendChild(createAppTextNode(obj.title));
+       }
+
+       return div;
+}
+
+Page.prototype.buildDivider = function() {
+       var div = createAppElement("div");
+       div.className = "page_trail_divider";
+       var text =  createAppTextNode(" / ");
+       div.appendChild(text);
+       return div;
+}
+
index 6ef9a35..db43e88 100644 (file)
@@ -19,3 +19,35 @@ RecordDetailPage.instance = function() {
 RecordDetailPage.prototype.init = function() {
        debug("Initing RecordDetailPage");
 }
+
+RecordDetailPage.prototype.setPageTrail = function() {
+       var box = getById("page_trail");
+       if(!box) return;
+
+       var d = this.buildTrailLink("start",true);
+       if(d) {
+               box.appendChild(d);
+       } else {
+               d = this.buildTrailLink("advanced_search",true);
+               if(d)
+                       box.appendChild(d);
+       }
+
+       var b = this.buildTrailLink("mr_result", true);
+
+       if(b) {
+               box.appendChild(this.buildDivider());
+               box.appendChild(b);
+       }
+
+       box.appendChild(this.buildDivider());
+       box.appendChild(this.buildTrailLink("record_result", true));
+
+       box.appendChild(this.buildDivider());
+       box.appendChild(
+               this.buildTrailLink("record_detail",false));
+}
+
+
+
+
index ba5a7c2..9ea0ba6 100644 (file)
@@ -9,6 +9,10 @@ function RecordResultPage() {
 
        debug("in RecordResultPage()");
 
+       var row = getById("hourglass_row");
+       if(row)
+               row.parentNode.removeChild(row);
+
        if( globalRecordResultPage != null ) {
                debug("globalRecordResultPage already exists: " + 
                                globalRecordResultPage.toString() );
@@ -17,12 +21,50 @@ function RecordResultPage() {
        globalRecordResultPage = this;
        this.resetSearch();
        debug("Built a new RecordResultPage()");
+
+       var row = getById("hourglass_row");
+       if(row)
+               row.parentNode.removeChild(row);
+}
+
+
+RecordResultPage.prototype.setPageTrail = function() {
+       var box = getById("page_trail");
+       if(!box) return;
+
+       var d = this.buildTrailLink("start", true);
+       if(d) {
+               box.appendChild(d);
+       } else {
+               d = this.buildTrailLink("advanced_search", true);
+               if(d)
+                       box.appendChild(d);
+       }
+
+       var b = this.buildTrailLink("mr_result", true);
+
+       if(b) {
+               box.appendChild(this.buildDivider());
+               box.appendChild(b);
+       }
+
+       box.appendChild(this.buildDivider());
+       box.appendChild(
+               this.buildTrailLink("record_result",false));
 }
 
 
+
+
+
 /* returns the global instance. builds the instance if necessary.  All client
  * code should use this method */
 RecordResultPage.instance = function() {
+
+       var row = getById("hourglass_row");
+       if(row)
+               row.parentNode.removeChild(row);
+
        if( globalRecordResultPage != null ) {
                return globalRecordResultPage;
        } 
@@ -93,6 +135,7 @@ RecordResultPage.prototype.mkLink = function(id, type, value) {
                        add_css_class(href,"record_result_title_link");
                        href.setAttribute("href","?target=record_detail&record=" + id );
                        href.appendChild(createAppTextNode(value));
+                       href.title = "View title details for " + value;
                        break;
 
                case "author":
@@ -101,12 +144,14 @@ RecordResultPage.prototype.mkLink = function(id, type, value) {
                        href.setAttribute("href","?target=mr_result&mr_search_type=author&mr_search_query=" +
                                              encodeURIComponent(value));
                        href.appendChild(createAppTextNode(value));
+                       href.title = "Author search for " + value + "";
                        break;
 
        case "img":
                        href = createAppElement("a");
                        add_css_class(href,"record_result_image_link");
                        href.setAttribute("href","?target=record_detail&page=0&mrid=" + id );
+                       href.title = "View title details for " + value;
                        break;
 
                default:
index 6997426..f625f28 100644 (file)
@@ -25,11 +25,12 @@ SearchBarFormChunk.prototype.resetPage = function() {
        this.search_type.onkeydown              = mrSearchSubmitOnEnter;
 
 
-       if(paramObj.__mr_search_query)
-               this.search_query.value = paramObj.__mr_search_query;
-
-       if(paramObj.__mr_search_type)
-               this.search_type.value = paramObj.__mr_search_type;
+       var s = paramObj.__mr_search_query;
+       if(!s) s = lastSearchString;
+       var t = paramObj.__mr_search_type;
+       if(!t) t = lastSearchType;
+       if(s) this.search_query.value = s;
+       if(t) this.search_type.value = t;
 
        try{ this.search_query.focus(); } catch(E) {}
 
@@ -38,36 +39,6 @@ SearchBarFormChunk.prototype.resetPage = function() {
 }
 
 
-/*
-SearchBarFormChunk.prototype.resetRange = function() {
-
-       this.searchRange                        = getById("search_range_select");
-       var orgunit = globalSelectedLocation;
-       if(!orgunit)
-               orgunit = globalLocation;
-
-       if(this.searchRange) {
-               for( var index in globalOrgTypes ) {
-                       var otype = globalOrgTypes[index];
-
-                       if( otype.depth() > orgunit.ou_type() )
-                               continue;
-
-                       var select =  new Option(otype.name(), otype.depth());
-       
-                       debug("org depth " + otype.name() + " : " + otype.depth() );
-                       if( otype.depth() == globalSearchDepth ) {
-                               debug("Building range selector with depth " 
-                                               + globalSearchDepth  + " and name " + otype.name() );
-                               select.selected = true;
-                       }
-       
-                       this.searchRange.options[index] = select;
-               }
-       }
-}
-*/
-
        
 function mrSearchSubmitForm() {
        var search_query                = getById("mr_search_query").value;
index 8c849b2..ff3ffda 100644 (file)
@@ -160,8 +160,12 @@ RemoteRequest.prototype.setCompleteCallback = function(callback) {
 
                                        debug("Communication Error: [" + E + "]");
                                        if(object.sendCount >= XML_HTTP_MAX_TRIES ) {
-                                               alert("Arrrgghh, Matey! Error communicating:\n" +
+                                               if(isXUL()) {
+                                                       throw object;
+                                               } else {
+                                                       alert("Arrrgghh, Matey! Error communicating:\n" +
                                                                 E  + "\n" + object.param_string);
+                                               }
                                        } else {
                                                object.buildXMLRequest();
                                                object.send();
index a873601..e419c5b 100644 (file)
@@ -138,19 +138,82 @@ Box.prototype.setMax = function(max) {
                this.max = null;
 }
 
+Box.prototype.sortMyKeys = function() {
+
+       var keys = new Array();
+
+       for( var i in this.items) 
+               keys.push(this.items[i].getKey());
+
+       keys = keys.sort();
+       debug("Keys: " + keys);
+
+       /* drop all of the children */
+       while(this.contentNode.childNodes.length > 0 ) 
+               this.contentNode.removeChild(
+                               this.contentNode.lastChild);
+
+       for(var k in keys) {
+               var node = this.findByKey(keys[k]);
+               if(node)
+                       this.contentNode.appendChild(node.getNode());
+       }
+
+}
+
+
+Box.prototype.sortMyCounts = function() {
+
+       var counts = new Array();
+       for( var x in this.itemCount) {
+               counts.push(this.itemCount[x]);
+       }
+
+
+       /* remove all of the divs */
+       while(this.contentNode.childNodes.length > 0 ) 
+               this.contentNode.removeChild(
+                               this.contentNode.lastChild);
+
+       /* then re-insert in order of the sorted counts array*/
+       counts = counts.sort().reverse();
+       for(var i in counts) {
+               for( var c in this.itemCount ) {
+                       if(this.itemCount[c] == counts[i]) {
+                               var item = this.findByKey(c);
+                               this.contentNode.appendChild(item.getNode());
+                       }
+               }
+       }
+
+}
+
+
+Box.prototype.sortMyBoth = function() {
+}
+
+Box.prototype.findByKey = function(key) {
+       for( var i in this.items) {
+               if( this.items[i] && this.items[i].getKey() == key)
+                       return this.items[i];
+       }
+       return null;
+}
+
 /* checks for sorting order/max items and does the final 
        div drawing. Sets hidden to false */
 Box.prototype.finalize = function() {
 
        /* first sort if necessary */
 
-       if(this.sortCounts){
-               /*remove all childrens*/
-       } 
+       if(this.sortCounts && this.sortKeys)
+               this.sortMyBoth(); 
 
-       if(this.sortKeys){
-       }
+       else if(this.sortKeys)
+               this.sortMyKeys();
 
+       else if(this.sortCounts) 
+               this.sortMyCounts();
 
        /* then trim */
        if( this.max ) {
index 0386240..ab86b7a 100644 (file)
@@ -15,7 +15,7 @@ function ProgressBar(size,interval) {
        this.percentDiv = createAppElement("div");
        add_css_class(this.percentDiv, "progress_percent");
 
-       var divWidth = 100 / parseInt(size);
+       var divWidth = parseInt(100 / parseInt(size));
        for( i = 0; i!= size; i++ ) {
                var div = createAppElement("div");
                div.className = "progress_bar_chunk";
@@ -47,10 +47,13 @@ ProgressBar.prototype.stop = function() {
        this.is_running = false;
        this.current = this.size;
        clearTimeout(this.timeoutId);
+       /*
        for(var i in this.div.childNodes) {
                this.div.childNodes[i].className = "progress_bar_chunk_active";
        }
+       */
        add_css_class(this.percentDiv, "hide_me");
+       add_css_class(this.div, "progress_bar_done");
        this.percentDiv.innerHTML = "";
 }
 
@@ -69,5 +72,5 @@ ProgressBar.prototype.manualNext = function() {
                this.current = parseInt(this.current) + 1;
        }
 
-       this.percentDiv.innerHTML = (parseInt(this.current) / parseInt(this.size) * 100) + "%";
+       this.percentDiv.innerHTML = parseInt((parseInt(this.current) / parseInt(this.size) * 100)) + "%";
 }
index fe355ab..7539142 100644 (file)
@@ -241,6 +241,7 @@ Survey._retrieve = function(request, surveyTaker, recvCallback) {
                debug("Retrieving random survey asynchronously");
                var c = function(req) {
                        var surveys = req.getResultObject();
+                       if(!surveys) return null;
 
                        if( typeof surveys != 'object' || 
                                        surveys.constructor != Array )