Show
Ignore:
Timestamp:
07.05.2013 19:32:42 (7 years ago)
Author:
ak19
Message:

Now the existing user comments to be displayed are all retrieved in one go using the new get_metadata_array subroutine in metadataaction.pm via the new gsajaxapi method getMetadataArray which take a JSON string and return one. This loads user comments much faster, and doesn't get that much slower if the number of comments stored in the index database gets larger. 2 bugfixes to metadataaction.pm's recently added get_metadata_array subroutine: if no metapos supplied it defaults to 0 like the other get_meta functions instead of defaulting to the keyword 'all'. The fieldnames in the JSON string returned also needed to be inside double quotes in order to be successfully parsed back into a JSON object on the Javascript side. Replaced the old loadUserComments() javascript function in style.dm, which now calls the new gsajaxapi.getMetadataArray() post method.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/web/script/gsajaxapi.js

    r27281 r27313  
    271271    } 
    272272 
     273    this.getMetadataArray = function(docArray,where) 
     274    { 
     275    docArrayJSON = JSON.stringify(docArray); 
     276 
     277    var mdserver = this.metadataserverURL(); 
     278     
     279    var params = "a=" + escape("get-metadata-array"); //"a=set-metadata-array"; 
     280    if(where != null) { 
     281        params += "&where=" + escape(where); // if where not specified, meta-server will default to setting index meta 
     282        //} else { 
     283        //    params += "&where=import|archives|index"; 
     284    } 
     285    params += "&c="+escape(collect_); 
     286    params += "&json="+escape(docArrayJSON); 
     287     
     288    //this.urlGetSync(mdserver + "?" + params); 
     289    return this.urlPostSync(mdserver,params);    
     290    } 
     291 
     292 
    273293    this._setMetadata = function(mode,docid,metaname,metapos,metavalue,metamode) 
    274294    {