author | Dan |
Mon, 21 Jan 2008 18:33:44 -0500 | |
changeset 365 | cc6bf4d63684 |
parent 359 | e0787bb6285b |
child 407 | 35d94240a197 |
permissions | -rw-r--r-- |
1 | 1 |
// Comments |
2 |
||
3 |
var comment_template = false; |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
4 |
var comment_render_track = 0; |
1 | 5 |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
6 |
function ajaxComments(parms) |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
7 |
{ |
1 | 8 |
setAjaxLoading(); |
9 |
var pid = strToPageID(title); |
|
10 |
if(!parms) |
|
11 |
{ |
|
12 |
var parms = { |
|
13 |
'mode' : 'fetch' |
|
14 |
}; |
|
15 |
} |
|
16 |
parms.page_id = pid[0]; |
|
17 |
parms.namespace = pid[1]; |
|
18 |
if(comment_template) |
|
19 |
parms.have_template = true; |
|
20 |
parms = ajaxEscape(toJSONString(parms)); |
|
21 |
ajaxPost(stdAjaxPrefix+'&_mode=comments', 'data=' + parms, function() { |
|
22 |
if(ajax.readyState == 4) { |
|
23 |
unsetAjaxLoading(); |
|
24 |
selectButtonMajor('discussion'); |
|
25 |
unselectAllButtonsMinor(); |
|
26 |
// IE compatibility - doing ajax.responseText.substr() doesn't work |
|
27 |
var rsptxt = ajax.responseText + ''; |
|
28 |
if ( rsptxt.substr(0, 1) != '{' ) |
|
29 |
{ |
|
30 |
document.getElementById('ajaxEditContainer').innerHTML = '<p>Comment system Javascript runtime: invalid JSON response from server, response text:</p><pre>' + ajax.responseText + '</pre>'; |
|
31 |
return false; |
|
32 |
} |
|
33 |
var response = parseJSON(ajax.responseText); |
|
34 |
switch(response.mode) |
|
35 |
{ |
|
36 |
case 'fetch': |
|
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
37 |
document.getElementById('ajaxEditContainer').innerHTML = '<div class="wait-box">Rendering '+response.count_total+' comments...</div>'; |
1 | 38 |
if(response.template) |
39 |
comment_template = response.template; |
|
40 |
setAjaxLoading(); |
|
41 |
renderComments(response); |
|
42 |
unsetAjaxLoading(); |
|
43 |
break; |
|
44 |
case 'redraw': |
|
45 |
redrawComment(response); |
|
46 |
break; |
|
47 |
case 'annihilate': |
|
48 |
annihiliateComment(response.id); |
|
49 |
break; |
|
50 |
case 'materialize': |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
51 |
alert($lang.get('comment_msg_comment_posted')); |
1 | 52 |
hideCommentForm(); |
53 |
materializeComment(response); |
|
54 |
break; |
|
55 |
case 'error': |
|
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
56 |
new messagebox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : 'Error fetching comment data' ), response.error); |
1 | 57 |
break; |
58 |
default: |
|
59 |
alert(ajax.responseText); |
|
60 |
break; |
|
61 |
} |
|
62 |
} |
|
63 |
}); |
|
64 |
} |
|
65 |
||
66 |
function renderComments(data) |
|
67 |
{ |
|
68 |
||
69 |
var html = ''; |
|
70 |
||
71 |
// Header |
|
72 |
||
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
73 |
html += '<h3>' + $lang.get('comment_heading') + '</h3>'; |
1 | 74 |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
75 |
var ns = ENANO_PAGE_TYPE; |
1 | 76 |
|
77 |
// Counters |
|
78 |
if ( data.auth_mod_comments ) |
|
79 |
{ |
|
80 |
var cnt = ( data.auth_mod_comments ) ? data.count_total : data.count_appr; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
81 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
82 |
var subst = { |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
83 |
num_comments: cnt, |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
84 |
page_type: ns |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
85 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
86 |
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) ); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
87 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
88 |
html += "<p id=\"comment_status\"><span>" + count_msg + '</span>'; |
1 | 89 |
if ( data.count_unappr > 0 ) |
90 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
91 |
html += ' <span style="color: #D84308" id="comment_status_unapp">' + $lang.get('comment_msg_count_unapp_mod', { num_unapp: data.count_unappr }) + '</span>'; |
1 | 92 |
} |
93 |
html += '</p>'; |
|
94 |
} |
|
95 |
else |
|
96 |
{ |
|
97 |
var cnt = data.count_appr; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
98 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
99 |
var subst = { |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
100 |
num_comments: cnt, |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
101 |
page_type: ns |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
102 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
103 |
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) ); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
104 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
105 |
html += "<p id=\"comment_status\">" + count_msg; |
1 | 106 |
if ( data.count_unappr > 0 ) |
107 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
108 |
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 }); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
109 |
html += ' ' + unappr_msg; |
1 | 110 |
} |
111 |
html += '</p>'; |
|
112 |
} |
|
113 |
||
114 |
// Comment display |
|
115 |
||
116 |
if ( data.count_total > 0 ) |
|
117 |
{ |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
118 |
comment_render_track = 0; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
119 |
var commentpages = new paginator(data.comments, _render_comment, 0, 10, data); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
120 |
html += commentpages.html; |
1 | 121 |
} |
122 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
123 |
if ( data.auth_post_comments ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
124 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
125 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
126 |
// Posting form |
1 | 127 |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
128 |
html += '<h3>' + $lang.get('comment_postform_title') + '</h3>'; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
129 |
html += '<p>' + $lang.get('comment_postform_blurb'); |
1 | 130 |
if ( data.approval_needed ) |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
131 |
html+=' ' + $lang.get('comment_postform_blurb_unapp'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
132 |
html += ' <a id="leave_comment_button" href="#" onclick="displayCommentForm(); return false;">' + $lang.get('comment_postform_blurb_link') + '</a></p>'; |
1 | 133 |
html += '<div id="comment_form" style="display: none;">'; |
134 |
html += ' <table border="0">'; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
135 |
html += ' <tr><td>' + $lang.get('comment_postform_field_name') + '</td><td>'; |
1 | 136 |
if ( data.user_id > 1 ) html += data.username + '<input id="commentform_name" type="hidden" value="'+data.username+'" size="40" />'; |
137 |
else html += '<input id="commentform_name" type="text" size="40" />'; |
|
138 |
html += ' </td></tr>'; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
139 |
html += ' <tr><td>' + $lang.get('comment_postform_field_subject') + '</td><td><input id="commentform_subject" type="text" size="40" /></td></tr>'; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
140 |
html += ' <tr><td>' + $lang.get('comment_postform_field_comment') + '</td><td><textarea id="commentform_message" rows="15" cols="50"></textarea></td></tr>'; |
1 | 141 |
if ( !data.logged_in && data.guest_posting == '1' ) |
142 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
143 |
html += ' <tr><td>' + $lang.get('comment_postform_field_captcha_title') + '<br /><small>' + $lang.get('comment_postform_field_captcha_blurb') + '</small></td><td>'; |
1 | 144 |
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 />'; |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
145 |
html += ' ' + $lang.get('comment_postform_field_captcha_label') + ' <input type="text" size="8" id="commentform_captcha" />'; |
1 | 146 |
html += ' <!-- This input is used to track the ID of the CAPTCHA image --> <input type="hidden" id="commentform_captcha_id" value="'+data.captcha+'" />'; |
147 |
html += ' </td></tr>'; |
|
148 |
} |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
149 |
html += ' <tr><td colspan="2" style="text-align: center;"><input type="button" onclick="submitComment();" value="' + $lang.get('comment_postform_btn_submit') + '" /></td></tr>'; |
1 | 150 |
html += ' </table>'; |
151 |
html += '</div>'; |
|
152 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
153 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
154 |
|
1 | 155 |
document.getElementById('ajaxEditContainer').innerHTML = html; |
156 |
||
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
157 |
for ( i = 0; i < data.comments.length; i++ ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
158 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
159 |
document.getElementById('comment_source_'+i).value = data.comments[i].comment_source; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
160 |
} |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
161 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
162 |
} |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
163 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
164 |
var _render_comment = function(this_comment, data) |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
165 |
{ |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
166 |
var i = comment_render_track; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
167 |
comment_render_track++; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
168 |
var parser = new templateParser(comment_template); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
169 |
var tplvars = new Object(); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
170 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
171 |
if ( this_comment.approved != '1' && !data.auth_mod_comments ) |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
172 |
return ''; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
173 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
174 |
tplvars.ID = i; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
175 |
tplvars.DATETIME = this_comment.time; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
176 |
tplvars.SUBJECT = this_comment.subject; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
177 |
tplvars.DATA = this_comment.comment_data; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
178 |
tplvars.SIGNATURE = this_comment.signature; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
179 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
180 |
if ( this_comment.approved != '1' ) |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
181 |
tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>'; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
182 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
183 |
// Name |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
184 |
tplvars.NAME = this_comment.name; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
185 |
if ( this_comment.user_id > 1 ) |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
186 |
tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '">' + this_comment.name + '</a>'; |
1 | 187 |
|
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
188 |
// Avatar |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
189 |
if ( this_comment.user_has_avatar == '1' ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
190 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
191 |
tplvars.AVATAR_URL = scriptPath + '/' + data.avatar_directory + '/' + this_comment.user_id + '.' + this_comment.avatar_type; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
192 |
tplvars.USERPAGE_LINK = makeUrlNS('User', this_comment.name); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
193 |
tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: this_comment.name }); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
194 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
195 |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
196 |
// User level |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
197 |
tplvars.USER_LEVEL = $lang.get('user_type_guest'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
198 |
if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = $lang.get('user_type_member'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
199 |
if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = $lang.get('user_type_mod'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
200 |
if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = $lang.get('user_type_admin'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
201 |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
202 |
// Send PM link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
203 |
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, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br />':''; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
204 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
205 |
// Add buddy link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
206 |
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, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':''; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
207 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
208 |
// Edit link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
209 |
tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
210 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
211 |
// Delete link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
212 |
tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
213 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
214 |
// Moderation: (Un)approve link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
215 |
var appr = ( this_comment.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
216 |
tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
217 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
218 |
// Moderation: Delete post link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
219 |
tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
220 |
|
359 | 221 |
// Moderation: IP address link |
222 |
if ( this_comment.have_ip ) |
|
223 |
{ |
|
224 |
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>'; |
|
225 |
} |
|
226 |
else |
|
227 |
{ |
|
228 |
tplvars.MOD_IP_LINK = $lang.get('comment_btn_mod_ip_missing'); |
|
229 |
} |
|
230 |
||
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
231 |
var tplbool = new Object(); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
232 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
233 |
tplbool.signature = ( this_comment.signature == '' ) ? false : true; |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
234 |
tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
235 |
tplbool.auth_mod = data.auth_mod_comments; |
108
1c7f59df9474
Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents:
102
diff
changeset
|
236 |
tplbool.is_friend = ( this_comment.is_buddy == 1 && this_comment.is_friend == 1 ); |
1c7f59df9474
Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents:
102
diff
changeset
|
237 |
tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 ); |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
238 |
tplbool.user_has_avatar = ( this_comment.user_has_avatar == '1' ); |
108
1c7f59df9474
Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents:
102
diff
changeset
|
239 |
|
1c7f59df9474
Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents:
102
diff
changeset
|
240 |
if ( tplbool.is_friend ) |
214 | 241 |
tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_friend_list') + '</b>'; |
108
1c7f59df9474
Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents:
102
diff
changeset
|
242 |
else if ( tplbool.is_foe ) |
214 | 243 |
tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_foe_list') + '</b>'; |
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
244 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
245 |
parser.assign_vars(tplvars); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
246 |
parser.assign_bool(tplbool); |
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
247 |
|
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
74
diff
changeset
|
248 |
return '<div id="comment_holder_' + i + '"><input type="hidden" value="'+this_comment.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run() + '</div>'; |
1 | 249 |
} |
250 |
||
251 |
function displayCommentForm() |
|
252 |
{ |
|
253 |
document.getElementById('leave_comment_button').style.display = 'none'; |
|
254 |
document.getElementById('comment_form').style.display = 'block'; |
|
255 |
} |
|
256 |
||
257 |
function hideCommentForm() |
|
258 |
{ |
|
259 |
document.getElementById('leave_comment_button').style.display = 'inline'; |
|
260 |
document.getElementById('comment_form').style.display = 'none'; |
|
261 |
} |
|
262 |
||
263 |
function editComment(id, link) |
|
264 |
{ |
|
265 |
var ctr = document.getElementById('subject_'+id); |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
266 |
var subj = ( ctr.firstChild ) ? trim(ctr.firstChild.nodeValue) : ''; // If there's a span in there that says 'unapproved', this eliminates it |
1 | 267 |
ctr.innerHTML = ''; |
268 |
var ipt = document.createElement('input'); |
|
269 |
ipt.id = 'subject_edit_'+id; |
|
270 |
ipt.value = subj; |
|
271 |
ctr.appendChild(ipt); |
|
272 |
||
273 |
var src = document.getElementById('comment_source_'+id).value; |
|
274 |
var cmt = document.getElementById('comment_'+id); |
|
275 |
cmt.innerHTML = ''; |
|
276 |
var ta = document.createElement('textarea'); |
|
277 |
ta.rows = '10'; |
|
278 |
ta.cols = '40'; |
|
279 |
ta.value = src; |
|
280 |
ta.id = 'comment_edit_'+id; |
|
281 |
cmt.appendChild(ta); |
|
282 |
||
283 |
link.style.fontWeight = 'bold'; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
284 |
link.innerHTML = $lang.get('comment_btn_save'); |
1 | 285 |
link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; }; |
286 |
} |
|
287 |
||
288 |
function saveComment(id, link) |
|
289 |
{ |
|
290 |
var data = document.getElementById('comment_edit_'+id).value; |
|
291 |
var subj = document.getElementById('subject_edit_'+id).value; |
|
292 |
var div = document.getElementById('comment_holder_'+id); |
|
293 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
294 |
var req = { |
|
295 |
'mode' : 'edit', |
|
296 |
'id' : real_id, |
|
297 |
'local_id' : id, |
|
298 |
'data' : data, |
|
299 |
'subj' : subj |
|
300 |
}; |
|
301 |
link.style.fontWeight = 'normal'; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
302 |
link.innerHTML = $lang.get('comment_btn_edit'); |
1 | 303 |
link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); editComment(id, this); return false; }; |
304 |
ajaxComments(req); |
|
305 |
} |
|
306 |
||
307 |
function deleteComment(id) |
|
308 |
{ |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
309 |
if ( !shift ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
310 |
{ |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
311 |
var c = confirm($lang.get('comment_msg_delete_confirm')); |
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
312 |
if(!c) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
313 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
314 |
} |
1 | 315 |
var div = document.getElementById('comment_holder_'+id); |
316 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
317 |
var req = { |
|
318 |
'mode' : 'delete', |
|
319 |
'id' : real_id, |
|
320 |
'local_id' : id |
|
321 |
}; |
|
322 |
ajaxComments(req); |
|
323 |
} |
|
324 |
||
325 |
function submitComment() |
|
326 |
{ |
|
327 |
var name = document.getElementById('commentform_name').value; |
|
328 |
var subj = document.getElementById('commentform_subject').value; |
|
329 |
var text = document.getElementById('commentform_message').value; |
|
330 |
if ( document.getElementById('commentform_captcha') ) |
|
331 |
{ |
|
332 |
var captcha_code = document.getElementById('commentform_captcha').value; |
|
333 |
var captcha_id = document.getElementById('commentform_captcha_id').value; |
|
334 |
} |
|
335 |
else |
|
336 |
{ |
|
337 |
var captcha_code = ''; |
|
338 |
var captcha_id = ''; |
|
339 |
} |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
340 |
if ( subj == '' ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
341 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
342 |
new messagebox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.'); |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
343 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
344 |
} |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
345 |
if ( text == '' ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
346 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
347 |
new messagebox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .'); |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
348 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
349 |
} |
1 | 350 |
var req = { |
351 |
'mode' : 'submit', |
|
352 |
'name' : name, |
|
353 |
'subj' : subj, |
|
354 |
'text' : text, |
|
355 |
'captcha_code' : captcha_code, |
|
356 |
'captcha_id' : captcha_id |
|
357 |
}; |
|
358 |
ajaxComments(req); |
|
359 |
} |
|
360 |
||
361 |
function redrawComment(data) |
|
362 |
{ |
|
363 |
if ( data.subj ) |
|
364 |
{ |
|
365 |
document.getElementById('subject_' + data.id).innerHTML = data.subj; |
|
366 |
} |
|
367 |
if ( data.approved && data.approved != '1' ) |
|
368 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
369 |
document.getElementById('subject_' + data.id).innerHTML += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>'; |
1 | 370 |
} |
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
1
diff
changeset
|
371 |
if ( data.approved && ( typeof(data.approve_updated) == 'string' && data.approve_updated == 'yes' ) ) |
1 | 372 |
{ |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
373 |
var appr = ( data.approved == '1' ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
1 | 374 |
document.getElementById('comment_approve_'+data.id).innerHTML = appr; |
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
1
diff
changeset
|
375 |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
376 |
if ( data.approved == '1' ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
377 |
comment_decrement_unapproval(); |
1 | 378 |
else |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
379 |
comment_increment_unapproval(); |
1 | 380 |
} |
381 |
if ( data.text ) |
|
382 |
{ |
|
383 |
document.getElementById('comment_' + data.id).innerHTML = data.text; |
|
384 |
} |
|
385 |
if ( data.src ) |
|
386 |
{ |
|
387 |
document.getElementById('comment_source_' + data.id).value = data.src; |
|
388 |
} |
|
359 | 389 |
if ( data.ip_addr ) |
390 |
{ |
|
391 |
var span = $('comment_ip_' + data.local_id).object; |
|
392 |
if ( !span ) |
|
393 |
return false; |
|
394 |
span.innerHTML = $lang.get('comment_msg_ip_address') + ' <a href="#rdns" onclick="ajaxReverseDNS(this); return false;">' + data.ip_addr + '</a>'; |
|
395 |
} |
|
1 | 396 |
} |
397 |
||
398 |
function approveComment(id) |
|
399 |
{ |
|
400 |
var div = document.getElementById('comment_holder_'+id); |
|
401 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
402 |
var req = { |
|
403 |
'mode' : 'approve', |
|
404 |
'id' : real_id, |
|
405 |
'local_id' : id |
|
406 |
}; |
|
407 |
ajaxComments(req); |
|
408 |
} |
|
409 |
||
410 |
// Does the actual DOM object removal |
|
411 |
function annihiliateComment(id) // Did I spell that right? |
|
412 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
413 |
var approved = true; |
1 | 414 |
if(document.getElementById('comment_approve_'+id)) |
415 |
{ |
|
416 |
var appr = document.getElementById('comment_approve_'+id).firstChild.nodeValue; |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
417 |
if ( appr == $lang.get('comment_btn_mod_approve') ) |
1 | 418 |
{ |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
419 |
approved = false; |
1 | 420 |
} |
421 |
} |
|
422 |
||
423 |
var div = document.getElementById('comment_holder_'+id); |
|
424 |
div.parentNode.removeChild(div); |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
425 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
426 |
// update approval status |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
427 |
if ( document.getElementById('comment_count_unapp_inner') && !approved ) |
1 | 428 |
{ |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
429 |
comment_decrement_unapproval(); |
1 | 430 |
} |
431 |
} |
|
432 |
||
433 |
function materializeComment(data) |
|
434 |
{ |
|
435 |
// Intelligently get an ID |
|
436 |
||
437 |
var i = 0; |
|
438 |
var brother; |
|
439 |
while ( true ) |
|
440 |
{ |
|
441 |
var x = document.getElementById('comment_holder_'+i); |
|
442 |
if(!x) |
|
443 |
break; |
|
444 |
brother = x; |
|
445 |
i++; |
|
446 |
} |
|
447 |
||
448 |
var parser = new templateParser(comment_template); |
|
449 |
var tplvars = new Object(); |
|
450 |
||
451 |
if ( data.approved != '1' && !data.auth_mod_comments ) |
|
452 |
return false; |
|
453 |
||
454 |
tplvars.ID = i; |
|
455 |
tplvars.DATETIME = data.time; |
|
456 |
tplvars.SUBJECT = data.subject; |
|
457 |
tplvars.DATA = data.comment_data; |
|
458 |
tplvars.SIGNATURE = data.signature; |
|
459 |
||
460 |
tplvars.NAME = data.name; |
|
461 |
if ( data.user_id > 1 ) |
|
462 |
tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '">' + data.name + '</a>'; |
|
463 |
||
464 |
if ( data.approved != '1' ) |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
465 |
tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>'; |
1 | 466 |
|
467 |
// User level |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
468 |
tplvars.USER_LEVEL = $lang.get('user_type_guest'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
469 |
if ( data.user_level >= data.user_level_list.member ) tplvars.USER_LEVEL = $lang.get('user_type_member'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
470 |
if ( data.user_level >= data.user_level_list.mod ) tplvars.USER_LEVEL = $lang.get('user_type_mod'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
471 |
if ( data.user_level >= data.user_level_list.admin ) tplvars.USER_LEVEL = $lang.get('user_type_admin'); |
1 | 472 |
|
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
473 |
// Avatar |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
474 |
if ( data.user_has_avatar == '1' ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
475 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
476 |
tplvars.AVATAR_URL = scriptPath + '/' + data.avatar_directory + '/' + data.user_id + '.' + data.avatar_type; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
477 |
tplvars.USERPAGE_LINK = makeUrlNS('User', data.name); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
478 |
tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: data.name }); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
479 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
480 |
|
1 | 481 |
// Send PM link |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
482 |
tplvars.SEND_PM_LINK=(data.user_id>1)?'<a 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 />':''; |
1 | 483 |
|
484 |
// Add buddy link |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
485 |
tplvars.ADD_BUDDY_LINK=(data.user_id>1)?'<a 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 />':''; |
1 | 486 |
|
487 |
// Edit link |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
488 |
tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>'; |
1 | 489 |
|
490 |
// Delete link |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
491 |
tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>'; |
1 | 492 |
|
493 |
// Moderation: (Un)approve link |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
494 |
var appr = ( data.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve'); |
1 | 495 |
tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
496 |
||
497 |
// Moderation: Delete post link |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
498 |
tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>'; |
1 | 499 |
|
359 | 500 |
// Moderation: IP address link |
501 |
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>'; |
|
502 |
||
1 | 503 |
var tplbool = new Object(); |
504 |
||
505 |
tplbool.signature = ( data.signature == '' ) ? false : true; |
|
506 |
tplbool.can_edit = ( data.auth_edit_comments && ( ( data.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
|
507 |
tplbool.auth_mod = data.auth_mod_comments; |
|
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
214
diff
changeset
|
508 |
tplbool.user_has_avatar = ( data.user_has_avatar == '1' ); |
1 | 509 |
|
510 |
parser.assign_vars(tplvars); |
|
511 |
parser.assign_bool(tplbool); |
|
512 |
||
513 |
var div = document.createElement('div'); |
|
514 |
div.id = 'comment_holder_'+i; |
|
515 |
||
516 |
div.innerHTML = '<input type="hidden" value="'+data.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run(); |
|
517 |
||
518 |
if ( brother ) |
|
519 |
{ |
|
520 |
brother.parentNode.insertBefore(div, brother.nextSibling); |
|
521 |
} |
|
522 |
else |
|
523 |
{ |
|
524 |
// No comments in ajaxEditContainer, insert it after the header |
|
525 |
var aec = document.getElementById("ajaxEditContainer"); |
|
526 |
aec.insertBefore(div, aec.firstChild.nextSibling.nextSibling); |
|
527 |
} |
|
528 |
||
529 |
document.getElementById('comment_source_'+i).value = data.comment_source; |
|
530 |
||
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
531 |
var cnt = document.getElementById('comment_count_inner').innerHTML; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
532 |
cnt = parseInt(cnt); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
533 |
if ( isNaN(cnt) ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
534 |
cnt = 0; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
535 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
536 |
var subst = { |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
537 |
num_comments: cnt, |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
538 |
page_type: ENANO_PAGE_TYPE |
1 | 539 |
} |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
540 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
541 |
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) ); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
542 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
543 |
document.getElementById('comment_status').firstChild.innerHTML = count_msg; |
1 | 544 |
|
545 |
if(document.getElementById('comment_approve_'+i)) |
|
546 |
{ |
|
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
547 |
var is_unappr = document.getElementById('comment_approve_'+i).firstChild.nodeValue; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
548 |
is_unappr = ( is_unappr == $lang.get('comment_btn_mod_approve') ); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
549 |
if ( is_unappr ) |
1 | 550 |
{ |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
551 |
comment_increment_unapproval(); |
1 | 552 |
} |
553 |
} |
|
554 |
||
555 |
} |
|
556 |
||
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
557 |
function comment_decrement_unapproval() |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
558 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
559 |
if ( document.getElementById('comment_count_unapp_inner') ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
560 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
561 |
var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
562 |
if ( !isNaN(num_unapp) ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
563 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
564 |
num_unapp = num_unapp - 1; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
565 |
if ( num_unapp == 0 ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
566 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
567 |
var p = document.getElementById('comment_status'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
568 |
p.removeChild(p.childNodes[2]); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
569 |
p.removeChild(p.childNodes[1]); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
570 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
571 |
else |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
572 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
573 |
var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
574 |
document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
575 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
576 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
577 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
578 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
579 |
|
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
580 |
function comment_increment_unapproval() |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
581 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
582 |
if ( document.getElementById('comment_count_unapp_inner') ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
583 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
584 |
var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
585 |
if ( isNaN(num_unapp) ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
586 |
num_unapp = 0; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
587 |
num_unapp = num_unapp + 1; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
588 |
var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp }); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
589 |
document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
590 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
591 |
else |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
592 |
{ |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
593 |
var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: 1 }); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
594 |
var status = document.getElementById('comment_status'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
595 |
if ( !status.childNodes[1] ) |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
596 |
status.appendChild(document.createTextNode(' ')); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
597 |
var span = document.createElement('span'); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
598 |
span.id = 'comment_status_unapp'; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
599 |
span.style.color = '#D84308'; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
600 |
span.innerHTML = count_msg; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
601 |
status.appendChild(span); |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
602 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
603 |
} |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
108
diff
changeset
|
604 |
|
359 | 605 |
function viewCommentIP(id, local_id) |
606 |
{ |
|
607 |
// set "loading" indicator on IP button |
|
608 |
var span = $('comment_ip_' + local_id).object; |
|
609 |
if ( !span ) |
|
610 |
return false; |
|
611 |
span.innerHTML = '<img alt="..." src="' + ajax_load_icon + '" />'; |
|
612 |
||
613 |
var parms = { |
|
614 |
mode: 'view_ip', |
|
615 |
id: id, |
|
616 |
local_id: local_id |
|
617 |
} |
|
618 |
ajaxComments(parms); |
|
619 |
} |
|
620 |
||
1 | 621 |
function htmlspecialchars(text) |
622 |
{ |
|
623 |
text = text.replace(/</g, '<'); |
|
624 |
text = text.replace(/>/g, '>'); |
|
625 |
return text; |
|
626 |
} |
|
627 |
||
628 |
// Equivalent to PHP trim() function |
|
629 |
function trim(text) |
|
630 |
{ |
|
631 |
text = text.replace(/^([\s]+)/, ''); |
|
632 |
text = text.replace(/([\s]+)$/, ''); |
|
633 |
return text; |
|
634 |
} |
|
635 |
||
636 |
// Equivalent to PHP implode() function |
|
637 |
function implode(chr, arr) |
|
638 |
{ |
|
639 |
if ( typeof ( arr.toJSONString ) == 'function' ) |
|
640 |
delete(arr.toJSONString); |
|
641 |
||
642 |
var ret = ''; |
|
643 |
var c = 0; |
|
644 |
for ( var i in arr ) |
|
645 |
{ |
|
646 |
if(i=='toJSONString')continue; |
|
647 |
if ( c > 0 ) |
|
648 |
ret += chr; |
|
649 |
ret += arr[i]; |
|
650 |
c++; |
|
651 |
} |
|
652 |
return ret; |
|
653 |
} |
|
654 |
||
655 |
function nl2br(text) |
|
656 |
{ |
|
657 |
var regex = new RegExp(unescape('%0A'), 'g'); |
|
658 |
return text.replace(regex, '<br />' + unescape('%0A')); |
|
659 |
} |
|
660 |