Changeset 25641

Show
Ignore:
Timestamp:
23.05.2012 11:24:00 (7 years ago)
Author:
sjm84
Message:

Fixing two ajax calls that behaved incorrectly when a href is used to refer to a document instead of a document identifier

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/js/document_scripts.js

    r25484 r25641  
    327327    var ajax = gs.functions.ajaxRequest(); 
    328328     
    329     ajax.open("GET", gs.xsltParams.library_name + "?a=d&dt=hierarchy&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d.replace(/([^.]*)\..*/, "$1") + "&excerptid=gs-document", true); 
     329    var url = gs.xsltParams.library_name + "?a=d&dt=hierarchy&c=" + gs.cgiParams.c + "&excerptid=gs-document"; 
     330    if(gs.cgiParams.d && gs.cgiParams.d.length > 0) 
     331    { 
     332        url += "&d=" + gs.cgiParams.d.replace(/([^.]*)\..*/, "$1"); 
     333    } 
     334    else if(gs.cgiParams.href && gs.cgiParams.href.length > 0) 
     335    { 
     336        url += "&d=&lb=1&rl=1&href=" + gs.cgiParams.href; 
     337    } 
     338     
     339    ajax.open("GET", url, true); 
    330340    ajax.onreadystatechange = function() 
    331341    { 
     
    361371    var ajax = gs.functions.ajaxRequest(); 
    362372     
    363     ajax.open("GET", gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + gs.cgiParams.d + "?excerptid=tableOfContents&ed=1", true); 
     373    var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "?excerptid=tableOfContents&ed=1"; 
     374    if(gs.cgiParams.d && gs.cgiParams.d.length > 0) 
     375    { 
     376        url += "&a=d&d=" + gs.cgiParams.d; 
     377    } 
     378    else if(gs.cgiParams.href && gs.cgiParams.href.length > 0) 
     379    { 
     380        url += "&a=d&d=&lb=1&rl=1&href=" + gs.cgiParams.href; 
     381    } 
     382     
     383    ajax.open("GET", url, true); 
    364384    ajax.onreadystatechange = function() 
    365385    { 
     
    372392            var newTOC = newTOCElem.substring(tocStart, tocEnd); 
    373393             
    374             //Add an "expand all" link 
     394            //Add the "Expand document"/"Collapse document" links 
    375395            newTOC = "<table style=\"width:100%; text-align:center;\"><tr><td><a href=\"javascript:expandOrCollapseAll(true);\">Expand document</a></td><td><a href=\"javascript:expandOrCollapseAll(false);\">Collapse document</a></td></tr></table>" + newTOC; 
    376396