Ignore:
Timestamp:
2013-01-11T18:27:42+13:00 (11 years ago)
Author:
davidb
Message:

These scripts will now search the processed GSDL document's xml for frame number and assocfilepath values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in

    r26596 r26694  
    182182         
    183183          //url += "&p.showExpediteeAttributes=1";
     184          url += "&p.showAssocFilePath=1";
    184185
    185186         
     
    213214            iframeDoc = iframe.contentWindow.document;
    214215          }
    215 
    216           var frameID = (numDocOIDs - docOIDs.length);
    217           var progressPercent = frameID/numDocOIDs * 100;
    218 
     216         
     217          var xmlUrl = iframe.src + "&o=xml";
     218         
     219          var iter = (numDocOIDs - docOIDs.length);
     220          var progressPercent = iter/numDocOIDs * 100;
     221         
     222          /*Check if a frame-id metadata element already exists,
     223          otherwise generate a new frame number based on the
     224          number of documents to process.*/
     225          var frameNum = getMetadata(xmlUrl,'frameID');
     226         
     227          if(frameNum === null){
     228            frameNum = iter;
     229            console.log("no frameNum found, use iter: " + frameNum);
     230          }else{
     231            console.log("frameNum metadata found: " + frameNum);
     232          }
     233         
    219234          \$(function() {
    220235          \$('#progressbar').progressbar({ value: progressPercent })
     
    228243          var pxr = gsContentPos.xr;
    229244          */
    230 
    231           //get assocfilepath from xml
    232           var xmlUrl = iframe.src + "&o=xml";
    233          
    234           var assoc = getAssocFilePath(xmlUrl);
     245         
     246          //Check if an assocfilepath annotation already exists on the page, otherwise obtain it from the xml.
     247          var assocElem = iframeDoc.getElementById('assocfilepath');
     248          var assoc = null;
     249         
     250          if(assocElem === undefined || assocElem === null){
     251            assoc = getMetadata(xmlUrl,'assocfilepath');
     252          }
    235253
    236254          var expFrameTree = htmlToExpeditee(gsContent);
     
    248266          }
    249267         
    250           params += "&a=generate-frame&fn=" + frameID;
     268          //params += "&a=generate-frame&fn=" + iter;
     269          params += "&a=generate-frame&fn=" + frameNum;
    251270          params += "&json=" + escape(expFrame);
    252271         
    253           //add an assocfilepath parameter
    254          
    255           if(assoc !== null && assoc !== undefined){
     272          //add an assocfilepath parameter but only if it is defined.
     273          if(assoc !== null){
    256274            params += "&assoc=" + assoc;
    257275          }
     
    288306
    289307          //url += "&p.showExpediteeAttributes=1";
    290 
    291           iframe.src = url;
     308            url += "&p.showAssocFilePath=1";
     309         
     310            iframe.src = url;
    292311          }
    293312          else {
    294           var progressbar = document.getElementById("progressbar");
    295           progressbar.style.display = "none";
    296 
    297           iframe.style.display = "none";
    298           delete iframe.src;
     313            var progressbar = document.getElementById("progressbar");
     314            progressbar.style.display = "none";
     315
     316            iframe.style.display = "none";
     317            delete iframe.src;
    299318          }
    300319      }
     
    302321      }
    303322     
    304       function getAssocFilePath(xmlUrl){
    305       var assoc = "";
     323    /**
     324    * Once this is working, remove getAssocFilePath method
     325    * This method is used at this stage to retrieve assocfilepath
     326    * and frame number metadata values from the document's xml.
     327    **/
     328    function getMetadata(xmlUrl,nameValue){
    306329     
    307       \$.ajax({
     330        var metadata = null;
     331       
     332         \$.ajax({
    308333            type: "GET",
    309334            async: false,
     
    317342                    var name = \$(this).attr('name');
    318343                   
    319                     if(name === 'assocfilepath'){
    320                         if(assoc === ""){
    321                             assoc = \$(this).text();
    322                             //console.log(assoc);
     344                    if(name === nameValue){
     345                        if(metadata === null){
     346                            metadata = \$(this).text();
     347                            //console.log(metadata);
    323348                        }
    324349                       
     
    329354           
    330355          });
    331          
    332           return assoc;
     356       
     357        return metadata;
    333358      }
    334359
Note: See TracChangeset for help on using the changeset viewer.