- Timestamp:
- 2023-04-23T22:33:27+12:00 (12 months ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/user_comments.js
r31559 r37704 20 20 gs.usercomments = {}; 21 21 22 gs.usercomments.defaults = { 23 "metaname_username" : "username", 24 "metaname_usertimestamp": "usertimestamp", 25 "metaname_usercomment" : "usercomment" 26 } 27 22 28 // http://stackoverflow.com/questions/6312993/javascript-seconds-to-time-with-format-hhmmss 23 29 // Call as: alert(timestamp.printTime()); … … 28 34 } 29 35 30 gs.usercomments.loadUserComments = function( ) {36 gs.usercomments.loadUserComments = function(opt_metaname_username, opt_metaname_usertimestamp, opt_metaname_usercomment) { 31 37 32 38 // don't bother loading comments if we're not on a document page (in which case there's no docid) … … 54 60 doc_id = doc_id.substring(0, period); 55 61 } 56 62 63 /* The current pattern of use (from usercomments.xsl) is to globally override/redefine 64 the metadata names in gs.usercomments.defaults{ values }. However, anticipating 65 future, more general use, loadUserComments() and addUserComment() have been written 66 with the ability to have optional parameters passed in the supersede the values in 67 gs.usercomments.defaults{} */ 68 57 69 var username_rec = { 58 metaname: "username",70 metaname: opt_metaname_username || gs.usercomments.defaults.metaname_username, // e.g. "username" 59 71 metapos: "all" 60 72 }; 61 73 62 74 var timestamp_rec = { 63 metaname: "usertimestamp",75 metaname: opt_metaname_usertimestamp || gs.usercomments.defaults.metaname_usertimestamp, // e.g. "usertimestamp" 64 76 metapos: "all" 65 77 }; 66 78 67 79 var comment_rec = { 68 metaname: "usercomment",80 metaname: opt_metaname_usercomment || gs.usercomments.defaults.metaname_usercomment, // e.g. "usercomment" 69 81 metapos: "all" 70 82 }; … … 79 91 //var json_result_str = gs.functions.getMetadataArray(gs.variables["c"], gs.variables["site"], docArray, "index"); 80 92 81 gs.functions.getMetadataArray(gs.variables["c"], gs.variables["site"], docArray, "index", gs.usercomments.loadedUserComments, false); // false for asynchronous 93 gs.functions.getMetadataArray(gs.variables["c"], gs.variables["site"], docArray, "index", 94 gs.usercomments.loadedUserComments, false); // false for asynchronous 82 95 } 83 96 … … 132 145 var username = metaval_rec.metavalue; 133 146 var timestamp = metatable[1].metavals[i].metavalue; 134 var comment = metatable[2].metavals[i].metavalue;147 var comment = metatable[2].metavals[i].metavalue; 135 148 136 149 // No need to sort by time, as the meta are already stored sorted … … 188 201 } 189 202 190 gs.usercomments.addUserComment = function(_username, _comment, _docid, doc) { 203 gs.usercomments.addUserComment = function(_username, _comment, _docid, doc, 204 opt_metaname_username, opt_metaname_usertimestamp, opt_metaname_usercomment) { 191 205 192 206 // don't add empty strings for name/comment … … 232 246 233 247 var username_rec = { 234 metaname: "username",248 metaname: opt_metaname_username || gs.usercomments.defaults.metaname_username, // e.g. "username" 235 249 metavals: [_username] 236 250 }; 237 251 238 252 var timestamp_rec = { 239 metaname: "usertimestamp",253 metaname: opt_metaname_usertimestamp || gs.usercomments.defaults.metaname_usertimestamp, // e.g. "usertimestamp" 240 254 metavals: [_timestamp] 241 255 }; 242 256 243 257 var comment_rec = { 244 metaname: "usercomment",258 metaname: opt_metaname_usercomment || gs.usercomments.defaults.metaname_usercomment, // e.g. "usercomment" 245 259 metavals: [_comment] 246 260 }; -
main/trunk/greenstone3/web/interfaces/default/transform/layouts/usercomments.xsl
r33755 r37704 9 9 exclude-result-prefixes="java util gsf"> 10 10 11 <xsl:template name="userCommentsDefineMetanames"> 12 <gsf:script> 13 <!-- Older Greenstone3 installations did not use metadata namespace/prefix for usercomment metadata 14 15 From GS3.11 onwards, this is now part of the Greenstone metadata set (gs.), allowing usercomments 16 to be edited and managed from GLI. 17 18 If you want the older way of doing things, replace the JS syntax below the commented out block 19 --> 20 21 <!-- 22 gs.usercomments.defaults.metaname_username = "username"; 23 gs.usercomments.defaults.metaname_usertimestamp = "usertimestamp"; 24 gs.usercomments.defaults.metaname_usercomment = "usercomment"; 25 --> 26 27 gs.usercomments.defaults.metaname_username = "gs.username"; 28 gs.usercomments.defaults.metaname_usertimestamp = "gs.usertimestamp"; 29 gs.usercomments.defaults.metaname_usercomment = "gs.usercomment"; 30 </gsf:script> 31 </xsl:template> 32 11 33 <xsl:template name="userCommentsSection"> 12 34 <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='allowUserComments']/@value='true'"> … … 23 45 <script type="text/javascript" src="interfaces/{$interface_name}/js/gsajaxapi.js"><xsl:text> </xsl:text></script> 24 46 <script type="text/javascript" src="interfaces/{$interface_name}/js/user_comments.js"><xsl:text> </xsl:text></script> 25 47 <xsl:call-template name="userCommentsDefineMetanames"/> 26 48 27 49 <!-- 3. Set up the User comments section in the HTML -->
Note:
See TracChangeset
for help on using the changeset viewer.