Ignore:
Timestamp:
2023-09-26T21:56:47+13:00 (8 months ago)
Author:
anupama
Message:

Removed most of the debugging statements when removing user comments. Added one console.log statement for feedback/informative purposes. Still one TODO needs checking: on error, I reload page as Dr Bainbridge specified, but want to ask Dr Bainbridge if there are any page parameters that may not get preserved but need preserving. Basically, I want to ask if a simple location.reload() suffices as I've chosen to do at present. This branch of the code is untested as there are no errors at present.

Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js

    r38218 r38234  
    10291029            where, successResponseFunction, forceSync, errorResponseFunction)
    10301030{
    1031     alert("in gs.functions.removeMetaArray START");
    1032    
    10331031    if( typeof errorResponseFunction === 'undefined' ) { errorResponseFunction = null; } // force error callback to be defined: either null or has value
    10341032
     
    10451043    var response = gs.functions._callMetadataServer("Removing metadata from "+where, payload, successResponseFunction, errorResponseFunction, {"forceSync": forceSync, "requestMethod": "POST"});
    10461044
    1047     console.log("in gs.functions.removeMetaArray: " + JSON.stringify(payload));
     1045    //console.log("in gs.functions.removeMetaArray: " + JSON.stringify(payload));
    10481046   
    10491047    return response;
  • main/trunk/greenstone3/web/interfaces/default/js/user_comments.js

    r38232 r38234  
    327327    }
    328328
     329    console.log("About to remove usercomments at metapositions: " + metadataPositions);
    329330   
    330331    gs.functions.removeMetadataArray(
     
    339340    );
    340341   
    341 
    342     //console.log("username: " + opt_metaname_username + " - " + gs.usercomments.defaults.metaname_username);
    343     console.log("metapositions to remove: " + metadataPositions);
    344     console.log("docArray:\n" + JSON.stringify(docArray));
     342    //console.log("metapositions to remove: " + metadataPositions);
     343    //console.log("docArray:\n" + JSON.stringify(docArray));
    345344}
    346345
     
    351350
    352351    // TODO, force a page reload so that the usercomments' state somewhat better reflects what's in DBs
     352    location.reload();
    353353}
    354354
     
    461461    var result = (data.responseText) ? data.responseText : data;       
    462462
    463     //alert(result);
    464     console.log("@@@ Done removing metadata:\n" + result);
     463    //console.log("@@@ Done removing metadata:\n" + result);
    465464   
    466465    var userCommentsDiv = document.getElementById("usercomments");
     
    495494}
    496495
    497 
    498 /*
    499 gs.usercomments.removeUserComment = function (_usernames, _timestamps, _comments, _docid, doc,
    500           opt_metaname_username, opt_metaname_usertimestamp, opt_metaname_usercomment)
    501 {
    502     // Want to remove usernames, timestamps and comments from import/metadata.xml,
    503     // archives/doc.xml and index/col.gdb.
    504    
    505     // Need to the add user comment meta of username, timestamp and comment to the
    506     // topmost section of the document. So only get the docId up to any period mark:
    507     var period = _docid.indexOf(".");
    508     if(period != -1) {
    509     _docid = _docid.substring(0, period);
    510     }
    511    
    512     // Use the new JSON metatable format to remove list of usernames, their matching timestamps and comments meta for docid in one go
    513     // For creating the JSON object that gets turned into a string, see
    514     // http://msdn.microsoft.com/en-us/library/ie/cc836459%28v=vs.94%29.aspx
    515     // http://jsfiddle.net/qmacro/W54hy/
    516    
    517     var username_rec = {
    518     metaname: opt_metaname_username || gs.usercomments.defaults.metaname_username, // e.g. "username"
    519     metavals: _usernames
    520     };
    521    
    522     var timestamp_rec = {
    523     metaname: opt_metaname_usertimestamp || gs.usercomments.defaults.metaname_usertimestamp, // e.g. "usertimestamp"
    524     metavals: _timestamps
    525     };
    526    
    527     var comment_rec = {
    528     metaname: opt_metaname_usercomment || gs.usercomments.defaults.metaname_usercomment, // e.g. "usercomment"
    529     metavals: _comments
    530     };
    531    
    532     var doc_rec = {
    533     docid: _docid,
    534     metatable: [username_rec, timestamp_rec, comment_rec],
    535     metamode: "accumulate" // TODO
    536     };
    537    
    538     var docArray = [doc_rec];
    539    
    540     // Don't allow the user to submit further comments or delete comments
    541     // until the metadata has been updated
    542     document.getElementById("usercommentSubmitButton").disabled = true;
    543     var delCommentsButton = document.getElementById("delCommentsButton");
    544     if(delCommentsButton != undefined) {// should be defined when in this function
    545     delCommentsButton.disabled = true;
    546     }
    547 
    548     // There is no remove array version yet!!!
    549    
    550     //var result = gs.functions.setMetadataArray(gs.variables["c"], gs.variables["site"], docArray, "accumulate", "import|archives|index");
    551     gs.functions.removeMetadataArray(gs.variables["c"],
    552     gs.variables["site"],
    553     docArray, "accumulate",
    554     "import|archives|index",
    555     function(ajaxResult) { return gs.usercomments.doneUpdatingMetatada(ajaxResult, _username, _timestamp, _comment); },
    556     true); // true for synchronous, meaning is opposite to explanation for addUserComment() function below   
    557    
    558 }
    559 */
    560496
    561497gs.usercomments.addUserComment = function(_username, _comment, _docid, doc,
Note: See TracChangeset for help on using the changeset viewer.