debugging the sort order stuff, changed some terminology, only
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 28 Feb 2006 22:09:43 +0000 (22:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 28 Feb 2006 22:09:43 +0000 (22:09 +0000)
propogating the sort order on next/prev links and not on
all links

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

Open-ILS/web/opac/common/js/JSON.js
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/locale/en-US/opac_common.dtd
Open-ILS/web/opac/skin/default/js/advanced.js
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/js/search_bar.js

index 1f7b805..399812b 100644 (file)
@@ -23,7 +23,7 @@ function JSON2js (json) {
                try {
                        eval( 'obj = ' + json );
                } catch(E) {
-                       debug("Error building JSON object with string " + E + "\nString:\n" + json );
+                       alert("* Fix Me *\nError parsing JSON [" + E + "]\n\n" + json );
                        return null;
                }
        }
@@ -33,11 +33,9 @@ function JSON2js (json) {
 
 function object2Array(obj) {
        if( obj == null ) return null;
-
        var arr = new Array();
-       for( var i  = 0; i < obj.length; i++ ) {
+       for( var i  = 0; i < obj.length; i++ ) 
                arr[i] = obj[i];
-       }
        return arr;
 }
 
index c0087ea..ae10506 100644 (file)
@@ -12,7 +12,7 @@ var PARAM_HITCOUNT    = "hc";                 /* hits per page */
 var PARAM_MRID                 = "m";                  /* metarecord id */
 var PARAM_RID                  = "r";                  /* record id */
 var PARAM_ORIGLOC              = "ol";                 /* the original location */
-var PARAM_TOPRANK              = "tr";                 /* this highest ranking rank */
+//var PARAM_TOPRANK            = "tr";                 /* this highest ranking rank */
 var PARAM_AUTHTIME     = "at";                 /* inactivity timeout in seconds */
 var PARAM_ADVTERM              = "adv";                        /* advanced search term */
 var PARAM_ADVTYPE              = "adt";                        /* the advanced search type */
@@ -32,7 +32,7 @@ var HITCOUNT;
 var RANKS; 
 var FONTSIZE;
 var ORIGLOC;
-var TOPRANK;
+//var TOPRANK;
 var AUTHTIME;
 var ADVTERM;
 var ADVTYPE;
@@ -81,6 +81,7 @@ var RTYPE_TITLE       = STYPE_TITLE;
 var RTYPE_SERIES       = STYPE_SERIES;
 var RTYPE_KEYWORD      = STYPE_KEYWORD;
 
+var SORT_TYPE_REL                      = "rel";
 var SORT_TYPE_AUTHOR           = STYPE_AUTHOR; 
 var SORT_TYPE_TITLE            = STYPE_TITLE;
 var SORT_TYPE_PUBDATE  = "pubdate";
index caa95db..5157f22 100644 (file)
@@ -81,7 +81,6 @@ function initParams() {
        HITCOUNT        = parseInt(cgi.param(PARAM_HITCOUNT));
        MRID            = parseInt(cgi.param(PARAM_MRID));
        RID             = parseInt(cgi.param(PARAM_RID));
-       TOPRANK  = parseFloat(cgi.param(PARAM_TOPRANK));
        AUTHTIME        = parseInt(cgi.param(PARAM_AUTHTIME));
        ADVTERM = cgi.param(PARAM_ADVTERM);
        ADVTYPE = cgi.param(PARAM_ADVTYPE);
@@ -97,9 +96,8 @@ function initParams() {
        if(isNaN(HITCOUNT))     HITCOUNT        = 0;
        if(isNaN(MRID))         MRID            = 0;
        if(isNaN(RID))                  RID             = 0;
-       if(isNaN(ORIGLOC))      ORIGLOC = 0;
-       if(isNaN(TOPRANK))      TOPRANK = 1;
-       if(isNaN(AUTHTIME))     AUTHTIME        = 1;
+       if(isNaN(ORIGLOC))      ORIGLOC = 1;
+       if(isNaN(AUTHTIME))     AUTHTIME        = 0;
        if(ADVTERM==null)               ADVTERM = "";
 }
 
@@ -122,7 +120,6 @@ function getHitCount(){return HITCOUNT;}
 function getMrid(){return MRID;};
 function getRid(){return RID;};
 function getOrigLocation(){return ORIGLOC;}
-function getTopRank(){return TOPRANK;}
 function getAuthtime() { return AUTHTIME; }
 function getSearchBarExtras(){return SBEXTRAS;}
 function getFontSize(){return FONTSIZE;};
@@ -162,6 +159,8 @@ function buildExtrasLink(name, ssl) {
        return findBaseURL(ssl) + "../../../../extras/" + name;
 }
 
+function _debug(str) { try { dump(str + '\n'); } catch(e) {} }
+
 function  buildOPACLink(args, slim, ssl) {
 
        if(!args) args = {};
@@ -176,28 +175,46 @@ function  buildOPACLink(args, slim, ssl) {
        string += "?";
 
        for( var x in args ) {
-               if(x == "page" || args[x] == null) continue;
-               string += "&" + x + "=" + encodeURIComponent(args[x]);
+               var v = args[x];
+               if(x == "page" || v == null || v == undefined ) continue;
+               if(x == PARAM_OFFSET && v == 0) continue;
+               if(x == PARAM_LOCATION && v == 1) continue;
+               if(x == PARAM_DEPTH && v == 0) continue;
+               if(x == PARAM_COUNT && v == 10) continue;
+               if(x == PARAM_FORM && v == 'all' ) continue;
+               string += "&" + x + "=" + encodeURIComponent(v);
        }
 
-       string += _appendParam(ORIGLOC, PARAM_ORIGLOC, args, getOrigLocation, string);
-       string += _appendParam(TERM,            PARAM_TERM, args, getTerm, string);
-       string += _appendParam(STYPE,           PARAM_STYPE, args, getStype, string);
-       string += _appendParam(LOCATION, PARAM_LOCATION, args, getLocation, string);
-       string += _appendParam(DEPTH,           PARAM_DEPTH, args, getDepth, string);
-       string += _appendParam(FORM,            PARAM_FORM, args, getForm, string);
-       string += _appendParam(OFFSET,  PARAM_OFFSET, args, getOffset, string);
-       string += _appendParam(COUNT,           PARAM_COUNT, args, getDisplayCount, string);
-       string += _appendParam(HITCOUNT, PARAM_HITCOUNT, args, getHitCount, string);
-       string += _appendParam(MRID,            PARAM_MRID, args, getMrid, string);
-       string += _appendParam(RID,             PARAM_RID, args, getRid, string);
-       string += _appendParam(TOPRANK, PARAM_TOPRANK, args, getTopRank, string);
-       string += _appendParam(AUTHTIME,        PARAM_AUTHTIME, args, getAuthtime, string);
-       string += _appendParam(ADVTERM, PARAM_ADVTERM, args, getAdvTerm, string);
-       string += _appendParam(ADVTYPE, PARAM_ADVTYPE, args, getAdvType, string);
-       string += _appendParam(RTYPE,           PARAM_RTYPE, args, getRtype, string);
-       string += _appendParam(SORT,            PARAM_SORT, args, getSort, string);
-       string += _appendParam(SORT_DIR,        PARAM_SORT_DIR, args, getSortDir, string);
+       if(getOrigLocation() != 1) 
+               string += _appendParam(ORIGLOC, PARAM_ORIGLOC, args, getOrigLocation, string);
+       if(getTerm()) 
+               string += _appendParam(TERM,            PARAM_TERM, args, getTerm, string);
+       if(getStype()) 
+               string += _appendParam(STYPE,           PARAM_STYPE, args, getStype, string);
+       if(getLocation() != 1) 
+               string += _appendParam(LOCATION, PARAM_LOCATION, args, getLocation, string);
+       if(getDepth() != 0) 
+               string += _appendParam(DEPTH,           PARAM_DEPTH, args, getDepth, string);
+       if(getForm() && (getForm() != 'all') ) 
+               string += _appendParam(FORM,            PARAM_FORM, args, getForm, string);
+       if(getOffset() != 0) 
+               string += _appendParam(OFFSET,  PARAM_OFFSET, args, getOffset, string);
+       if(getDisplayCount() != 10) 
+               string += _appendParam(COUNT,           PARAM_COUNT, args, getDisplayCount, string);
+       if(getHitCount()) 
+               string += _appendParam(HITCOUNT, PARAM_HITCOUNT, args, getHitCount, string);
+       if(getMrid())
+               string += _appendParam(MRID,            PARAM_MRID, args, getMrid, string);
+       if(getRid())
+               string += _appendParam(RID,             PARAM_RID, args, getRid, string);
+       if(getAuthtime())
+               string += _appendParam(AUTHTIME,        PARAM_AUTHTIME, args, getAuthtime, string);
+       if(getAdvTerm())
+               string += _appendParam(ADVTERM, PARAM_ADVTERM, args, getAdvTerm, string);
+       if(getAdvType())
+               string += _appendParam(ADVTYPE, PARAM_ADVTYPE, args, getAdvType, string);
+       if(getRtype())
+               string += _appendParam(RTYPE,           PARAM_RTYPE, args, getRtype, string);
 
        return string.replace(/\&$/,'').replace(/\?\&/,"?");    
 }
index 36acf73..f68cd3a 100644 (file)
@@ -32,7 +32,7 @@
 
 <!ENTITY common.nowSearching "Now searching ">
 <!ENTITY common.ofAtLeast " of at least ">
-<!ENTITY common.relevancy "Relevancy ">
+<!ENTITY common.relevancy "Match Score: ">
 <!ENTITY common.tips "Tips:">
 <!ENTITY common.tips.tip1 "Click on a folder icon in the sidebar to access related quick searches">
 <!ENTITY common.tips.tip2 "If you don't find what you want try expanding your search using the range selector at the right of the search bar">
index 8428a14..b90e5b3 100644 (file)
@@ -31,6 +31,11 @@ function advInit() {
        setEnterFunc($('opac.advanced.quick.isbn'), advISBNRun );
        setEnterFunc($('opac.advanced.quick.issn'), advISSNRun );
        setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun );
+
+       setSelector($('advanced.wizard.sort_by'), getSort());
+       setSelector($('advanced.wizard.sort_dir'), getSortDir());
+       if(getSort() && getSort() != SORT_TYPE_REL) 
+               $('advanced.wizard.sort_dir').disabled = false;
 }
 
 
@@ -51,7 +56,7 @@ function advWizardRun() {
        arg[PARAM_DEPTH]                = depthSelGetDepth();
        arg[PARAM_LOCATION]     = depthSelGetNewLoc();
        arg[PARAM_TERM]         = advBuildSearch( contains, nocontains, exact );
-       arg[PARAM_SORT]         = (sort.match(/relevance/i)) ? null : sort;
+       arg[PARAM_SORT]         = sort;
        arg[PARAM_SORT_DIR]     = sortdir;
 
        goTo(buildOPACLink(arg));
index 4d62060..c139986 100644 (file)
@@ -101,16 +101,21 @@ function mresultCollectIds(method) {
 
 function _mresultCollectIds() {
        if( getOffset() == 0 || !mresultTryCachedSearch() ) {
-               var form = (getForm() == "all") ? null : getForm();
+
+               var form                = (!getForm() || getForm() == "all") ? null : getForm();
+               var sort                = (getSort() == SORT_TYPE_REL) ? null : getSort(); 
+               var sortdir = (sort) ? getSortDir() : null;
+
                var req = new Request(FETCH_MRIDS_, getStype(), 
                        {       term            : getTerm(), 
-                               sort            : getSort(), 
-                               sort_dir        : getSortDir(),
+                               sort            : sort,
+                               sort_dir        : sortdir,
                                org_unit : getLocation(),
                                depth           : getDepth(),
                                limit           : mresultPreCache,
                                offset  : getOffset(),
-                               format  : (getForm()=="all") ? null : getForm() } );
+                               format  : form } );
+
                req.callback(mresultHandleMRIds);
                req.send();
        }
index 13dbd80..702b2c6 100644 (file)
@@ -194,7 +194,10 @@ function resultPaginate() {
        if( !((o + getDisplayCount()) >= getHitCount()) ) {
 
                var args = {};
-               args[PARAM_OFFSET] = o + getDisplayCount();
+               args[PARAM_OFFSET]      = o + getDisplayCount();
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+
                G.ui.result.next_link.setAttribute("href", buildOPACLink(args)); 
                addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
 
@@ -206,6 +209,9 @@ function resultPaginate() {
        if( o > 0 ) {
 
                var args = {};
+               args[PARAM_SORT]                = SORT;
+               args[PARAM_SORT_DIR] = SORT_DIR;
+
                args[PARAM_OFFSET] = o - getDisplayCount();
                G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args)); 
                addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
@@ -234,8 +240,7 @@ function resultDisplayRecord(rec, pos, is_mr) {
        
        try {
                var rank = parseFloat(ranks[pos + getOffset()]);
-               rank = ( rank / getTopRank() ) * 100;
-               rank = parseInt(rank) + "%";
+               rank            = parseInt( rank * 100 );
                var relspan = $n(r, "relevancy_span");
                relspan.appendChild(text(rank));
                unHideMe(relspan.parentNode);
index 5088892..03f902d 100644 (file)
@@ -51,6 +51,8 @@ function searchBarSubmit() {
                if(getAdvTerm()){}
        }
 
+       SORT = ""; /* we don't want this to propogate */
+
        if(!text || text == "") return;
        var d   = (newSearchDepth != null) ?  newSearchDepth : depthSelGetDepth();
        if(isNaN(d)) d = 0;