author | Dan |
Thu, 06 Sep 2007 23:03:51 -0400 | |
changeset 116 | 77c75179bb95 |
parent 108 | 1c7f59df9474 |
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': |
|
51 |
alert('Your comment has been posted. If it does not appear right away, it is probably awaiting approval.'); |
|
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 |
||
73 |
html += '<h3>Article Comments</h3>'; |
|
74 |
||
75 |
var ns = ( strToPageID(title)[1]=='Article' ) ? 'article' : ( strToPageID(title)[1].toLowerCase() ) + ' page'; |
|
76 |
||
77 |
// Counters |
|
78 |
if ( data.auth_mod_comments ) |
|
79 |
{ |
|
80 |
var cnt = ( data.auth_mod_comments ) ? data.count_total : data.count_appr; |
|
81 |
if ( cnt == 0 ) cnt = 'no'; |
|
82 |
var s = ( cnt == 1 ) ? '' : 's'; |
|
83 |
var is = ( cnt == 1 ) ? 'is' : 'are'; |
|
84 |
html += "<p id=\"comment_status\">There "+is+" " + cnt + " comment"+s+" on this "+ns+"."; |
|
85 |
if ( data.count_unappr > 0 ) |
|
86 |
{ |
|
87 |
html += ' <span style="color: #D84308">' + data.count_unappr + ' of those are unapproved.</span>'; |
|
88 |
} |
|
89 |
html += '</p>'; |
|
90 |
} |
|
91 |
else |
|
92 |
{ |
|
93 |
var cnt = data.count_appr; |
|
94 |
if ( cnt == 0 ) cnt = 'no'; |
|
95 |
var s = ( cnt == 1 ) ? '' : 's'; |
|
96 |
var is = ( cnt == 1 ) ? 'is' : 'are'; |
|
97 |
html += "<p id=\"comment_status\">There "+is+" " + cnt + " comment"+s+" on this "+ns+"."; |
|
98 |
if ( data.count_unappr > 0 ) |
|
99 |
{ |
|
100 |
var s = ( data.count_unappr == 1 ) ? '' : 's'; |
|
101 |
var is = ( data.count_unappr == 1 ) ? 'is' : 'are'; |
|
102 |
html += ' However, there '+is+' '+data.count_unappr+' additional comment'+s+' awaiting approval.'; |
|
103 |
} |
|
104 |
html += '</p>'; |
|
105 |
} |
|
106 |
||
107 |
// Comment display |
|
108 |
||
109 |
if ( data.count_total > 0 ) |
|
110 |
{ |
|
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
|
111 |
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
|
112 |
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
|
113 |
html += commentpages.html; |
1 | 114 |
} |
115 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
116 |
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
|
117 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
118 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
119 |
// Posting form |
1 | 120 |
|
121 |
html += '<h3>Got something to say?</h3>'; |
|
122 |
html += '<p>If you have comments or suggestions on this article, you can shout it out here.'; |
|
123 |
if ( data.approval_needed ) |
|
124 |
html+=' Before your post will be visible to the public, a moderator will have to approve it.'; |
|
125 |
html += ' <a id="leave_comment_button" href="#" onclick="displayCommentForm(); return false;">Leave a comment...</a></p>'; |
|
126 |
html += '<div id="comment_form" style="display: none;">'; |
|
127 |
html += ' <table border="0">'; |
|
128 |
html += ' <tr><td>Your name/screen name:</td><td>'; |
|
129 |
if ( data.user_id > 1 ) html += data.username + '<input id="commentform_name" type="hidden" value="'+data.username+'" size="40" />'; |
|
130 |
else html += '<input id="commentform_name" type="text" size="40" />'; |
|
131 |
html += ' </td></tr>'; |
|
132 |
html += ' <tr><td>Comment subject:</td><td><input id="commentform_subject" type="text" size="40" /></td></tr>'; |
|
133 |
html += ' <tr><td>Comment:</td><td><textarea id="commentform_message" rows="15" cols="50"></textarea></td></tr>'; |
|
134 |
if ( !data.logged_in && data.guest_posting == '1' ) |
|
135 |
{ |
|
136 |
html += ' <tr><td>Visual confirmation:<br /><small>Please enter the confirmation code seen in the image on the right into the box. If you cannot read the code, please click on the image to generate a new one. This helps to prevent automated bot posting.</small></td><td>'; |
|
137 |
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 />'; |
|
138 |
html += ' Confirmation code: <input type="text" size="8" id="commentform_captcha" />'; |
|
139 |
html += ' <!-- This input is used to track the ID of the CAPTCHA image --> <input type="hidden" id="commentform_captcha_id" value="'+data.captcha+'" />'; |
|
140 |
html += ' </td></tr>'; |
|
141 |
} |
|
142 |
html += ' <tr><td colspan="2" style="text-align: center;"><input type="button" onclick="submitComment();" value="Submit comment" /></td></tr>'; |
|
143 |
html += ' </table>'; |
|
144 |
html += '</div>'; |
|
145 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
146 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
29
diff
changeset
|
147 |
|
1 | 148 |
document.getElementById('ajaxEditContainer').innerHTML = html; |
149 |
||
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
150 |
for ( i = 0; i < data.comments.length; i++ ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
151 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
152 |
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
|
153 |
} |
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
|
154 |
|
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
|
155 |
} |
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
|
156 |
|
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
|
157 |
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
|
158 |
{ |
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
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
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
|
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 |
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
|
165 |
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
|
166 |
|
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 |
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
|
168 |
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
|
169 |
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
|
170 |
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
|
171 |
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
|
172 |
|
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 |
if ( this_comment.approved != '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
|
174 |
tplvars.SUBJECT += ' <span style="color: #D84308">(Unapproved)</span>'; |
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 |
|
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 |
// 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
|
177 |
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
|
178 |
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
|
179 |
tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '">' + this_comment.name + '</a>'; |
1 | 180 |
|
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
|
181 |
// User level |
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 |
tplvars.USER_LEVEL = 'Guest'; |
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 |
if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member'; |
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
|
184 |
if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator'; |
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
|
185 |
if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator'; |
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
186 |
|
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
|
187 |
// Send PM link |
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
188 |
tplvars.SEND_PM_LINK=(this_comment.user_id>1 && data.logged_in)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">Send private message</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
|
189 |
|
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
|
190 |
// Add buddy link |
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
|
191 |
tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1 && data.logged_in && this_comment.is_buddy != 1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':''; |
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
|
192 |
|
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
|
193 |
// Edit link |
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
|
194 |
tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</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
|
195 |
|
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 |
// Delete link |
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
|
197 |
tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">delete</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
|
198 |
|
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
|
199 |
// Moderation: (Un)approve link |
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
|
200 |
var appr = ( this_comment.approved == 1 ) ? 'Unapprove' : 'Approve'; |
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
|
201 |
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
|
202 |
|
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
|
203 |
// Moderation: Delete post link |
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 |
tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">Delete</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
|
205 |
|
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
|
206 |
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
|
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 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 ); |
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
|
213 |
|
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
|
214 |
if ( tplbool.is_friend ) |
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
|
215 |
tplvars.USER_LEVEL += '<br /><b>On your friend list</b>'; |
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
|
216 |
else if ( tplbool.is_foe ) |
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
|
217 |
tplvars.USER_LEVEL += '<br /><b>On your 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
|
218 |
|
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
|
219 |
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
|
220 |
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
|
221 |
|
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
|
222 |
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 | 223 |
} |
224 |
||
225 |
function displayCommentForm() |
|
226 |
{ |
|
227 |
document.getElementById('leave_comment_button').style.display = 'none'; |
|
228 |
document.getElementById('comment_form').style.display = 'block'; |
|
229 |
} |
|
230 |
||
231 |
function hideCommentForm() |
|
232 |
{ |
|
233 |
document.getElementById('leave_comment_button').style.display = 'inline'; |
|
234 |
document.getElementById('comment_form').style.display = 'none'; |
|
235 |
} |
|
236 |
||
237 |
function editComment(id, link) |
|
238 |
{ |
|
239 |
var ctr = document.getElementById('subject_'+id); |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
240 |
var subj = ( ctr.firstChild ) ? trim(ctr.firstChild.nodeValue) : ''; // If there's a span in there that says 'unapproved', this eliminates it |
1 | 241 |
ctr.innerHTML = ''; |
242 |
var ipt = document.createElement('input'); |
|
243 |
ipt.id = 'subject_edit_'+id; |
|
244 |
ipt.value = subj; |
|
245 |
ctr.appendChild(ipt); |
|
246 |
||
247 |
var src = document.getElementById('comment_source_'+id).value; |
|
248 |
var cmt = document.getElementById('comment_'+id); |
|
249 |
cmt.innerHTML = ''; |
|
250 |
var ta = document.createElement('textarea'); |
|
251 |
ta.rows = '10'; |
|
252 |
ta.cols = '40'; |
|
253 |
ta.value = src; |
|
254 |
ta.id = 'comment_edit_'+id; |
|
255 |
cmt.appendChild(ta); |
|
256 |
||
257 |
link.style.fontWeight = 'bold'; |
|
258 |
link.innerHTML = 'save'; |
|
259 |
link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; }; |
|
260 |
} |
|
261 |
||
262 |
function saveComment(id, link) |
|
263 |
{ |
|
264 |
var data = document.getElementById('comment_edit_'+id).value; |
|
265 |
var subj = document.getElementById('subject_edit_'+id).value; |
|
266 |
var div = document.getElementById('comment_holder_'+id); |
|
267 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
268 |
var req = { |
|
269 |
'mode' : 'edit', |
|
270 |
'id' : real_id, |
|
271 |
'local_id' : id, |
|
272 |
'data' : data, |
|
273 |
'subj' : subj |
|
274 |
}; |
|
275 |
link.style.fontWeight = 'normal'; |
|
276 |
link.innerHTML = 'edit'; |
|
277 |
link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); editComment(id, this); return false; }; |
|
278 |
ajaxComments(req); |
|
279 |
} |
|
280 |
||
281 |
function deleteComment(id) |
|
282 |
{ |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
283 |
if ( !shift ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
284 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
285 |
var c = confirm('Do you really want to delete this comment?'); |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
286 |
if(!c) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
287 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
288 |
} |
1 | 289 |
var div = document.getElementById('comment_holder_'+id); |
290 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
291 |
var req = { |
|
292 |
'mode' : 'delete', |
|
293 |
'id' : real_id, |
|
294 |
'local_id' : id |
|
295 |
}; |
|
296 |
ajaxComments(req); |
|
297 |
} |
|
298 |
||
299 |
function submitComment() |
|
300 |
{ |
|
301 |
var name = document.getElementById('commentform_name').value; |
|
302 |
var subj = document.getElementById('commentform_subject').value; |
|
303 |
var text = document.getElementById('commentform_message').value; |
|
304 |
if ( document.getElementById('commentform_captcha') ) |
|
305 |
{ |
|
306 |
var captcha_code = document.getElementById('commentform_captcha').value; |
|
307 |
var captcha_id = document.getElementById('commentform_captcha_id').value; |
|
308 |
} |
|
309 |
else |
|
310 |
{ |
|
311 |
var captcha_code = ''; |
|
312 |
var captcha_id = ''; |
|
313 |
} |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
314 |
if ( subj == '' ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
315 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
316 |
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
|
317 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
318 |
} |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
319 |
if ( text == '' ) |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
320 |
{ |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
321 |
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
|
322 |
return false; |
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
86
diff
changeset
|
323 |
} |
1 | 324 |
var req = { |
325 |
'mode' : 'submit', |
|
326 |
'name' : name, |
|
327 |
'subj' : subj, |
|
328 |
'text' : text, |
|
329 |
'captcha_code' : captcha_code, |
|
330 |
'captcha_id' : captcha_id |
|
331 |
}; |
|
332 |
ajaxComments(req); |
|
333 |
} |
|
334 |
||
335 |
function redrawComment(data) |
|
336 |
{ |
|
337 |
if ( data.subj ) |
|
338 |
{ |
|
339 |
document.getElementById('subject_' + data.id).innerHTML = data.subj; |
|
340 |
} |
|
341 |
if ( data.approved && data.approved != '1' ) |
|
342 |
{ |
|
343 |
document.getElementById('subject_' + data.id).innerHTML += ' <span style="color: #D84308">(Unapproved)</span>'; |
|
344 |
} |
|
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
|
345 |
if ( data.approved && ( typeof(data.approve_updated) == 'string' && data.approve_updated == 'yes' ) ) |
1 | 346 |
{ |
347 |
var appr = ( data.approved == '1' ) ? 'Unapprove' : 'Approve'; |
|
348 |
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
|
349 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
1
diff
changeset
|
350 |
// Update approval status |
1 | 351 |
var p = document.getElementById('comment_status'); |
352 |
var count = p.firstChild.nodeValue.split(' ')[2]; |
|
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
|
353 |
|
1 | 354 |
if ( p.firstChild.nextSibling ) |
355 |
{ |
|
356 |
var span = p.firstChild.nextSibling; |
|
357 |
var is = ( data.approved == '1' ) ? -1 : 1; |
|
358 |
var n_unapp = parseInt(span.firstChild.nodeValue.split(' ')[0]) + is; |
|
359 |
n_unapp = n_unapp + ''; |
|
360 |
} |
|
361 |
else |
|
362 |
{ |
|
363 |
var span = document.createElement('span'); |
|
364 |
p.innerHTML += ' '; |
|
365 |
span.innerHTML = ' '; |
|
366 |
span.style.color = '#D84308'; |
|
367 |
var n_unapp = '1'; |
|
368 |
p.appendChild(span); |
|
369 |
} |
|
370 |
span.innerHTML = n_unapp + ' of those are unapproved.'; |
|
371 |
if ( n_unapp == '0' ) |
|
372 |
p.removeChild(span); |
|
373 |
} |
|
374 |
if ( data.text ) |
|
375 |
{ |
|
376 |
document.getElementById('comment_' + data.id).innerHTML = data.text; |
|
377 |
} |
|
378 |
if ( data.src ) |
|
379 |
{ |
|
380 |
document.getElementById('comment_source_' + data.id).value = data.src; |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
function approveComment(id) |
|
385 |
{ |
|
386 |
var div = document.getElementById('comment_holder_'+id); |
|
387 |
var real_id = div.getElementsByTagName('input')[0]['value']; |
|
388 |
var req = { |
|
389 |
'mode' : 'approve', |
|
390 |
'id' : real_id, |
|
391 |
'local_id' : id |
|
392 |
}; |
|
393 |
ajaxComments(req); |
|
394 |
} |
|
395 |
||
396 |
// Does the actual DOM object removal |
|
397 |
function annihiliateComment(id) // Did I spell that right? |
|
398 |
{ |
|
399 |
// Approved? |
|
400 |
var p = document.getElementById('comment_status'); |
|
401 |
||
402 |
if(document.getElementById('comment_approve_'+id)) |
|
403 |
{ |
|
404 |
var appr = document.getElementById('comment_approve_'+id).firstChild.nodeValue; |
|
405 |
if ( p.firstChild.nextSibling && appr == 'Approve' ) |
|
406 |
{ |
|
407 |
var span = p.firstChild.nextSibling; |
|
408 |
var t = span.firstChild.nodeValue; |
|
409 |
var n_unapp = ( parseInt(t.split(' ')[0]) ) - 1; |
|
410 |
if ( n_unapp == 0 ) |
|
411 |
p.removeChild(span); |
|
412 |
else |
|
413 |
span.firstChild.nodeValue = n_unapp + t.substr(t.indexOf(' ')); |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
var div = document.getElementById('comment_holder_'+id); |
|
418 |
div.parentNode.removeChild(div); |
|
419 |
var t = p.firstChild.nodeValue.split(' '); |
|
420 |
t[2] = ( parseInt(t[2]) - 1 ) + ''; |
|
421 |
delete(t.toJSONString); |
|
422 |
if ( t[2] == '1' ) |
|
423 |
{ |
|
424 |
t[1] = 'is'; |
|
425 |
t[3] = 'comment'; |
|
426 |
} |
|
427 |
else |
|
428 |
{ |
|
429 |
t[1] = 'are'; |
|
430 |
t[3] = 'comments'; |
|
431 |
} |
|
432 |
t = implode(' ', t); |
|
433 |
p.firstChild.nodeValue = t; |
|
434 |
} |
|
435 |
||
436 |
function materializeComment(data) |
|
437 |
{ |
|
438 |
// Intelligently get an ID |
|
439 |
||
440 |
var i = 0; |
|
441 |
var brother; |
|
442 |
while ( true ) |
|
443 |
{ |
|
444 |
var x = document.getElementById('comment_holder_'+i); |
|
445 |
if(!x) |
|
446 |
break; |
|
447 |
brother = x; |
|
448 |
i++; |
|
449 |
} |
|
450 |
||
451 |
var parser = new templateParser(comment_template); |
|
452 |
var tplvars = new Object(); |
|
453 |
||
454 |
if ( data.approved != '1' && !data.auth_mod_comments ) |
|
455 |
return false; |
|
456 |
||
457 |
tplvars.ID = i; |
|
458 |
tplvars.DATETIME = data.time; |
|
459 |
tplvars.SUBJECT = data.subject; |
|
460 |
tplvars.DATA = data.comment_data; |
|
461 |
tplvars.SIGNATURE = data.signature; |
|
462 |
||
463 |
tplvars.NAME = data.name; |
|
464 |
if ( data.user_id > 1 ) |
|
465 |
tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '">' + data.name + '</a>'; |
|
466 |
||
467 |
if ( data.approved != '1' ) |
|
468 |
tplvars.SUBJECT += ' <span style="color: #D84308">(Unapproved)</span>'; |
|
469 |
||
470 |
// User level |
|
471 |
tplvars.USER_LEVEL = 'Guest'; |
|
472 |
if ( data.user_level >= data.user_level_list.member ) tplvars.USER_LEVEL = 'Member'; |
|
473 |
if ( data.user_level >= data.user_level_list.mod ) tplvars.USER_LEVEL = 'Moderator'; |
|
474 |
if ( data.user_level >= data.user_level_list.admin ) tplvars.USER_LEVEL = 'Administrator'; |
|
475 |
||
476 |
// Send PM link |
|
477 |
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, '_') )) +'">Send private message</a><br />':''; |
|
478 |
||
479 |
// Add buddy link |
|
480 |
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, '_') )) +'">Add to buddy list</a><br />':''; |
|
481 |
||
482 |
// Edit link |
|
483 |
tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>'; |
|
484 |
||
485 |
// Delete link |
|
486 |
tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">delete</a>'; |
|
487 |
||
488 |
// Moderation: (Un)approve link |
|
489 |
var appr = ( data.approved == 1 ) ? 'Unapprove' : 'Approve'; |
|
490 |
tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>'; |
|
491 |
||
492 |
// Moderation: Delete post link |
|
493 |
tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">Delete</a>'; |
|
494 |
||
495 |
var tplbool = new Object(); |
|
496 |
||
497 |
tplbool.signature = ( data.signature == '' ) ? false : true; |
|
498 |
tplbool.can_edit = ( data.auth_edit_comments && ( ( data.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) ); |
|
499 |
tplbool.auth_mod = data.auth_mod_comments; |
|
500 |
||
501 |
parser.assign_vars(tplvars); |
|
502 |
parser.assign_bool(tplbool); |
|
503 |
||
504 |
var div = document.createElement('div'); |
|
505 |
div.id = 'comment_holder_'+i; |
|
506 |
||
507 |
div.innerHTML = '<input type="hidden" value="'+data.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run(); |
|
508 |
||
509 |
if ( brother ) |
|
510 |
{ |
|
511 |
brother.parentNode.insertBefore(div, brother.nextSibling); |
|
512 |
} |
|
513 |
else |
|
514 |
{ |
|
515 |
// No comments in ajaxEditContainer, insert it after the header |
|
516 |
var aec = document.getElementById("ajaxEditContainer"); |
|
517 |
aec.insertBefore(div, aec.firstChild.nextSibling.nextSibling); |
|
518 |
} |
|
519 |
||
520 |
document.getElementById('comment_source_'+i).value = data.comment_source; |
|
521 |
||
522 |
var p = document.getElementById('comment_status'); |
|
523 |
var t = p.firstChild.nodeValue.split(' '); |
|
524 |
var n = ( isNaN(parseInt(t[2])) ) ? 0 : parseInt(t[2]); |
|
525 |
t[2] = ( n + 1 ) + ''; |
|
526 |
delete(t.toJSONString); |
|
527 |
if ( t[2] == '1' ) |
|
528 |
{ |
|
529 |
t[1] = 'is'; |
|
530 |
t[3] = 'comment'; |
|
531 |
} |
|
532 |
else |
|
533 |
{ |
|
534 |
t[1] = 'are'; |
|
535 |
t[3] = 'comments'; |
|
536 |
} |
|
537 |
t = implode(' ', t); |
|
538 |
p.firstChild.nodeValue = t; |
|
539 |
||
540 |
if(document.getElementById('comment_approve_'+i)) |
|
541 |
{ |
|
542 |
var appr = document.getElementById('comment_approve_'+i).firstChild.nodeValue; |
|
543 |
if ( p.firstChild.nextSibling && appr == 'Approve' ) |
|
544 |
{ |
|
545 |
var span = p.firstChild.nextSibling; |
|
546 |
var t = span.firstChild.nodeValue; |
|
547 |
var n_unapp = ( parseInt(t.split(' ')[0]) ) - 1; |
|
548 |
if ( n_unapp == 0 ) |
|
549 |
p.removeChild(span); |
|
550 |
else |
|
551 |
span.firstChild.nodeValue = n_unapp + t.substr(t.indexOf(' ')); |
|
552 |
} |
|
553 |
else if ( appr == 'Approve' && !p.firstChild.nextSibling ) |
|
554 |
{ |
|
555 |
var span = document.createElement('span'); |
|
556 |
p.innerHTML += ' '; |
|
557 |
span.innerHTML = '1 of those are unapproved.'; |
|
558 |
span.style.color = '#D84308'; |
|
559 |
var n_unapp = '1'; |
|
560 |
p.appendChild(span); |
|
561 |
} |
|
562 |
} |
|
563 |
||
564 |
} |
|
565 |
||
566 |
function htmlspecialchars(text) |
|
567 |
{ |
|
568 |
text = text.replace(/</g, '<'); |
|
569 |
text = text.replace(/>/g, '>'); |
|
570 |
return text; |
|
571 |
} |
|
572 |
||
573 |
// Equivalent to PHP trim() function |
|
574 |
function trim(text) |
|
575 |
{ |
|
576 |
text = text.replace(/^([\s]+)/, ''); |
|
577 |
text = text.replace(/([\s]+)$/, ''); |
|
578 |
return text; |
|
579 |
} |
|
580 |
||
581 |
// Equivalent to PHP implode() function |
|
582 |
function implode(chr, arr) |
|
583 |
{ |
|
584 |
if ( typeof ( arr.toJSONString ) == 'function' ) |
|
585 |
delete(arr.toJSONString); |
|
586 |
||
587 |
var ret = ''; |
|
588 |
var c = 0; |
|
589 |
for ( var i in arr ) |
|
590 |
{ |
|
591 |
if(i=='toJSONString')continue; |
|
592 |
if ( c > 0 ) |
|
593 |
ret += chr; |
|
594 |
ret += arr[i]; |
|
595 |
c++; |
|
596 |
} |
|
597 |
return ret; |
|
598 |
} |
|
599 |
||
600 |
function nl2br(text) |
|
601 |
{ |
|
602 |
var regex = new RegExp(unescape('%0A'), 'g'); |
|
603 |
return text.replace(regex, '<br />' + unescape('%0A')); |
|
604 |
} |
|
605 |