| 1 | |
|---|
| 2 | function hideDocumentElement(id) { |
|---|
| 3 | var el = document.getElementById(id); |
|---|
| 4 | if (el) |
|---|
| 5 | el.style.display = 'none'; |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | function showDocumentElement(id) { |
|---|
| 9 | var el = document.getElementById(id); |
|---|
| 10 | if (el) |
|---|
| 11 | el.style.display = 'block'; |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | var captcha_timer; |
|---|
| 15 | function showAnonymousForm() { |
|---|
| 16 | showDocumentElement('comments-form'); |
|---|
| 17 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 18 | captcha_timer = setInterval('delayShowCaptcha()', 1000); |
|---|
| 19 | </MTIfNonEmpty> |
|---|
| 20 | } |
|---|
| 21 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 22 | function delayShowCaptcha() { |
|---|
| 23 | clearInterval(captcha_timer); |
|---|
| 24 | var div = document.getElementById('comments-open-captcha'); |
|---|
| 25 | if (div) |
|---|
| 26 | div.innerHTML = '<$MTCaptchaFields$>'; |
|---|
| 27 | } |
|---|
| 28 | </MTIfNonEmpty> |
|---|
| 29 | |
|---|
| 30 | var AUTHOR = 1; |
|---|
| 31 | var COMMENTER = 2; |
|---|
| 32 | var commenter_name; |
|---|
| 33 | var commenter_status; |
|---|
| 34 | var commenter_id; |
|---|
| 35 | var commenter_url |
|---|
| 36 | var is_preview; |
|---|
| 37 | var mtcmtmail; |
|---|
| 38 | var mtcmtauth; |
|---|
| 39 | var mtcmthome; |
|---|
| 40 | |
|---|
| 41 | function individualArchivesOnLoad(commenter_name) { |
|---|
| 42 | hideDocumentElement('comment-form-reply'); |
|---|
| 43 | <MTIfCommentsAccepted> |
|---|
| 44 | <MTElse> |
|---|
| 45 | hideDocumentElement('comments-open'); |
|---|
| 46 | </MTIfCommentsAccepted> |
|---|
| 47 | <MTIfPingsAccepted> |
|---|
| 48 | <MTElse> |
|---|
| 49 | hideDocumentElement('trackbacks-info'); |
|---|
| 50 | </MTIfPingsAccepted> |
|---|
| 51 | <MTIfRegistrationAllowed> |
|---|
| 52 | <MTIfRegistrationRequired> |
|---|
| 53 | if ( commenter_status > 0 ) { |
|---|
| 54 | hideDocumentElement('comment-form-name'); |
|---|
| 55 | hideDocumentElement('comment-form-email'); |
|---|
| 56 | showDocumentElement('comments-open-text'); |
|---|
| 57 | showDocumentElement('comments-open-footer'); |
|---|
| 58 | } else { |
|---|
| 59 | hideDocumentElement('comments-open-data'); |
|---|
| 60 | hideDocumentElement('comments-open-text'); |
|---|
| 61 | hideDocumentElement('comments-open-footer'); |
|---|
| 62 | } |
|---|
| 63 | <MTElse> |
|---|
| 64 | // comments are allowed but registration not required |
|---|
| 65 | if ( commenter_status > 0 ) { |
|---|
| 66 | hideDocumentElement('comment-form-name'); |
|---|
| 67 | hideDocumentElement('comment-form-email'); |
|---|
| 68 | } else if (is_preview) { |
|---|
| 69 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 70 | delayShowCaptcha(); |
|---|
| 71 | </MTIfNonEmpty> |
|---|
| 72 | } else { |
|---|
| 73 | hideDocumentElement('comments-form'); |
|---|
| 74 | } |
|---|
| 75 | </MTIfRegistrationRequired> |
|---|
| 76 | </MTIfRegistrationAllowed> |
|---|
| 77 | |
|---|
| 78 | var cf = document.comments_form; |
|---|
| 79 | if (cf) { |
|---|
| 80 | if (!commenter_name && (cf.email != undefined) && |
|---|
| 81 | (mtcmtmail = getCookie("mtcmtmail"))) |
|---|
| 82 | cf.email.value = mtcmtmail; |
|---|
| 83 | if (!commenter_name && (cf.author != undefined) && |
|---|
| 84 | (mtcmtauth = getCookie("mtcmtauth"))) |
|---|
| 85 | cf.author.value = mtcmtauth; |
|---|
| 86 | if (cf.url != undefined && |
|---|
| 87 | (mtcmthome = getCookie("mtcmthome"))) |
|---|
| 88 | cf.url.value = mtcmthome; |
|---|
| 89 | if (cf["bakecookie"]) { |
|---|
| 90 | if (mtcmtauth || mtcmthome) { |
|---|
| 91 | cf.bakecookie.checked = true; |
|---|
| 92 | } else { |
|---|
| 93 | cf.bakecookie.checked = false; |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) { |
|---|
| 100 | <MTIfRegistrationAllowed> |
|---|
| 101 | if ( commenter_status > 0 ) { |
|---|
| 102 | var commenter_link; |
|---|
| 103 | if ( commenter_status == COMMENTER ) { |
|---|
| 104 | if (commenter_url) { |
|---|
| 105 | commenter_link = '<a href="' + commenter_url + '">' + commenter_name + '</a>'; |
|---|
| 106 | } else { |
|---|
| 107 | commenter_link = commenter_name; |
|---|
| 108 | } |
|---|
| 109 | } else if ( commenter_status == AUTHOR ) { |
|---|
| 110 | if (commenter_id) { |
|---|
| 111 | commenter_link = '<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=' + blog_id; |
|---|
| 112 | if (entry_id) { |
|---|
| 113 | commenter_link += '&entry_id=' + entry_id; |
|---|
| 114 | } else { |
|---|
| 115 | commenter_link += '&static=1'; |
|---|
| 116 | } |
|---|
| 117 | commenter_link += '">' + commenter_name + '</a>'; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | } |
|---|
| 121 | document.write( |
|---|
| 122 | '<__trans phrase="Thanks for signing in, [_1]. Now you can comment. ([_2]sign out[_3])" params="' + commenter_link + '%%<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '">%%</a>">' |
|---|
| 123 | ); |
|---|
| 124 | } else if (commenter_name) { |
|---|
| 125 | document.write('<__trans phrase="You do not have permission to comment on this blog. ([_1]sign out[_2])" params="<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '">%%</a>">'); |
|---|
| 126 | } else { |
|---|
| 127 | <MTIfRegistrationRequired> |
|---|
| 128 | var phrase = '<__trans phrase="[_1]Sign in[_2] to comment on this entry." params="<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1&return_to=' + encodeURIComponent(document.URL) + '">%%</a>">'; |
|---|
| 129 | <MTElse> |
|---|
| 130 | var phrase = '<__trans phrase="[_1]Sign in[_2] to comment on this entry, or [_3]comment anonymously[_2]." params="<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1&return_to=' + encodeURIComponent(document.URL) + '">%%</a>%%<a href="javascript:void(0);" onclick="showAnonymousForm();">">'; |
|---|
| 131 | </MTIfRegistrationRequired> |
|---|
| 132 | document.write(phrase); |
|---|
| 133 | } |
|---|
| 134 | </MTIfRegistrationAllowed> |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | <MTIfRegistrationAllowed> |
|---|
| 138 | <$MTCGIHost exclude_port="1" setvar="cgi_host"$><$MTBlogHost exclude_port="1" setvar="blog_host"$> |
|---|
| 139 | <MTIf name="cgi_host" eq="$blog_host"> |
|---|
| 140 | commenter_name = getCookie('commenter_name'); |
|---|
| 141 | commenter_url = getCookie('commenter_url'); |
|---|
| 142 | ids = getCookie('commenter_id').split(':'); |
|---|
| 143 | commenter_id = ids[0]; |
|---|
| 144 | if ( ids[1] == 'S' ) { |
|---|
| 145 | commenter_status = AUTHOR; |
|---|
| 146 | } |
|---|
| 147 | else if ( ids[1] == 'N' ) { |
|---|
| 148 | document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_status_js&blog_id=<$MTBlogID$>"></script>'); |
|---|
| 149 | } |
|---|
| 150 | else if ( commenter_name && !commenter_id ) { |
|---|
| 151 | commenter_status = COMMENTER; |
|---|
| 152 | } |
|---|
| 153 | else if ( commenter_name |
|---|
| 154 | && commenter_id |
|---|
| 155 | && ( ids[1].indexOf("'<$MTBlogID$>'") > -1 ) ) { |
|---|
| 156 | commenter_status = AUTHOR; |
|---|
| 157 | } |
|---|
| 158 | else { |
|---|
| 159 | commenter_status = 0; |
|---|
| 160 | } |
|---|
| 161 | <MTElse> |
|---|
| 162 | document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_name_js&blog_id=<$MTBlogID$>"></script>'); |
|---|
| 163 | </MTIf> |
|---|
| 164 | </MTIfRegistrationAllowed> |
|---|
| 165 | |
|---|
| 166 | function replyComment(parent_id, author) { |
|---|
| 167 | showDocumentElement('comment-form-reply'); |
|---|
| 168 | |
|---|
| 169 | var checkbox = document.getElementById('comment-reply'); |
|---|
| 170 | |
|---|
| 171 | // Clear the current label but NOT our checkbox! |
|---|
| 172 | var label = document.getElementById('comment-reply-label'); |
|---|
| 173 | for(var i = 1; i < label.childNodes.length; i++) { |
|---|
| 174 | label.removeChild(label.childNodes[i]); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | // Populate label with new values |
|---|
| 178 | var reply_text = document.createTextNode(' <__trans phrase="Replying to"> '); |
|---|
| 179 | label.appendChild(reply_text); |
|---|
| 180 | |
|---|
| 181 | var anchor = document.createElement('a'); |
|---|
| 182 | anchor.setAttribute('href', '#comment-' + parent_id); |
|---|
| 183 | anchor.innerHTML = author; |
|---|
| 184 | label.appendChild(anchor); |
|---|
| 185 | |
|---|
| 186 | checkbox.value = parent_id; |
|---|
| 187 | checkbox.setAttribute('checked', true); |
|---|
| 188 | checkbox.focus(); |
|---|
| 189 | |
|---|
| 190 | setCommentParentID(); |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | function setCommentParentID() { |
|---|
| 194 | var checkbox = document.getElementById('comment-reply'); |
|---|
| 195 | var parent_id_field = document.getElementById('comment-parent-id'); |
|---|
| 196 | var pid = 0; |
|---|
| 197 | |
|---|
| 198 | if(checkbox.checked == true) |
|---|
| 199 | pid = checkbox.value; |
|---|
| 200 | |
|---|
| 201 | parent_id_field.value = pid; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | // Copyright (c) 1996-1997 Athenia Associates. |
|---|
| 206 | // http://www.webreference.com/js/ |
|---|
| 207 | // License is granted if and only if this entire |
|---|
| 208 | // copyright notice is included. By Tomer Shiran. |
|---|
| 209 | |
|---|
| 210 | function setCookie (name, value, expires, path, domain, secure) { |
|---|
| 211 | var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires.toGMTString() : "") + |
|---|
| 212 | (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : ""); |
|---|
| 213 | document.cookie = curCookie; |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | function getCookie (name) { |
|---|
| 217 | var prefix = name + '='; |
|---|
| 218 | var c = document.cookie; |
|---|
| 219 | var nullstring = ''; |
|---|
| 220 | var cookieStartIndex = c.indexOf(prefix); |
|---|
| 221 | if (cookieStartIndex == -1) |
|---|
| 222 | return nullstring; |
|---|
| 223 | var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); |
|---|
| 224 | if (cookieEndIndex == -1) |
|---|
| 225 | cookieEndIndex = c.length; |
|---|
| 226 | return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | function deleteCookie (name, path, domain) { |
|---|
| 230 | if (getCookie(name)) |
|---|
| 231 | document.cookie = name + "=" + ((path) ? "; path=" + path : "") + |
|---|
| 232 | ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | function fixDate (date) { |
|---|
| 236 | var base = new Date(0); |
|---|
| 237 | var skew = base.getTime(); |
|---|
| 238 | if (skew > 0) |
|---|
| 239 | date.setTime(date.getTime() - skew); |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | function rememberMe (f) { |
|---|
| 243 | var now = new Date(); |
|---|
| 244 | fixDate(now); |
|---|
| 245 | now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); |
|---|
| 246 | if (f.author != undefined) |
|---|
| 247 | setCookie('mtcmtauth', f.author.value, now, '/', '', ''); |
|---|
| 248 | if (f.email != undefined) |
|---|
| 249 | setCookie('mtcmtmail', f.email.value, now, '/', '', ''); |
|---|
| 250 | if (f.url != undefined) |
|---|
| 251 | setCookie('mtcmthome', f.url.value, now, '/', '', ''); |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | function forgetMe (f) { |
|---|
| 255 | deleteCookie('mtcmtmail', '/', ''); |
|---|
| 256 | deleteCookie('mtcmthome', '/', ''); |
|---|
| 257 | deleteCookie('mtcmtauth', '/', ''); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | // BEGIN: fast browser onload init |
|---|
| 262 | // Modifications by David Davis, DWD |
|---|
| 263 | // Dean Edwards/Matthias Miller/John Resig |
|---|
| 264 | // http://dean.edwards.name/weblog/2006/06/again/?full#comment5338 |
|---|
| 265 | |
|---|
| 266 | function init() { |
|---|
| 267 | // quit if this function has already been called |
|---|
| 268 | if (arguments.callee.done) return; |
|---|
| 269 | |
|---|
| 270 | // flag this function so we don't do the same thing twice |
|---|
| 271 | arguments.callee.done = true; |
|---|
| 272 | |
|---|
| 273 | // kill the timer |
|---|
| 274 | // DWD - check against window |
|---|
| 275 | if ( window._timer ) clearInterval(window._timer); |
|---|
| 276 | |
|---|
| 277 | // DWD - fire the window onload now, and replace it |
|---|
| 278 | if ( window.onload && ( window.onload !== window.init ) ) { |
|---|
| 279 | window.onload(); |
|---|
| 280 | window.onload = function() {}; |
|---|
| 281 | } |
|---|
| 282 | }; |
|---|
| 283 | |
|---|
| 284 | /* for Mozilla/Opera9 */ |
|---|
| 285 | if (document.addEventListener) { |
|---|
| 286 | document.addEventListener("DOMContentLoaded", init, false); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | /* for Internet Explorer */ |
|---|
| 290 | /*@cc_on @*/ |
|---|
| 291 | /*@if (@_win32) |
|---|
| 292 | document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>"); |
|---|
| 293 | var script = document.getElementById("__ie_onload"); |
|---|
| 294 | script.onreadystatechange = function() { |
|---|
| 295 | if (this.readyState == "complete") { |
|---|
| 296 | init(); // call the onload handler |
|---|
| 297 | } |
|---|
| 298 | }; |
|---|
| 299 | /*@end @*/ |
|---|
| 300 | |
|---|
| 301 | /* for Safari */ |
|---|
| 302 | if (/WebKit/i.test(navigator.userAgent)) { // sniff |
|---|
| 303 | _timer = setInterval(function() { |
|---|
| 304 | if (/loaded|complete/.test(document.readyState)) { |
|---|
| 305 | init(); // call the onload handler |
|---|
| 306 | } |
|---|
| 307 | }, 10); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | /* for other browsers */ |
|---|
| 311 | window.onload = init; |
|---|
| 312 | |
|---|
| 313 | // END: fast browser onload init |
|---|
| 314 | |
|---|