Ignore:
Timestamp:
2013-04-29T20:25:28+12:00 (11 years ago)
Author:
ak19
Message:

Adding an Ajax Synchronous Post method to gsajaxapi.js which is then used by the setMetadataArray() that is called from document.dm. Also corrected a variable misspelling in baseaction (authenication changed to authentication) so that locating perl code that deals with authentication may become easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/macros/document.dm

    r27260 r27277  
    151151<script type="text/javascript"> 
    152152
    153     // http://stackoverflow.com/questions/3830244/get-current-date-time-in-seconds
     153    // Unused. Replaced in favour of call to escape() in setMetaArray function that calls urlPostSync
     154    // http://stackoverflow.com/questions/6020714/escape-html-using-jquery
    154155    function safeHTML(str) \{
    155156         return str.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace('"',"&quot;").replace("'","&#x27;").replace("/", "&#x2F;"); //"\\""
    156157    \}
     158
    157159
    158160    function addUserComment(_username, _comment, _docid, doc) \{
     
    163165            _docid = _docid.substring(0, period);
    164166        \}
    165        
    166         // Entity encode the values before storing (at least <, >, /. And single and double quote, ampersand)
    167         // http://stackoverflow.com/questions/6020714/escape-html-using-jquery
    168         _username = safeHTML(_username);
    169         _comment = safeHTML(_comment);     
     167
    170168
    171169        // Want to store username, timestamp and comment in import/metadata.xml, archives/doc.xml
     
    183181
    184182
    185         // To make individual api calls to set username meta, then timestamp then comment meta:
     183        // Entity encode the values before storing (at least <, >, /. And single and double quote, ampersand)
     184        // http://stackoverflow.com/questions/6020714/escape-html-using-jquery
     185        // setMetadataArray escapes the entire JSON, is that better than escaping individually here?
     186        //_docid = escape(_docid);
     187        //_timestamp = escape(_timestamp);
     188        //_username = escape(_username); //safeHTML(_username);
     189        //_comment = escape(_comment); //safeHTML(_comment);
     190
     191        // Use this if making individual api calls to set username meta, then timestamp then comment meta
    186192        // GSAPI already knows the collection
    187193        //gsapi.setMetadata(_docid, "username", null, _username, "accumulate", "import|archives|index");
     
    222228
    223229        // GSAPI already knows the collection
    224         gsapi.setMetadataArray(docArray, "accumulate","import|archives|index");
    225         //doc.AddUserCommentForm.comment.value = "submitted";
    226         doc.getElementById("usercommentfeedback").innerHTML = "_textcommentsubmitted_"; //"submitted"; // <p id="feedback"></p>
     230        gsapi.setMetadataArray(docArray, "accumulate", "import|archives|index");       
     231        doc.AddUserCommentForm.comment.value = "";
     232        doc.AddUserCommentForm.username.value = "";
     233        doc.getElementById("usercommentfeedback").innerHTML = "_textcommentsubmitted_";
    227234    \}
    228235</script>
Note: See TracChangeset for help on using the changeset viewer.