Ignore:
Timestamp:
2013-05-02T17:43:31+12:00 (11 years ago)
Author:
ak19
Message:

Some bugfixes and improvements to the existing Add User Comment form before committing changes for the authentication. Fixes like checking for empty strings entered for the comment which shouldn't go in the database. And after a comment is submitted, it needs to be added to the existing list of displayed user comments, instead of reloading them all.

File:
1 edited

Legend:

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

    r27281 r27293  
    166166
    167167    function addUserComment(_username, _comment, _docid, doc) \{
     168
     169        // don't add empty strings for name/comment     
     170
     171        // http://stackoverflow.com/questions/498970/how-do-i-trim-a-string-in-javascript
     172        var trimmed_username=_username.replace(/^\s+|\s+$/g, '');
     173        var trimmed_comment = _comment.replace(/^\s+|\s+$/g, '');
     174       
     175        if(!trimmed_username || !trimmed_comment) \{
     176              doc.AddUserCommentForm.comment.value = "";
     177              doc.AddUserCommentForm.username.value = "";
     178              doc.getElementById("usercommentfeedback").innerHTML = "_text-is-empty_";
     179              return;
     180        \}
     181
    168182        // Need to the add user comment meta of username, timestamp and comment to the
    169183        // topmost section of the document. So only get the docId up to any period mark:
     
    241255
    242256        // update display of existing user comments to show the newly added comment
    243         loadUserComments();
     257        var usercommentdiv = document.getElementById("usercomments");
     258        if(usercommentdiv != undefined) \{
     259             displayInUserCommentList(usercommentdiv, _username, _timestamp, _comment);
     260        \}
    244261    \}
    245262</script>
Note: See TracChangeset for help on using the changeset viewer.