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