- Timestamp:
- 2013-04-24T21:20:27+12:00 (11 years ago)
- Location:
- main/trunk/greenstone2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/macros/document.dm
r25396 r27257 105 105 <table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0> 106 106 <tr><td align=left valign=top> 107 _usercomment_ 107 108 _prevarrow_ 108 109 </td><td align=right valign=top> … … 118 119 _prevarrow_<br> 119 120 _nextarrow_ 121 } 122 123 ####################################################################### 124 # section for adding user comments: consists of form and its javascript 125 ####################################################################### 126 127 # For 128 # http://stackoverflow.com/questions/4264091/input-type-submit-instead-of-input-type-button-with-ajax 129 # http://stackoverflow.com/questions/8869341/ajax-form-submit-with-submit-button 130 131 _usercomment_ { 132 133 <form name="AddUserCommentForm"> 134 <p>_textcommentusername_ <input type="text" name="username"></p> 135 <p> 136 _textaddusercomment_ 137 <textarea name="comment" rows="10" cols="70"></textarea> 138 <input type=hidden name="d" value="_cgiargd_"> 139 </p> 140 141 <input type="submit" value="_textaddcomment_" onclick="addUserComment(document.AddUserCommentForm.username.value, document.AddUserCommentForm.comment.value, document.AddUserCommentForm.d.value); return false;"> 142 </form> 143 144 <script type="text/javascript"> 145 function addUserComment(_username, _comment, _docid) \{ 146 147 // Want to store username, timestamp and comment in import/metadata.xml, archives/doc.xml 148 // and index/col.gdb. 149 150 // For getting the current time, see 151 // http://stackoverflow.com/questions/3830244/get-current-date-time-in-seconds 152 var _timestamp = new Date().getTime(); // div by 1000 to get seconds. valueOf() may return string 153 154 //alert("username:" + _username 155 //+ "\\ncomment: " + _comment 156 //+ "\\ncollection: " + collection 157 //+ "\\ndocid: " + _docid 158 //+ "\\ntimestamp: " + _timestamp); 159 160 161 // To make individual api calls to set username meta, then timestamp then comment meta: 162 // GSAPI already knows the collection 163 //gsapi.setMetadata(_docid, "username", null, _username, "accumulate", "import|archives|index"); 164 //gsapi.setMetadata(_docid, "usertimestamp", null, _timestamp, "accumulate", "import|archives|index"); 165 //gsapi.setMetadata(_docid, "usercomment", null, _comment, "accumulate", "import|archives|index"); 166 167 168 // Use the new JSON metatable format to set username, timestamp and comment meta for docid in one go 169 170 // For creating the JSON object that gets turned into a string, see 171 // http://msdn.microsoft.com/en-us/library/ie/cc836459%28v=vs.94%29.aspx 172 // http://jsfiddle.net/qmacro/W54hy/ 173 174 var username_rec = \{ 175 metaname: "username", 176 metavals: [_username] 177 \}; 178 179 var timestamp_rec = \{ 180 metaname: "timestamp", 181 metavals: [_timestamp] 182 \}; 183 184 var comment_rec = \{ 185 metaname: "comment", 186 metavals: [_comment] 187 \}; 188 189 var doc_rec = \{ 190 docid: _docid, 191 metatable: [username_rec, timestamp_rec, comment_rec], 192 metamode: "accumulate" 193 \}; 194 195 var docArray = [doc_rec]; 196 197 //alert(JSON.stringify(docArray)); 198 199 // GSAPI already knows the collection 200 gsapi.setMetadataArray(docArray, "accumulate","import|archives|index"); 201 202 \} 203 </script> 120 204 } 121 205 -
main/trunk/greenstone2/macros/english.dm
r27060 r27257 336 336 } 337 337 338 _textcommentusername_ {User name:} 339 _textaddusercomment_ {Add user comment:} 340 _textaddcomment_ {add comment} 341 338 342 _textgoto_ {go to page} 339 343 _textintro_ { <i>(introductory text)</i>} -
main/trunk/greenstone2/web/script/gsajaxapi.js
r24072 r27257 139 139 } 140 140 141 142 143 144 145 141 this.setLiveMetadata = function(id,metaname,metavalue) 146 142 { … … 155 151 this.urlGetSync(url); 156 152 } 157 153 154 // New 155 // The where parameter can be specified as one or more of: import, archives, index, live 156 // separated by |. If null, it is assumed to be index which is the original default 157 // behaviour of calling set-metadata). E.g. where=import|archives|index 158 this.setMetadata = function(docid,metaname,metapos,metavalue,metamode,where) 159 { 160 var mdserver = this.metadataserverURL(); 161 162 var params = "a=set-metadata"; 163 if(where != null) { 164 params += "&where=" + where; // if where not specified, meta-server will default to setting index meta 165 //} else { 166 // params += "&where=import|archives|index"; 167 } 168 params += "&c="+collect_; 169 params += "&d="+docid; 170 params += "&metaname=" + metaname; 171 if (metapos!=null) { 172 params += "&metapos=" + metapos; 173 } 174 params += "&metavalue=" + metavalue; 175 if (metamode!=null) { 176 params += "&metamode=" + metamode; 177 } 178 179 this.urlGetSync(mdserver + "?" + params); 180 //this.urlPostSync(mdserver,params); 181 } 182 183 // New 184 // The where parameter can be specified as one or more of: import, archives, index, live 185 // separated by |. If null, it is assumed to be index which is the original default 186 // behaviour of calling set-metadata-array). E.g. where=import|archives|index 187 this.setMetadataArray = function(docArray,metamode,where) 188 { 189 docArrayJSON = JSON.stringify(docArray); 190 191 var mdserver = this.metadataserverURL(); 192 193 var params = "a=set-metadata-array"; 194 if(where != null) { 195 params += "&where=" + where; // if where not specified, meta-server will default to setting index meta 196 //} else { 197 // params += "&where=import|archives|index"; 198 } 199 params += "&c="+collect_; 200 params += "&json="+docArrayJSON; 201 202 if (metamode!=null) { 203 params += "&metamode=" + metamode; 204 } 205 206 this.urlGetSync(mdserver + "?" + params); 207 208 } 209 158 210 this._setMetadata = function(mode,docid,metaname,metapos,metavalue,metamode) 159 211 { … … 168 220 } 169 221 params += "&metavalue=" + metavalue; 170 222 if (metamode!=null) { 171 223 params += "&metamode=" + metamode; 172 224 } 173 225 174 226 this.urlGetSync(mdserver + "?" + params); … … 177 229 178 230 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 231 this._setDocumentArrayMetadata = function(mode,docArray,metamode) 232 { 233 docArrayJSON = JSON.stringify(docArray); 234 235 var mdserver = this.metadataserverURL(); 236 237 var params = "a=set" + mode + "-metadata-array"; 238 params += "&c="+collect_; 239 params += "&json="+docArrayJSON; 240 241 if (metamode!=null) { 242 params += "&metamode=" + metamode; 243 } 244 245 this.urlGetSync(mdserver + "?" + params); 246 247 } 196 248 197 249
Note:
See TracChangeset
for help on using the changeset viewer.