Changeset 27257 for main/trunk/greenstone2/macros/document.dm
- Timestamp:
- 2013-04-24T21:20:27+12:00 (11 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.