3 var comment_template = false; |
3 var comment_template = false; |
4 var comment_render_track = 0; |
4 var comment_render_track = 0; |
5 |
5 |
6 window.ajaxComments = function(parms) |
6 window.ajaxComments = function(parms) |
7 { |
7 { |
8 load_component(['l10n', 'paginate', 'template-compiler', 'toolbar', 'flyin', 'jquery', 'jquery-ui']); |
8 load_component(['l10n', 'paginate', 'template-compiler', 'toolbar', 'flyin', 'jquery', 'jquery-ui']); |
9 setAjaxLoading(); |
9 setAjaxLoading(); |
10 var pid = strToPageID(title); |
10 var pid = strToPageID(title); |
11 if(!parms) |
11 if(!parms) |
12 { |
12 { |
13 var parms = { |
13 var parms = { |
14 mode: 'fetch', |
14 mode: 'fetch', |
15 pagenum: 0 |
15 pagenum: 0 |
16 }; |
16 }; |
17 } |
17 } |
18 parms.page_id = pid[0]; |
18 parms.page_id = pid[0]; |
19 parms.namespace = pid[1]; |
19 parms.namespace = pid[1]; |
20 if(comment_template) |
20 if(comment_template) |
21 parms.have_template = true; |
21 parms.have_template = true; |
22 parms = ajaxEscape(toJSONString(parms)); |
22 parms = ajaxEscape(toJSONString(parms)); |
23 ajaxPost(stdAjaxPrefix+'&_mode=comments', 'data=' + parms, function(ajax) { |
23 ajaxPost(stdAjaxPrefix+'&_mode=comments', 'data=' + parms, function(ajax) { |
24 if ( ajax.readyState == 4 && ajax.status == 200 ) { |
24 if ( ajax.readyState == 4 && ajax.status == 200 ) { |
25 unsetAjaxLoading(); |
25 unsetAjaxLoading(); |
26 selectButtonMajor('discussion'); |
26 selectButtonMajor('discussion'); |
27 unselectAllButtonsMinor(); |
27 unselectAllButtonsMinor(); |
28 // IE compatibility - doing ajax.responseText.substr() doesn't work |
28 // IE compatibility - doing ajax.responseText.substr() doesn't work |
29 var rsptxt = ajax.responseText + ''; |
29 var rsptxt = ajax.responseText + ''; |
30 if ( rsptxt.substr(0, 1) != '{' ) |
30 if ( rsptxt.substr(0, 1) != '{' ) |
31 { |
31 { |
32 document.getElementById('ajaxEditContainer').innerHTML = '<p>Comment system Javascript runtime: invalid JSON response from server, response text:</p><pre>' + ajax.responseText + '</pre>'; |
32 document.getElementById('ajaxEditContainer').innerHTML = '<p>Comment system Javascript runtime: invalid JSON response from server, response text:</p><pre>' + ajax.responseText + '</pre>'; |
33 return false; |
33 return false; |
34 } |
34 } |
35 var response = parseJSON(ajax.responseText); |
35 var response = parseJSON(ajax.responseText); |
36 switch(response.mode) |
36 switch(response.mode) |
37 { |
37 { |
38 case 'fetch': |
38 case 'fetch': |
39 if(response.template) |
39 if(response.template) |
40 comment_template = response.template; |
40 comment_template = response.template; |
41 setAjaxLoading(); |
41 setAjaxLoading(); |
42 renderComments(response); |
42 renderComments(response); |
43 unsetAjaxLoading(); |
43 unsetAjaxLoading(); |
44 break; |
44 break; |
45 case 'refetch': |
45 case 'refetch': |
46 var html = ''; |
46 var html = ''; |
47 for ( var i = 0; i < response.comments.length; i++ ) |
47 for ( var i = 0; i < response.comments.length; i++ ) |
48 { |
48 { |
49 html += window._render_comment(response.comments[i], response); |
49 html += window._render_comment(response.comments[i], response); |
50 } |
50 } |
51 $('#' + response.passback.paginator_id + '_0') |
51 $('#' + response.passback.paginator_id + '_0') |
52 .css('height', 'auto') |
52 .css('height', 'auto') |
53 .css('background-color', 'transparent') |
53 .css('background-color', 'transparent') |
54 .css('background-image', 'none') |
54 .css('background-image', 'none') |
55 .fadeTo('fast', 100) |
55 .fadeTo('fast', 100) |
56 .html(html); |
56 .html(html); |
57 break; |
57 break; |
58 case 'redraw': |
58 case 'redraw': |
59 redrawComment(response); |
59 redrawComment(response); |
60 break; |
60 break; |
61 case 'annihilate': |
61 case 'annihilate': |
62 annihiliateComment(response.id); |
62 annihiliateComment(response.id); |
63 break; |
63 break; |
64 case 'materialize': |
64 case 'materialize': |
65 alert($lang.get('comment_msg_comment_posted')); |
65 alert($lang.get('comment_msg_comment_posted')); |
66 hideCommentForm(); |
66 hideCommentForm(); |
67 materializeComment(response); |
67 materializeComment(response); |
68 break; |
68 break; |
69 case 'error': |
69 case 'error': |
70 load_component(['messagebox', 'fadefilter', 'flyin']); |
70 load_component(['messagebox', 'fadefilter', 'flyin']); |
71 new MessageBox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : $lang.get('comment_ajax_err_generic_title') ), response.error); |
71 new MessageBox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : $lang.get('comment_ajax_err_generic_title') ), response.error); |
72 break; |
72 break; |
73 default: |
73 default: |
74 alert(ajax.responseText); |
74 alert(ajax.responseText); |
75 break; |
75 break; |
76 } |
76 } |
77 } |
77 } |
78 }); |
78 }); |
79 } |
79 } |
80 |
80 |
81 window.renderComments = function(data) |
81 window.renderComments = function(data) |
82 { |
82 { |
83 |
83 |
84 var html = ''; |
84 var html = ''; |
85 |
85 |
86 // Header |
86 // Header |
87 |
87 |
88 html += '<h3>' + $lang.get('comment_heading') + '</h3>'; |
88 html += '<h3>' + $lang.get('comment_heading') + '</h3>'; |
89 |
89 |
90 var ns = ENANO_PAGE_TYPE; |
90 var ns = ENANO_PAGE_TYPE; |
91 |
91 |
92 // Counters |
92 // Counters |
93 if ( data.auth_mod_comments ) |
93 if ( data.auth_mod_comments ) |
94 { |
94 { |
95 var cnt = ( data.auth_mod_comments ) ? data.count_total : data.count_appr; |
95 var cnt = ( data.auth_mod_comments ) ? data.count_total : data.count_appr; |
96 |
96 |
97 var subst = { |
97 var subst = { |
98 num_comments: cnt, |
98 num_comments: cnt, |
99 page_type: ns |
99 page_type: ns |
100 } |
100 } |
101 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
101 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
102 |
102 |
103 html += "<p id=\"comment_status\"><span>" + count_msg + '</span>'; |
103 html += "<p id=\"comment_status\"><span>" + count_msg + '</span>'; |
104 if ( data.count_unappr > 0 ) |
104 if ( data.count_unappr > 0 ) |
105 { |
105 { |
106 html += ' <span style="color: #D84308" id="comment_status_unapp">' + $lang.get('comment_msg_count_unapp_mod', { num_unapp: data.count_unappr }) + '</span>'; |
106 html += ' <span style="color: #D84308" id="comment_status_unapp">' + $lang.get('comment_msg_count_unapp_mod', { num_unapp: data.count_unappr }) + '</span>'; |
107 } |
107 } |
108 html += '</p>'; |
108 html += '</p>'; |
109 } |
109 } |
110 else |
110 else |
111 { |
111 { |
112 var cnt = data.count_appr; |
112 var cnt = data.count_appr; |
113 |
113 |
114 var subst = { |
114 var subst = { |
115 num_comments: cnt, |
115 num_comments: cnt, |
116 page_type: ns |
116 page_type: ns |
117 } |
117 } |
118 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
118 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
119 |
119 |
120 html += "<p id=\"comment_status\">" + count_msg; |
120 html += "<p id=\"comment_status\">" + count_msg; |
121 if ( data.count_unappr > 0 ) |
121 if ( data.count_unappr > 0 ) |
122 { |
122 { |
123 var unappr_msg = ( data.count_unappr == 1 ) ? $lang.get('comment_msg_count_unapp_one') : $lang.get('comment_msg_count_unapp_plural', { num_unapp: data.count_unappr }); |
123 var unappr_msg = ( data.count_unappr == 1 ) ? $lang.get('comment_msg_count_unapp_one') : $lang.get('comment_msg_count_unapp_plural', { num_unapp: data.count_unappr }); |
124 html += ' ' + unappr_msg; |
124 html += ' ' + unappr_msg; |
125 } |
125 } |
126 html += '</p>'; |
126 html += '</p>'; |
127 } |
127 } |
128 |
128 |
129 // Comment display |
129 // Comment display |
130 |
130 |
131 if ( data.count_total > 0 ) |
131 if ( data.count_total > 0 ) |
132 { |
132 { |
133 comment_render_track = 0; |
133 comment_render_track = 0; |
134 var commentpages = new paginator(data.comments, _render_comment, 0, data.per_page, data, Math.ceil(data.count_total / data.per_page), window._comment_page_flip); |
134 var commentpages = new paginator(data.comments, _render_comment, 0, data.per_page, data, Math.ceil(data.count_total / data.per_page), window._comment_page_flip); |
135 html += commentpages.html; |
135 html += commentpages.html; |
136 } |
136 } |
137 |
137 |
138 if ( data.auth_post_comments ) |
138 if ( data.auth_post_comments ) |
139 { |
139 { |
140 // Posting form |
140 // Posting form |
141 |
141 |
142 html += '<h3>' + $lang.get('comment_postform_title') + '</h3>'; |
142 html += '<h3>' + $lang.get('comment_postform_title') + '</h3>'; |
143 html += '<p>' + $lang.get('comment_postform_blurb'); |
143 html += '<p>' + $lang.get('comment_postform_blurb'); |
144 if ( data.approval_needed ) |
144 if ( data.approval_needed ) |
145 html+=' ' + $lang.get('comment_postform_blurb_unapp'); |
145 html+=' ' + $lang.get('comment_postform_blurb_unapp'); |
146 html += ' <a id="leave_comment_button" href="#" onclick="displayCommentForm(); return false;">' + $lang.get('comment_postform_blurb_link') + '</a></p>'; |
146 html += ' <a id="leave_comment_button" href="#" onclick="displayCommentForm(); return false;">' + $lang.get('comment_postform_blurb_link') + '</a></p>'; |
147 html += '<div id="comment_form" style="display: none;">'; |
147 html += '<div id="comment_form" style="display: none;">'; |
148 html += ' <table border="0" style="width: 100%;">'; |
148 html += ' <table border="0" style="width: 100%;">'; |
149 html += ' <tr><td>' + $lang.get('comment_postform_field_name') + '</td><td>'; |
149 html += ' <tr><td>' + $lang.get('comment_postform_field_name') + '</td><td>'; |
150 if ( data.user_id > 1 ) html += data.username + '<input id="commentform_name" type="hidden" value="'+data.username+'" size="40" />'; |
150 if ( data.user_id > 1 ) html += data.username + '<input id="commentform_name" type="hidden" value="'+data.username+'" size="40" />'; |
151 else html += '<input id="commentform_name" type="text" size="40" style="width: 100%;" />'; |
151 else html += '<input id="commentform_name" type="text" size="40" style="width: 100%;" />'; |
152 html += ' </td></tr>'; |
152 html += ' </td></tr>'; |
153 html += ' <tr><td>' + $lang.get('comment_postform_field_subject') + '</td><td><input id="commentform_subject" type="text" size="40" style="width: 100%;" /></td></tr>'; |
153 html += ' <tr><td>' + $lang.get('comment_postform_field_subject') + '</td><td><input id="commentform_subject" type="text" size="40" style="width: 100%;" /></td></tr>'; |
154 html += ' <tr><td>' + $lang.get('comment_postform_field_comment') + '</td><td><textarea id="commentform_message" rows="15" cols="50" style="width: 100%;"></textarea></td></tr>'; |
154 html += ' <tr><td>' + $lang.get('comment_postform_field_comment') + '</td><td><textarea id="commentform_message" rows="15" cols="50" style="width: 100%;"></textarea></td></tr>'; |
155 if ( !data.logged_in && data.guest_posting == '1' ) |
155 if ( !data.logged_in && data.guest_posting == '1' ) |
156 { |
156 { |
157 html += ' <tr><td>' + $lang.get('comment_postform_field_captcha_title') + '<br /><small>' + $lang.get('comment_postform_field_captcha_blurb') + '</small></td><td>'; |
157 html += ' <tr><td>' + $lang.get('comment_postform_field_captcha_title') + '<br /><small>' + $lang.get('comment_postform_field_captcha_blurb') + '</small></td><td>'; |
158 html += ' <img alt="CAPTCHA image" src="'+makeUrlNS('Special', 'Captcha/' + data.captcha)+'" onclick="this.src=\''+makeUrlNS('Special', 'Captcha/' + data.captcha)+'/\'+Math.floor(Math.random()*10000000);" style="cursor: pointer;" /><br />'; |
158 html += ' <img alt="CAPTCHA image" src="'+makeUrlNS('Special', 'Captcha/' + data.captcha)+'" onclick="this.src=\''+makeUrlNS('Special', 'Captcha/' + data.captcha)+'/\'+Math.floor(Math.random()*10000000);" style="cursor: pointer;" /><br />'; |
159 html += ' ' + $lang.get('comment_postform_field_captcha_label') + ' <input type="text" size="8" id="commentform_captcha" />'; |
159 html += ' ' + $lang.get('comment_postform_field_captcha_label') + ' <input type="text" size="8" id="commentform_captcha" />'; |
160 html += ' <!-- This input is used to track the ID of the CAPTCHA image --> <input type="hidden" id="commentform_captcha_id" value="'+data.captcha+'" />'; |
160 html += ' <!-- This input is used to track the ID of the CAPTCHA image --> <input type="hidden" id="commentform_captcha_id" value="'+data.captcha+'" />'; |
161 html += ' </td></tr>'; |
161 html += ' </td></tr>'; |
162 } |
162 } |
163 html += ' <tr><td colspan="2" style="text-align: center;"><input type="button" onclick="submitComment();" value="' + $lang.get('comment_postform_btn_submit') + '" /></td></tr>'; |
163 html += ' <tr><td colspan="2" style="text-align: center;"><input type="button" onclick="submitComment();" value="' + $lang.get('comment_postform_btn_submit') + '" /></td></tr>'; |
164 html += ' </table>'; |
164 html += ' </table>'; |
165 html += '</div>'; |
165 html += '</div>'; |
166 } |
166 } |
167 |
167 |
168 document.getElementById('ajaxEditContainer').innerHTML = html; |
168 document.getElementById('ajaxEditContainer').innerHTML = html; |
169 if ( document.getElementById('commentform_message') ) |
169 if ( document.getElementById('commentform_message') ) |
170 { |
170 { |
171 document.getElementById('commentform_message').allow_wysiwyg = data.auth_edit_wysiwyg |
171 document.getElementById('commentform_message').allow_wysiwyg = data.auth_edit_wysiwyg |
172 } |
172 } |
173 |
173 |
174 for ( i = 0; i < data.comments.length; i++ ) |
174 for ( i = 0; i < data.comments.length; i++ ) |
175 { |
175 { |
176 document.getElementById('comment_source_'+i).value = data.comments[i].comment_source; |
176 document.getElementById('comment_source_'+i).value = data.comments[i].comment_source; |
177 } |
177 } |
178 |
178 |
179 } |
179 } |
180 |
180 |
181 var _render_comment = function(this_comment, data) |
181 var _render_comment = function(this_comment, data) |
182 { |
182 { |
183 var i = comment_render_track; |
183 var i = comment_render_track; |
184 comment_render_track++; |
184 comment_render_track++; |
185 var parser = new templateParser(comment_template); |
185 var parser = new templateParser(comment_template); |
186 var tplvars = new Object(); |
186 var tplvars = new Object(); |
187 |
187 |
188 if ( this_comment.approved != '1' && !data.auth_mod_comments ) |
188 if ( this_comment.approved != '1' && !data.auth_mod_comments ) |
189 return ''; |
189 return ''; |
190 |
190 |
191 tplvars.ID = i; |
191 tplvars.ID = i; |
192 tplvars.DATETIME = this_comment.time; |
192 tplvars.DATETIME = this_comment.time; |
193 tplvars.SUBJECT = this_comment.subject; |
193 tplvars.SUBJECT = this_comment.subject; |
194 tplvars.DATA = this_comment.comment_data; |
194 tplvars.DATA = this_comment.comment_data; |
195 tplvars.SIGNATURE = this_comment.signature; |
195 tplvars.SIGNATURE = this_comment.signature; |
196 |
196 |
197 if ( this_comment.approved == '0' ) |
197 if ( this_comment.approved == '0' ) |
198 tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>'; |
198 tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>'; |
199 else if ( this_comment.approved == '2' ) |
199 else if ( this_comment.approved == '2' ) |
200 tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_spam') + '</span>'; |
200 tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_spam') + '</span>'; |
201 |
201 |
202 // Name |
202 // Name |
203 tplvars.NAME = this_comment.name; |
203 tplvars.NAME = this_comment.name; |
204 if ( this_comment.user_id > 1 ) |
204 if ( this_comment.user_id > 1 ) |
205 tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '" style="' + this_comment.rank_style + '">' + this_comment.name + '</a>'; |
205 tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '" style="' + this_comment.rank_style + '">' + this_comment.name + '</a>'; |
206 |
206 |
207 // Avatar |
207 // Avatar |
208 if ( this_comment.user_has_avatar == '1' ) |
208 if ( this_comment.user_has_avatar == '1' ) |
209 { |
209 { |
210 tplvars.AVATAR_URL = this_comment.avatar_path; |
210 tplvars.AVATAR_URL = this_comment.avatar_path; |
211 tplvars.USERPAGE_LINK = makeUrlNS('User', this_comment.name); |
211 tplvars.USERPAGE_LINK = makeUrlNS('User', this_comment.name); |
212 tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: this_comment.name }); |
212 tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: this_comment.name }); |
213 } |
213 } |
214 |
214 |
215 // User level |
215 // User level |
216 tplvars.USER_LEVEL = ''; |
216 tplvars.USER_LEVEL = ''; |
217 if ( this_comment.user_title ) |
217 if ( this_comment.user_title ) |
218 tplvars.USER_LEVEL += this_comment.user_title; |
218 tplvars.USER_LEVEL += this_comment.user_title; |
219 if ( this_comment.rank_title && this_comment.user_title ) |
219 if ( this_comment.rank_title && this_comment.user_title ) |
220 tplvars.USER_LEVEL += '<br />'; |
220 tplvars.USER_LEVEL += '<br />'; |
221 if ( this_comment.rank_title ) |
221 if ( this_comment.rank_title ) |
222 tplvars.USER_LEVEL += $lang.get(this_comment.rank_title); |
222 tplvars.USER_LEVEL += $lang.get(this_comment.rank_title); |
223 |
223 |
224 // Send PM link |
224 // Send PM link |
225 tplvars.SEND_PM_LINK=(this_comment.user_id>1)?'<a class="abutton icon abutton_blue" style="background-image: url(' + cdnPath + '/images/icons/send_pm.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br /><br />':''; |
225 tplvars.SEND_PM_LINK=(this_comment.user_id>1)?'<a class="abutton icon abutton_blue" style="background-image: url(' + cdnPath + '/images/icons/send_pm.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br /><br />':''; |
226 |
226 |
227 // Add buddy link |
227 // Add buddy link |
228 tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1)?'<a class="abutton icon abutton_green" style="background-image: url(' + cdnPath + '/images/icons/add_buddy.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':''; |
228 tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1)?'<a class="abutton icon abutton_green" style="background-image: url(' + cdnPath + '/images/icons/add_buddy.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':''; |
229 |
229 |
230 // Edit link |
230 // Edit link |
231 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
231 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
232 |
232 |
233 // Delete link |
233 // Delete link |
234 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
234 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
235 |
235 |
236 // Moderation: (Un)approve link |
236 // Moderation: (Un)approve link |
237 var appr = ( this_comment.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
237 var appr = ( this_comment.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
238 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
238 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
239 |
239 |
240 // Moderation: Delete post link |
240 // Moderation: Delete post link |
241 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
241 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
242 |
242 |
243 // Moderation: IP address link |
243 // Moderation: IP address link |
244 if ( this_comment.have_ip ) |
244 if ( this_comment.have_ip ) |
245 { |
245 { |
246 tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + this_comment.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>'; |
246 tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + this_comment.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>'; |
247 } |
247 } |
248 else |
248 else |
249 { |
249 { |
250 tplvars.MOD_IP_LINK = $lang.get('comment_btn_mod_ip_missing'); |
250 tplvars.MOD_IP_LINK = $lang.get('comment_btn_mod_ip_missing'); |
251 } |
251 } |
252 |
252 |
253 var tplbool = new Object(); |
253 var tplbool = new Object(); |
254 |
254 |
255 tplbool.signature = ( this_comment.signature == '' ) ? false : true; |
255 tplbool.signature = ( this_comment.signature == '' ) ? false : true; |
256 tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
256 tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
257 tplbool.auth_mod = data.auth_mod_comments; |
257 tplbool.auth_mod = data.auth_mod_comments; |
258 tplbool.is_friend = ( this_comment.is_buddy == 1 && this_comment.is_friend == 1 ); |
258 tplbool.is_friend = ( this_comment.is_buddy == 1 && this_comment.is_friend == 1 ); |
259 tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 ); |
259 tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 ); |
260 tplbool.user_has_avatar = ( this_comment.user_has_avatar == '1' ); |
260 tplbool.user_has_avatar = ( this_comment.user_has_avatar == '1' ); |
261 |
261 |
262 if ( tplbool.is_friend ) |
262 if ( tplbool.is_friend ) |
263 tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_friend_list') + '</b>'; |
263 tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_friend_list') + '</b>'; |
264 else if ( tplbool.is_foe ) |
264 else if ( tplbool.is_foe ) |
265 tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_foe_list') + '</b>'; |
265 tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_foe_list') + '</b>'; |
266 |
266 |
267 parser.assign_vars(tplvars); |
267 parser.assign_vars(tplvars); |
268 parser.assign_bool(tplbool); |
268 parser.assign_bool(tplbool); |
269 |
269 |
270 var ret = '<div id="comment_holder_' + i + '">'; |
270 var ret = '<div id="comment_holder_' + i + '">'; |
271 ret += '<input type="hidden" value="'+this_comment.comment_id+'" />'; |
271 ret += '<input type="hidden" value="'+this_comment.comment_id+'" />'; |
272 ret += '<input type="hidden" id="comment_source_'+i+'" />'; |
272 ret += '<input type="hidden" id="comment_source_'+i+'" />'; |
273 ret += parser.run(); |
273 ret += parser.run(); |
274 ret += '</div>'; |
274 ret += '</div>'; |
275 return ret; |
275 return ret; |
276 } |
276 } |
277 |
277 |
278 window.displayCommentForm = function() |
278 window.displayCommentForm = function() |
279 { |
279 { |
280 document.getElementById('leave_comment_button').style.display = 'none'; |
280 document.getElementById('leave_comment_button').style.display = 'none'; |
281 document.getElementById('comment_form').style.display = 'block'; |
281 document.getElementById('comment_form').style.display = 'block'; |
282 if ( $dynano('commentform_message').object.allow_wysiwyg ) |
282 if ( $dynano('commentform_message').object.allow_wysiwyg ) |
283 $dynano('commentform_message').makeSwitchable(); |
283 $dynano('commentform_message').makeSwitchable(); |
284 } |
284 } |
285 |
285 |
286 window.hideCommentForm = function() |
286 window.hideCommentForm = function() |
287 { |
287 { |
288 document.getElementById('leave_comment_button').style.display = 'inline'; |
288 document.getElementById('leave_comment_button').style.display = 'inline'; |
289 document.getElementById('comment_form').style.display = 'none'; |
289 document.getElementById('comment_form').style.display = 'none'; |
290 } |
290 } |
291 |
291 |
292 window.editComment = function(id, link) |
292 window.editComment = function(id, link) |
293 { |
293 { |
294 var ctr = document.getElementById('subject_'+id); |
294 var ctr = document.getElementById('subject_'+id); |
295 var subj = ( ctr.firstChild ) ? trim(ctr.firstChild.nodeValue) : ''; // If there's a span in there that says 'unapproved', this eliminates it |
295 var subj = ( ctr.firstChild ) ? trim(ctr.firstChild.nodeValue) : ''; // If there's a span in there that says 'unapproved', this eliminates it |
296 ctr.innerHTML = ''; |
296 ctr.innerHTML = ''; |
297 var ipt = document.createElement('input'); |
297 var ipt = document.createElement('input'); |
298 ipt.id = 'subject_edit_'+id; |
298 ipt.id = 'subject_edit_'+id; |
299 ipt.value = subj; |
299 ipt.value = subj; |
300 ctr.appendChild(ipt); |
300 ctr.appendChild(ipt); |
301 |
301 |
302 var src = document.getElementById('comment_source_'+id).value; |
302 var src = document.getElementById('comment_source_'+id).value; |
303 var cmt = document.getElementById('comment_'+id); |
303 var cmt = document.getElementById('comment_'+id); |
304 cmt.innerHTML = ''; |
304 cmt.innerHTML = ''; |
305 var ta = document.createElement('textarea'); |
305 var ta = document.createElement('textarea'); |
306 ta.rows = '10'; |
306 ta.rows = '10'; |
307 ta.cols = '40'; |
307 ta.cols = '40'; |
308 ta.style.width = '98%'; |
308 ta.style.width = '98%'; |
309 ta.value = src; |
309 ta.value = src; |
310 ta.id = 'comment_edit_'+id; |
310 ta.id = 'comment_edit_'+id; |
311 cmt.appendChild(ta); |
311 cmt.appendChild(ta); |
312 $dynano(ta).makeSwitchable(); |
312 $dynano(ta).makeSwitchable(); |
313 |
313 |
314 link.style.fontWeight = 'bold'; |
314 link.style.fontWeight = 'bold'; |
315 link.innerHTML = $lang.get('comment_btn_save'); |
315 link.innerHTML = $lang.get('comment_btn_save'); |
316 link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; }; |
316 link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; }; |
317 } |
317 } |
318 |
318 |
319 window.saveComment = function(id, link) |
319 window.saveComment = function(id, link) |
320 { |
320 { |
321 var data = document.getElementById('comment_edit_'+id).value; |
321 var data = document.getElementById('comment_edit_'+id).value; |
322 var subj = document.getElementById('subject_edit_'+id).value; |
322 var subj = document.getElementById('subject_edit_'+id).value; |
323 var div = document.getElementById('comment_holder_'+id); |
323 var div = document.getElementById('comment_holder_'+id); |
324 var real_id = div.getElementsByTagName('input')[0]['value']; |
324 var real_id = div.getElementsByTagName('input')[0]['value']; |
325 var req = { |
325 var req = { |
326 'mode' : 'edit', |
326 'mode' : 'edit', |
327 'id' : real_id, |
327 'id' : real_id, |
328 'local_id' : id, |
328 'local_id' : id, |
329 'data' : data, |
329 'data' : data, |
330 'subj' : subj |
330 'subj' : subj |
331 }; |
331 }; |
332 link.style.fontWeight = 'normal'; |
332 link.style.fontWeight = 'normal'; |
333 link.innerHTML = $lang.get('comment_btn_edit'); |
333 link.innerHTML = $lang.get('comment_btn_edit'); |
334 link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); editComment(id, this); return false; }; |
334 link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); editComment(id, this); return false; }; |
335 ajaxComments(req); |
335 ajaxComments(req); |
336 } |
336 } |
337 |
337 |
338 window.deleteComment = function(id) |
338 window.deleteComment = function(id) |
339 { |
339 { |
340 if ( !shift ) |
340 if ( !shift ) |
341 { |
341 { |
342 var c = confirm($lang.get('comment_msg_delete_confirm')); |
342 var c = confirm($lang.get('comment_msg_delete_confirm')); |
343 if(!c) |
343 if(!c) |
344 return false; |
344 return false; |
345 } |
345 } |
346 var div = document.getElementById('comment_holder_'+id); |
346 var div = document.getElementById('comment_holder_'+id); |
347 var real_id = div.getElementsByTagName('input')[0]['value']; |
347 var real_id = div.getElementsByTagName('input')[0]['value']; |
348 var req = { |
348 var req = { |
349 'mode' : 'delete', |
349 'mode' : 'delete', |
350 'id' : real_id, |
350 'id' : real_id, |
351 'local_id' : id |
351 'local_id' : id |
352 }; |
352 }; |
353 ajaxComments(req); |
353 ajaxComments(req); |
354 } |
354 } |
355 |
355 |
356 window.submitComment = function() |
356 window.submitComment = function() |
357 { |
357 { |
358 var name = document.getElementById('commentform_name').value; |
358 var name = document.getElementById('commentform_name').value; |
359 var subj = document.getElementById('commentform_subject').value; |
359 var subj = document.getElementById('commentform_subject').value; |
360 var text = $dynano('commentform_message').getContent(); |
360 var text = $dynano('commentform_message').getContent(); |
361 if ( document.getElementById('commentform_captcha') ) |
361 if ( document.getElementById('commentform_captcha') ) |
362 { |
362 { |
363 var captcha_code = document.getElementById('commentform_captcha').value; |
363 var captcha_code = document.getElementById('commentform_captcha').value; |
364 var captcha_id = document.getElementById('commentform_captcha_id').value; |
364 var captcha_id = document.getElementById('commentform_captcha_id').value; |
365 } |
365 } |
366 else |
366 else |
367 { |
367 { |
368 var captcha_code = ''; |
368 var captcha_code = ''; |
369 var captcha_id = ''; |
369 var captcha_id = ''; |
370 } |
370 } |
371 if ( subj == '' ) |
371 if ( subj == '' ) |
372 { |
372 { |
373 load_component(['messagebox', 'fadefilter']); |
373 load_component(['messagebox', 'fadefilter']); |
374 new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.'); |
374 new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.'); |
375 return false; |
375 return false; |
376 } |
376 } |
377 if ( text == '' ) |
377 if ( text == '' ) |
378 { |
378 { |
379 load_component(['messagebox', 'fadefilter']); |
379 load_component(['messagebox', 'fadefilter']); |
380 new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .'); |
380 new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .'); |
381 return false; |
381 return false; |
382 } |
382 } |
383 var req = { |
383 var req = { |
384 'mode' : 'submit', |
384 'mode' : 'submit', |
385 'name' : name, |
385 'name' : name, |
386 'subj' : subj, |
386 'subj' : subj, |
387 'text' : text, |
387 'text' : text, |
388 'captcha_code' : captcha_code, |
388 'captcha_code' : captcha_code, |
389 'captcha_id' : captcha_id |
389 'captcha_id' : captcha_id |
390 }; |
390 }; |
391 ajaxComments(req); |
391 ajaxComments(req); |
392 } |
392 } |
393 |
393 |
394 window.redrawComment = function(data) |
394 window.redrawComment = function(data) |
395 { |
395 { |
396 if ( data.subj ) |
396 if ( data.subj ) |
397 { |
397 { |
398 document.getElementById('subject_' + data.id).innerHTML = data.subj; |
398 document.getElementById('subject_' + data.id).innerHTML = data.subj; |
399 } |
399 } |
400 if ( data.approved && data.approved != '1' ) |
400 if ( data.approved && data.approved != '1' ) |
401 { |
401 { |
402 document.getElementById('subject_' + data.id).innerHTML += ' <span style="color: #D84308">' + ( data.approved == '2' ? $lang.get('comment_msg_note_spam') : $lang.get('comment_msg_note_unapp') ) + '</span>'; |
402 document.getElementById('subject_' + data.id).innerHTML += ' <span style="color: #D84308">' + ( data.approved == '2' ? $lang.get('comment_msg_note_spam') : $lang.get('comment_msg_note_unapp') ) + '</span>'; |
403 } |
403 } |
404 if ( data.approved && ( typeof(data.approve_updated) == 'string' && data.approve_updated == 'yes' ) ) |
404 if ( data.approved && ( typeof(data.approve_updated) == 'string' && data.approve_updated == 'yes' ) ) |
405 { |
405 { |
406 var appr = ( data.approved == '1' ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
406 var appr = ( data.approved == '1' ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
407 document.getElementById('comment_approve_'+data.id).innerHTML = appr; |
407 document.getElementById('comment_approve_'+data.id).innerHTML = appr; |
408 |
408 |
409 if ( data.approved == '1' ) |
409 if ( data.approved == '1' ) |
410 comment_decrement_unapproval(); |
410 comment_decrement_unapproval(); |
411 else |
411 else |
412 comment_increment_unapproval(); |
412 comment_increment_unapproval(); |
413 } |
413 } |
414 if ( data.text ) |
414 if ( data.text ) |
415 { |
415 { |
416 document.getElementById('comment_' + data.id).innerHTML = data.text; |
416 document.getElementById('comment_' + data.id).innerHTML = data.text; |
417 } |
417 } |
418 if ( data.src ) |
418 if ( data.src ) |
419 { |
419 { |
420 document.getElementById('comment_source_' + data.id).value = data.src; |
420 document.getElementById('comment_source_' + data.id).value = data.src; |
421 } |
421 } |
422 if ( data.ip_addr ) |
422 if ( data.ip_addr ) |
423 { |
423 { |
424 var span = $dynano('comment_ip_' + data.local_id).object; |
424 var span = $dynano('comment_ip_' + data.local_id).object; |
425 if ( !span ) |
425 if ( !span ) |
426 return false; |
426 return false; |
427 span.innerHTML = $lang.get('comment_msg_ip_address') + ' <a href="#rdns" onclick="ajaxReverseDNS(this); return false;">' + data.ip_addr + '</a>'; |
427 span.innerHTML = $lang.get('comment_msg_ip_address') + ' <a href="#rdns" onclick="ajaxReverseDNS(this); return false;">' + data.ip_addr + '</a>'; |
428 } |
428 } |
429 } |
429 } |
430 |
430 |
431 window.approveComment = function(id) |
431 window.approveComment = function(id) |
432 { |
432 { |
433 var div = document.getElementById('comment_holder_'+id); |
433 var div = document.getElementById('comment_holder_'+id); |
434 var real_id = div.getElementsByTagName('input')[0]['value']; |
434 var real_id = div.getElementsByTagName('input')[0]['value']; |
435 var req = { |
435 var req = { |
436 'mode' : 'approve', |
436 'mode' : 'approve', |
437 'id' : real_id, |
437 'id' : real_id, |
438 'local_id' : id |
438 'local_id' : id |
439 }; |
439 }; |
440 ajaxComments(req); |
440 ajaxComments(req); |
441 } |
441 } |
442 |
442 |
443 // Does the actual DOM object removal |
443 // Does the actual DOM object removal |
444 window.annihiliateComment = function(id) // Did I spell that right? |
444 window.annihiliateComment = function(id) // Did I spell that right? |
445 { |
445 { |
446 var approved = true; |
446 var approved = true; |
447 if(document.getElementById('comment_approve_'+id)) |
447 if(document.getElementById('comment_approve_'+id)) |
448 { |
448 { |
449 var appr = document.getElementById('comment_approve_'+id).firstChild.nodeValue; |
449 var appr = document.getElementById('comment_approve_'+id).firstChild.nodeValue; |
450 if ( appr == $lang.get('comment_btn_mod_approve') ) |
450 if ( appr == $lang.get('comment_btn_mod_approve') ) |
451 { |
451 { |
452 approved = false; |
452 approved = false; |
453 } |
453 } |
454 } |
454 } |
455 |
455 |
456 var div = document.getElementById('comment_holder_'+id); |
456 var div = document.getElementById('comment_holder_'+id); |
457 div.parentNode.removeChild(div); |
457 div.parentNode.removeChild(div); |
458 |
458 |
459 // update approval status |
459 // update approval status |
460 if ( document.getElementById('comment_count_unapp_inner') && !approved ) |
460 if ( document.getElementById('comment_count_unapp_inner') && !approved ) |
461 { |
461 { |
462 comment_decrement_unapproval(); |
462 comment_decrement_unapproval(); |
463 } |
463 } |
464 } |
464 } |
465 |
465 |
466 window.materializeComment = function(data) |
466 window.materializeComment = function(data) |
467 { |
467 { |
468 // Intelligently get an ID |
468 // Intelligently get an ID |
469 |
469 |
470 var i = 0; |
470 var i = 0; |
471 var brother; |
471 var brother; |
472 while ( true ) |
472 while ( true ) |
473 { |
473 { |
474 var x = document.getElementById('comment_holder_'+i); |
474 var x = document.getElementById('comment_holder_'+i); |
475 if(!x) |
475 if(!x) |
476 break; |
476 break; |
477 brother = x; |
477 brother = x; |
478 i++; |
478 i++; |
479 } |
479 } |
480 |
480 |
481 var parser = new templateParser(comment_template); |
481 var parser = new templateParser(comment_template); |
482 var tplvars = new Object(); |
482 var tplvars = new Object(); |
483 |
483 |
484 if ( data.approved != '1' && !data.auth_mod_comments ) |
484 if ( data.approved != '1' && !data.auth_mod_comments ) |
485 return false; |
485 return false; |
486 |
486 |
487 tplvars.ID = i; |
487 tplvars.ID = i; |
488 tplvars.DATETIME = data.time; |
488 tplvars.DATETIME = data.time; |
489 tplvars.SUBJECT = data.subject; |
489 tplvars.SUBJECT = data.subject; |
490 tplvars.DATA = data.comment_data; |
490 tplvars.DATA = data.comment_data; |
491 tplvars.SIGNATURE = data.signature; |
491 tplvars.SIGNATURE = data.signature; |
492 |
492 |
493 tplvars.NAME = data.name; |
493 tplvars.NAME = data.name; |
494 if ( data.user_id > 1 ) |
494 if ( data.user_id > 1 ) |
495 tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '">' + data.name + '</a>'; |
495 tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '">' + data.name + '</a>'; |
496 |
496 |
497 if ( data.approved != '1' ) |
497 if ( data.approved != '1' ) |
498 tplvars.SUBJECT += ' <span style="color: #D84308">' + ( data.approved == '2' ? $lang.get('comment_msg_note_spam') : $lang.get('comment_msg_note_unapp') ) + '</span>'; |
498 tplvars.SUBJECT += ' <span style="color: #D84308">' + ( data.approved == '2' ? $lang.get('comment_msg_note_spam') : $lang.get('comment_msg_note_unapp') ) + '</span>'; |
499 |
499 |
500 // Name |
500 // Name |
501 tplvars.NAME = data.name; |
501 tplvars.NAME = data.name; |
502 if ( data.user_id > 1 ) |
502 if ( data.user_id > 1 ) |
503 tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '" style="' + data.rank_data.rank_style + '">' + data.name + '</a>'; |
503 tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '" style="' + data.rank_data.rank_style + '">' + data.name + '</a>'; |
504 |
504 |
505 // Avatar |
505 // Avatar |
506 if ( data.user_has_avatar == '1' ) |
506 if ( data.user_has_avatar == '1' ) |
507 { |
507 { |
508 tplvars.AVATAR_URL = data.avatar_path; |
508 tplvars.AVATAR_URL = data.avatar_path; |
509 tplvars.USERPAGE_LINK = makeUrlNS('User', data.name); |
509 tplvars.USERPAGE_LINK = makeUrlNS('User', data.name); |
510 tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: data.name }); |
510 tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: data.name }); |
511 } |
511 } |
512 |
512 |
513 // User level |
513 // User level |
514 tplvars.USER_LEVEL = ''; |
514 tplvars.USER_LEVEL = ''; |
515 if ( data.rank_data.user_title ) |
515 if ( data.rank_data.user_title ) |
516 tplvars.USER_LEVEL += data.rank_data.user_title; |
516 tplvars.USER_LEVEL += data.rank_data.user_title; |
517 if ( data.rank_data.rank_title && data.rank_data.user_title ) |
517 if ( data.rank_data.rank_title && data.rank_data.user_title ) |
518 tplvars.USER_LEVEL += '<br />'; |
518 tplvars.USER_LEVEL += '<br />'; |
519 if ( data.rank_data.rank_title ) |
519 if ( data.rank_data.rank_title ) |
520 tplvars.USER_LEVEL += $lang.get(data.rank_data.rank_title); |
520 tplvars.USER_LEVEL += $lang.get(data.rank_data.rank_title); |
521 |
521 |
522 // Send PM link |
522 // Send PM link |
523 tplvars.SEND_PM_LINK=(data.user_id>1)?'<a class="abutton icon abutton_blue" style="background-image: url(' + cdnPath + '/images/icons/send_pm.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br /><br />':''; |
523 tplvars.SEND_PM_LINK=(data.user_id>1)?'<a class="abutton icon abutton_blue" style="background-image: url(' + cdnPath + '/images/icons/send_pm.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br /><br />':''; |
524 |
524 |
525 // Add buddy link |
525 // Add buddy link |
526 tplvars.ADD_BUDDY_LINK=(data.user_id>1)?'<a class="abutton icon abutton_green" style="background-image: url(' + cdnPath + '/images/icons/add_buddy.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':''; |
526 tplvars.ADD_BUDDY_LINK=(data.user_id>1)?'<a class="abutton icon abutton_green" style="background-image: url(' + cdnPath + '/images/icons/add_buddy.png);" onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':''; |
527 |
527 |
528 // Edit link |
528 // Edit link |
529 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
529 tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
530 |
530 |
531 // Delete link |
531 // Delete link |
532 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
532 tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
533 |
533 |
534 // Moderation: (Un)approve link |
534 // Moderation: (Un)approve link |
535 var appr = ( data.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
535 var appr = ( data.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
536 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
536 tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
537 |
537 |
538 // Moderation: Delete post link |
538 // Moderation: Delete post link |
539 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
539 tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
540 |
540 |
541 // Moderation: IP address link |
541 // Moderation: IP address link |
542 tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + data.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>'; |
542 tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + data.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>'; |
543 |
543 |
544 var tplbool = new Object(); |
544 var tplbool = new Object(); |
545 |
545 |
546 tplbool.signature = ( data.signature == '' ) ? false : true; |
546 tplbool.signature = ( data.signature == '' ) ? false : true; |
547 tplbool.can_edit = ( data.auth_edit_comments && ( ( data.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
547 tplbool.can_edit = ( data.auth_edit_comments && ( ( data.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
548 tplbool.auth_mod = data.auth_mod_comments; |
548 tplbool.auth_mod = data.auth_mod_comments; |
549 tplbool.user_has_avatar = ( data.user_has_avatar == '1' ); |
549 tplbool.user_has_avatar = ( data.user_has_avatar == '1' ); |
550 |
550 |
551 parser.assign_vars(tplvars); |
551 parser.assign_vars(tplvars); |
552 parser.assign_bool(tplbool); |
552 parser.assign_bool(tplbool); |
553 |
553 |
554 var div = document.createElement('div'); |
554 var div = document.createElement('div'); |
555 div.id = 'comment_holder_'+i; |
555 div.id = 'comment_holder_'+i; |
556 |
556 |
557 div.innerHTML = '<input type="hidden" value="'+data.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run(); |
557 div.innerHTML = '<input type="hidden" value="'+data.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run(); |
558 |
558 |
559 if ( brother ) |
559 if ( brother ) |
560 { |
560 { |
561 brother.parentNode.insertBefore(div, brother.nextSibling); |
561 brother.parentNode.insertBefore(div, brother.nextSibling); |
562 } |
562 } |
563 else |
563 else |
564 { |
564 { |
565 // No comments in ajaxEditContainer, insert it after the header |
565 // No comments in ajaxEditContainer, insert it after the header |
566 var aec = document.getElementById("ajaxEditContainer"); |
566 var aec = document.getElementById("ajaxEditContainer"); |
567 aec.insertBefore(div, aec.firstChild.nextSibling.nextSibling); |
567 aec.insertBefore(div, aec.firstChild.nextSibling.nextSibling); |
568 } |
568 } |
569 |
569 |
570 document.getElementById('comment_source_'+i).value = data.comment_source; |
570 document.getElementById('comment_source_'+i).value = data.comment_source; |
571 |
571 |
572 var cnt = document.getElementById('comment_count_inner').innerHTML; |
572 var cnt = document.getElementById('comment_count_inner').innerHTML; |
573 cnt = parseInt(cnt); |
573 cnt = parseInt(cnt); |
574 if ( isNaN(cnt) ) |
574 if ( isNaN(cnt) ) |
575 cnt = 0; |
575 cnt = 0; |
576 |
576 |
577 var subst = { |
577 var subst = { |
578 num_comments: cnt, |
578 num_comments: cnt, |
579 page_type: ENANO_PAGE_TYPE |
579 page_type: ENANO_PAGE_TYPE |
580 } |
580 } |
581 |
581 |
582 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
582 var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) ); |
583 |
583 |
584 document.getElementById('comment_status').firstChild.innerHTML = count_msg; |
584 document.getElementById('comment_status').firstChild.innerHTML = count_msg; |
585 |
585 |
586 if(document.getElementById('comment_approve_'+i)) |
586 if(document.getElementById('comment_approve_'+i)) |
587 { |
587 { |
588 var is_unappr = document.getElementById('comment_approve_'+i).firstChild.nodeValue; |
588 var is_unappr = document.getElementById('comment_approve_'+i).firstChild.nodeValue; |
589 is_unappr = ( is_unappr == $lang.get('comment_btn_mod_approve') ); |
589 is_unappr = ( is_unappr == $lang.get('comment_btn_mod_approve') ); |
590 if ( is_unappr ) |
590 if ( is_unappr ) |
591 { |
591 { |
592 comment_increment_unapproval(); |
592 comment_increment_unapproval(); |
593 } |
593 } |
594 } |
594 } |
595 |
595 |
596 } |
596 } |
597 |
597 |
598 window.comment_decrement_unapproval = function() |
598 window.comment_decrement_unapproval = function() |
599 { |
599 { |
600 if ( document.getElementById('comment_count_unapp_inner') ) |
600 if ( document.getElementById('comment_count_unapp_inner') ) |
601 { |
601 { |
602 var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
602 var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
603 if ( !isNaN(num_unapp) ) |
603 if ( !isNaN(num_unapp) ) |
604 { |
604 { |
605 num_unapp = num_unapp - 1; |
605 num_unapp = num_unapp - 1; |
606 if ( num_unapp == 0 ) |
606 if ( num_unapp == 0 ) |
607 { |
607 { |
608 var p = document.getElementById('comment_status'); |
608 var p = document.getElementById('comment_status'); |
609 p.removeChild(p.childNodes[2]); |
609 p.removeChild(p.childNodes[2]); |
610 p.removeChild(p.childNodes[1]); |
610 p.removeChild(p.childNodes[1]); |
611 } |
611 } |
612 else |
612 else |
613 { |
613 { |
614 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
614 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
615 document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
615 document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
616 } |
616 } |
617 } |
617 } |
618 } |
618 } |
619 } |
619 } |
620 |
620 |
621 window.comment_increment_unapproval = function() |
621 window.comment_increment_unapproval = function() |
622 { |
622 { |
623 if ( document.getElementById('comment_count_unapp_inner') ) |
623 if ( document.getElementById('comment_count_unapp_inner') ) |
624 { |
624 { |
625 var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
625 var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
626 if ( isNaN(num_unapp) ) |
626 if ( isNaN(num_unapp) ) |
627 num_unapp = 0; |
627 num_unapp = 0; |
628 num_unapp = num_unapp + 1; |
628 num_unapp = num_unapp + 1; |
629 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
629 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
630 document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
630 document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
631 } |
631 } |
632 else |
632 else |
633 { |
633 { |
634 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: 1 }); |
634 var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: 1 }); |
635 var status = document.getElementById('comment_status'); |
635 var status = document.getElementById('comment_status'); |
636 if ( !status.childNodes[1] ) |
636 if ( !status.childNodes[1] ) |
637 status.appendChild(document.createTextNode(' ')); |
637 status.appendChild(document.createTextNode(' ')); |
638 var span = document.createElement('span'); |
638 var span = document.createElement('span'); |
639 span.id = 'comment_status_unapp'; |
639 span.id = 'comment_status_unapp'; |
640 span.style.color = '#D84308'; |
640 span.style.color = '#D84308'; |
641 span.innerHTML = count_msg; |
641 span.innerHTML = count_msg; |
642 status.appendChild(span); |
642 status.appendChild(span); |
643 } |
643 } |
644 } |
644 } |
645 |
645 |
646 window._comment_page_flip = function(paginator, page_number) |
646 window._comment_page_flip = function(paginator, page_number) |
647 { |
647 { |
648 // get ID |
648 // get ID |
649 var random_id = paginator.random_id; |
649 var random_id = paginator.random_id; |
650 // update paginate control |
650 // update paginate control |
651 paginator.set_page(page_number); |
651 paginator.set_page(page_number); |
652 $('.' + random_id + '_control').html(paginator._build_control(page_number)); |
652 $('.' + random_id + '_control').html(paginator._build_control(page_number)); |
653 paginator.offset = page_number; |
653 paginator.offset = page_number; |
654 // set to loading state |
654 // set to loading state |
655 $('#' + random_id + '_0') |
655 $('#' + random_id + '_0') |
656 .css('height', 500) |
656 .css('height', 500) |
657 .html('') |
657 .html('') |
658 .fadeTo("fast", 0.7) |
658 .fadeTo("fast", 0.7) |
659 .css('background-position', 'center 51px') |
659 .css('background-position', 'center 51px') |
660 .css('background-repeat', 'no-repeat') |
660 .css('background-repeat', 'no-repeat') |
661 .css('background-color', 'white') |
661 .css('background-color', 'white') |
662 .css('background-image', 'url(' + cdnPath + '/images/loading-big.gif' + ')') |
662 .css('background-image', 'url(' + cdnPath + '/images/loading-big.gif' + ')') |
663 .animate({ height: 150 }, 500, function() |
663 .animate({ height: 150 }, 500, function() |
664 { |
664 { |
665 // load the new comments |
665 // load the new comments |
666 ajaxComments({ |
666 ajaxComments({ |
667 mode: 'fetch', |
667 mode: 'fetch', |
668 pagenum: page_number, |
668 pagenum: page_number, |
669 passback: { |
669 passback: { |
670 paginator_id: random_id |
670 paginator_id: random_id |
671 } |
671 } |
672 }); |
672 }); |
673 }); |
673 }); |
674 } |
674 } |
675 |
675 |
676 window.viewCommentIP = function(id, local_id) |
676 window.viewCommentIP = function(id, local_id) |
677 { |
677 { |
678 // set "loading" indicator on IP button |
678 // set "loading" indicator on IP button |
679 var span = $dynano('comment_ip_' + local_id).object; |
679 var span = $dynano('comment_ip_' + local_id).object; |
680 if ( !span ) |
680 if ( !span ) |
681 return false; |
681 return false; |
682 span.innerHTML = '<img alt="..." src="' + ajax_load_icon + '" />'; |
682 span.innerHTML = '<img alt="..." src="' + ajax_load_icon + '" />'; |
683 |
683 |
684 var parms = { |
684 var parms = { |
685 mode: 'view_ip', |
685 mode: 'view_ip', |
686 id: id, |
686 id: id, |
687 local_id: local_id |
687 local_id: local_id |
688 } |
688 } |
689 ajaxComments(parms); |
689 ajaxComments(parms); |
690 } |
690 } |
691 |
691 |