104 |
106 |
105 // Comment display |
107 // Comment display |
106 |
108 |
107 if ( data.count_total > 0 ) |
109 if ( data.count_total > 0 ) |
108 { |
110 { |
109 var parser = new templateParser(comment_template); |
111 comment_render_track = 0; |
110 for ( var i = 0; i < data.comments.length; i++ ) |
112 var commentpages = new paginator(data.comments, _render_comment, 0, 10, data); |
111 { |
113 html += commentpages.html; |
112 var tplvars = new Object(); |
|
113 |
|
114 if ( data.comments[i].approved != '1' && !data.auth_mod_comments ) |
|
115 continue; |
|
116 |
|
117 tplvars.ID = i; |
|
118 tplvars.DATETIME = data.comments[i].time; |
|
119 tplvars.SUBJECT = data.comments[i].subject; |
|
120 tplvars.DATA = data.comments[i].comment_data; |
|
121 tplvars.SIGNATURE = data.comments[i].signature; |
|
122 |
|
123 if ( data.comments[i].approved != '1' ) |
|
124 tplvars.SUBJECT += ' <span style="color: #D84308">(Unapproved)</span>'; |
|
125 |
|
126 // Name |
|
127 tplvars.NAME = data.comments[i].name; |
|
128 if ( data.comments[i].user_id > 1 ) |
|
129 tplvars.NAME = '<a href="' + makeUrlNS('User', data.comments[i].name) + '">' + data.comments[i].name + '</a>'; |
|
130 |
|
131 // User level |
|
132 tplvars.USER_LEVEL = 'Guest'; |
|
133 if ( data.comments[i].user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member'; |
|
134 if ( data.comments[i].user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator'; |
|
135 if ( data.comments[i].user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator'; |
|
136 |
|
137 // Send PM link |
|
138 tplvars.SEND_PM_LINK=(data.comments[i].user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( data.comments[i].name.replace(/ /g, '_') )) +'">Send private message</a><br />':''; |
|
139 |
|
140 // Add buddy link |
|
141 tplvars.ADD_BUDDY_LINK=(data.comments[i].user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( data.comments[i].name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':''; |
|
142 |
|
143 // Edit link |
|
144 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>'; |
|
145 |
|
146 // Delete link |
|
147 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">delete</a>'; |
|
148 |
|
149 // Moderation: (Un)approve link |
|
150 var appr = ( data.comments[i].approved == 1 ) ? 'Unapprove' : 'Approve'; |
|
151 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
|
152 |
|
153 // Moderation: Delete post link |
|
154 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">Delete</a>'; |
|
155 |
|
156 var tplbool = new Object(); |
|
157 |
|
158 tplbool.signature = ( data.comments[i].signature == '' ) ? false : true; |
|
159 tplbool.can_edit = ( data.auth_edit_comments && ( ( data.comments[i].user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
|
160 tplbool.auth_mod = data.auth_mod_comments; |
|
161 |
|
162 parser.assign_vars(tplvars); |
|
163 parser.assign_bool(tplbool); |
|
164 |
|
165 html += '<div id="comment_holder_' + i + '"><input type="hidden" value="'+data.comments[i].comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run() + '</div>'; |
|
166 } |
|
167 } |
114 } |
168 |
115 |
169 if ( data.auth_post_comments ) |
116 if ( data.auth_post_comments ) |
170 { |
117 { |
171 |
118 |
198 |
145 |
199 } |
146 } |
200 |
147 |
201 document.getElementById('ajaxEditContainer').innerHTML = html; |
148 document.getElementById('ajaxEditContainer').innerHTML = html; |
202 |
149 |
203 for ( i = 0; i < data.comments.length; i++ ) |
150 //for ( i = 0; i < data.comments.length; i++ ) |
204 { |
151 //{ |
205 document.getElementById('comment_source_'+i).value = data.comments[i].comment_source; |
152 // document.getElementById('comment_source_'+i).value = data.comments[i].comment_source; |
206 } |
153 //} |
207 |
154 |
|
155 } |
|
156 |
|
157 var _render_comment = function(this_comment, data) |
|
158 { |
|
159 var i = comment_render_track; |
|
160 comment_render_track++; |
|
161 var parser = new templateParser(comment_template); |
|
162 var tplvars = new Object(); |
|
163 |
|
164 if ( this_comment.approved != '1' && !data.auth_mod_comments ) |
|
165 return ''; |
|
166 |
|
167 tplvars.ID = i; |
|
168 tplvars.DATETIME = this_comment.time; |
|
169 tplvars.SUBJECT = this_comment.subject; |
|
170 tplvars.DATA = this_comment.comment_data; |
|
171 tplvars.SIGNATURE = this_comment.signature; |
|
172 |
|
173 if ( this_comment.approved != '1' ) |
|
174 tplvars.SUBJECT += ' <span style="color: #D84308">(Unapproved)</span>'; |
|
175 |
|
176 // Name |
|
177 tplvars.NAME = this_comment.name; |
|
178 if ( this_comment.user_id > 1 ) |
|
179 tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '">' + this_comment.name + '</a>'; |
|
180 |
|
181 // User level |
|
182 tplvars.USER_LEVEL = 'Guest'; |
|
183 if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member'; |
|
184 if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator'; |
|
185 if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator'; |
|
186 |
|
187 // Send PM link |
|
188 tplvars.SEND_PM_LINK=(this_comment.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">Send private message</a><br />':''; |
|
189 |
|
190 // Add buddy link |
|
191 tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':''; |
|
192 |
|
193 // Edit link |
|
194 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>'; |
|
195 |
|
196 // Delete link |
|
197 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">delete</a>'; |
|
198 |
|
199 // Moderation: (Un)approve link |
|
200 var appr = ( this_comment.approved == 1 ) ? 'Unapprove' : 'Approve'; |
|
201 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
|
202 |
|
203 // Moderation: Delete post link |
|
204 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">Delete</a>'; |
|
205 |
|
206 var tplbool = new Object(); |
|
207 |
|
208 tplbool.signature = ( this_comment.signature == '' ) ? false : true; |
|
209 tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
|
210 tplbool.auth_mod = data.auth_mod_comments; |
|
211 |
|
212 parser.assign_vars(tplvars); |
|
213 parser.assign_bool(tplbool); |
|
214 |
|
215 return '<div id="comment_holder_' + i + '"><input type="hidden" value="'+this_comment.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run() + '</div>'; |
208 } |
216 } |
209 |
217 |
210 function displayCommentForm() |
218 function displayCommentForm() |
211 { |
219 { |
212 document.getElementById('leave_comment_button').style.display = 'none'; |
220 document.getElementById('leave_comment_button').style.display = 'none'; |