| 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 commenter_name; |
|---|
| 31 | var commenter_blog_ids; |
|---|
| 32 | var is_preview; |
|---|
| 33 | var mtcmtmail; |
|---|
| 34 | var mtcmtauth; |
|---|
| 35 | var mtcmthome; |
|---|
| 36 | |
|---|
| 37 | function individualArchivesOnLoad(commenter_name) { |
|---|
| 38 | <MTIfCommentsAccepted> |
|---|
| 39 | <MTElse> |
|---|
| 40 | hideDocumentElement('comments-open'); |
|---|
| 41 | </MTIfCommentsAccepted> |
|---|
| 42 | <MTIfPingsAccepted> |
|---|
| 43 | <MTElse> |
|---|
| 44 | hideDocumentElement('trackbacks-info'); |
|---|
| 45 | </MTIfPingsAccepted> |
|---|
| 46 | <MTIfRegistrationAllowed> |
|---|
| 47 | <MTIfRegistrationRequired> |
|---|
| 48 | if ( commenter_name && |
|---|
| 49 | ( !commenter_id |
|---|
| 50 | || commenter_blog_ids.indexOf("'<$MTBlogID$>'") > -1)) |
|---|
| 51 | { |
|---|
| 52 | hideDocumentElement('comment-form-name'); |
|---|
| 53 | hideDocumentElement('comment-form-email'); |
|---|
| 54 | showDocumentElement('comments-open-text'); |
|---|
| 55 | showDocumentElement('comments-open-footer'); |
|---|
| 56 | } else { |
|---|
| 57 | hideDocumentElement('comments-open-data'); |
|---|
| 58 | hideDocumentElement('comments-open-text'); |
|---|
| 59 | hideDocumentElement('comments-open-footer'); |
|---|
| 60 | } |
|---|
| 61 | <MTElse> |
|---|
| 62 | // comments are allowed but registration not required |
|---|
| 63 | if ( commenter_name && |
|---|
| 64 | ( !commenter_id |
|---|
| 65 | || commenter_blog_ids.indexOf("'<$MTBlogID$>'") > -1)) |
|---|
| 66 | { |
|---|
| 67 | hideDocumentElement('comment-form-name'); |
|---|
| 68 | hideDocumentElement('comment-form-email'); |
|---|
| 69 | } else if (is_preview) { |
|---|
| 70 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 71 | delayShowCaptcha(); |
|---|
| 72 | </MTIfNonEmpty> |
|---|
| 73 | } else { |
|---|
| 74 | hideDocumentElement('comments-form'); |
|---|
| 75 | } |
|---|
| 76 | </MTIfRegistrationRequired> |
|---|
| 77 | </MTIfRegistrationAllowed> |
|---|
| 78 | |
|---|
| 79 | var cf = document.comments_form; |
|---|
| 80 | if (cf) { |
|---|
| 81 | if (!commenter_name && (cf.email != undefined) && |
|---|
| 82 | (mtcmtmail = getCookie("mtcmtmail"))) |
|---|
| 83 | cf.email.value = mtcmtmail; |
|---|
| 84 | if (!commenter_name && (cf.author != undefined) && |
|---|
| 85 | (mtcmtauth = getCookie("mtcmtauth"))) |
|---|
| 86 | cf.author.value = mtcmtauth; |
|---|
| 87 | if (cf.url != undefined && |
|---|
| 88 | (mtcmthome = getCookie("mtcmthome"))) |
|---|
| 89 | cf.url.value = mtcmthome; |
|---|
| 90 | if (cf["bakecookie"]) { |
|---|
| 91 | if (mtcmtauth || mtcmthome) { |
|---|
| 92 | cf.bakecookie.checked = true; |
|---|
| 93 | } else { |
|---|
| 94 | cf.bakecookie.checked = false; |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) { |
|---|
| 101 | <MTIfRegistrationAllowed> |
|---|
| 102 | if ( commenter_name && |
|---|
| 103 | ( !commenter_id |
|---|
| 104 | || commenter_blog_ids.indexOf("'" + blog_id + "'") > -1)) |
|---|
| 105 | { |
|---|
| 106 | var url; |
|---|
| 107 | if (commenter_id) { |
|---|
| 108 | url = '<$MTCGIPath$><$MTCommentScript$>?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=' + blog_id; |
|---|
| 109 | if (entry_id) { |
|---|
| 110 | url += '&entry_id=' + entry_id; |
|---|
| 111 | } else { |
|---|
| 112 | url += '&static=1'; |
|---|
| 113 | } |
|---|
| 114 | } else if (commenter_url) { |
|---|
| 115 | url = commenter_url; |
|---|
| 116 | } else { |
|---|
| 117 | url = null; |
|---|
| 118 | } |
|---|
| 119 | var content = '<__trans phrase="Thanks for signing in," escape="js"> '; |
|---|
| 120 | if (url) { |
|---|
| 121 | content += '<a href="' + url + '">' + commenter_name + '</a>'; |
|---|
| 122 | } else { |
|---|
| 123 | content += commenter_name; |
|---|
| 124 | } |
|---|
| 125 | content += '<__trans phrase=". Now you can comment." escape="js"> (<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '"><__trans phrase="sign out" escape="js"></a>)'; |
|---|
| 126 | document.write(content); |
|---|
| 127 | } else if (commenter_name) { |
|---|
| 128 | document.write('<__trans phrase="You do not have permission to comment on this blog." escape="js"> (<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '"><__trans phrase="sign out" escape="js"></a>)'); |
|---|
| 129 | } else { |
|---|
| 130 | <MTIfRegistrationRequired> |
|---|
| 131 | document.write('<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1"><__trans phrase="Sign in" escape="js">' + '</a>' + '<__trans phrase=" to comment on this entry." escape="js">'); |
|---|
| 132 | <MTElse> |
|---|
| 133 | document.write('<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1"><__trans phrase="Sign in" escape="js">' + '</a>' + '<__trans phrase=" to comment on this entry," escape="js"> <__trans phrase="or " escape="js"><a href="javascript:void(0);" onclick="showAnonymousForm();"><__trans phrase="comment anonymously." escape="js"></a>'); |
|---|
| 134 | </MTIfRegistrationRequired> |
|---|
| 135 | } |
|---|
| 136 | </MTIfRegistrationAllowed> |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | <MTIfRegistrationAllowed> |
|---|
| 140 | <MTsetvarblock name="cgi_host"><$MTCGIHost exclude_port="1"></MTsetvarblock> |
|---|
| 141 | <MTIf tag="MTBlogHost" exclude_port="1" eq="cgi_host"> |
|---|
| 142 | commenter_name = getCookie('commenter_name'); |
|---|
| 143 | ids = getCookie('commenter_id').split(':'); |
|---|
| 144 | commenter_id = ids[0]; |
|---|
| 145 | commenter_blog_ids = ids[1]; |
|---|
| 146 | commenter_url = getCookie('commenter_url'); |
|---|
| 147 | <MTelse> |
|---|
| 148 | document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_name_js&blog_id=<$MTBlogID$>"></script>'); |
|---|
| 149 | </MTIf> |
|---|
| 150 | </MTIfRegistrationAllowed> |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | // Copyright (c) 1996-1997 Athenia Associates. |
|---|
| 154 | // http://www.webreference.com/js/ |
|---|
| 155 | // License is granted if and only if this entire |
|---|
| 156 | // copyright notice is included. By Tomer Shiran. |
|---|
| 157 | |
|---|
| 158 | function setCookie (name, value, expires, path, domain, secure) { |
|---|
| 159 | var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires.toGMTString() : "") + |
|---|
| 160 | (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : ""); |
|---|
| 161 | document.cookie = curCookie; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | function getCookie (name) { |
|---|
| 165 | var prefix = name + '='; |
|---|
| 166 | var c = document.cookie; |
|---|
| 167 | var nullstring = ''; |
|---|
| 168 | var cookieStartIndex = c.indexOf(prefix); |
|---|
| 169 | if (cookieStartIndex == -1) |
|---|
| 170 | return nullstring; |
|---|
| 171 | var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); |
|---|
| 172 | if (cookieEndIndex == -1) |
|---|
| 173 | cookieEndIndex = c.length; |
|---|
| 174 | return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | function deleteCookie (name, path, domain) { |
|---|
| 178 | if (getCookie(name)) |
|---|
| 179 | document.cookie = name + "=" + ((path) ? "; path=" + path : "") + |
|---|
| 180 | ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | function fixDate (date) { |
|---|
| 184 | var base = new Date(0); |
|---|
| 185 | var skew = base.getTime(); |
|---|
| 186 | if (skew > 0) |
|---|
| 187 | date.setTime(date.getTime() - skew); |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | function rememberMe (f) { |
|---|
| 191 | var now = new Date(); |
|---|
| 192 | fixDate(now); |
|---|
| 193 | now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); |
|---|
| 194 | now = now.toGMTString(); |
|---|
| 195 | if (f.author != undefined) |
|---|
| 196 | setCookie('mtcmtauth', f.author.value, now, '/', '', ''); |
|---|
| 197 | if (f.email != undefined) |
|---|
| 198 | setCookie('mtcmtmail', f.email.value, now, '/', '', ''); |
|---|
| 199 | if (f.url != undefined) |
|---|
| 200 | setCookie('mtcmthome', f.url.value, now, '/', '', ''); |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | function forgetMe (f) { |
|---|
| 204 | deleteCookie('mtcmtmail', '/', ''); |
|---|
| 205 | deleteCookie('mtcmthome', '/', ''); |
|---|
| 206 | deleteCookie('mtcmtauth', '/', ''); |
|---|
| 207 | f.email.value = ''; |
|---|
| 208 | f.author.value = ''; |
|---|
| 209 | f.url.value = ''; |
|---|
| 210 | } |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | // BEGIN: fast browser onload init |
|---|
| 214 | // Modificaitons by David Davis, DWD |
|---|
| 215 | // Dean Edwards/Matthias Miller/John Resig |
|---|
| 216 | // http://dean.edwards.name/weblog/2006/06/again/?full#comment5338 |
|---|
| 217 | |
|---|
| 218 | function init() { |
|---|
| 219 | // quit if this function has already been called |
|---|
| 220 | if (arguments.callee.done) return; |
|---|
| 221 | |
|---|
| 222 | // flag this function so we don't do the same thing twice |
|---|
| 223 | arguments.callee.done = true; |
|---|
| 224 | |
|---|
| 225 | // kill the timer |
|---|
| 226 | // DWD - check against window |
|---|
| 227 | if ( window._timer ) clearInterval(window._timer); |
|---|
| 228 | |
|---|
| 229 | // DWD - fire the window onload now, and replace it |
|---|
| 230 | if ( window.onload && ( window.onload !== window.init ) ) { |
|---|
| 231 | window.onload(); |
|---|
| 232 | window.onload = function() {}; |
|---|
| 233 | } |
|---|
| 234 | }; |
|---|
| 235 | |
|---|
| 236 | /* for Mozilla/Opera9 */ |
|---|
| 237 | if (document.addEventListener) { |
|---|
| 238 | document.addEventListener("DOMContentLoaded", init, false); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | /* for Internet Explorer */ |
|---|
| 242 | /*@cc_on @*/ |
|---|
| 243 | /*@if (@_win32) |
|---|
| 244 | document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>"); |
|---|
| 245 | var script = document.getElementById("__ie_onload"); |
|---|
| 246 | script.onreadystatechange = function() { |
|---|
| 247 | if (this.readyState == "complete") { |
|---|
| 248 | init(); // call the onload handler |
|---|
| 249 | } |
|---|
| 250 | }; |
|---|
| 251 | /*@end @*/ |
|---|
| 252 | |
|---|
| 253 | /* for Safari */ |
|---|
| 254 | if (/WebKit/i.test(navigator.userAgent)) { // sniff |
|---|
| 255 | _timer = setInterval(function() { |
|---|
| 256 | if (/loaded|complete/.test(document.readyState)) { |
|---|
| 257 | init(); // call the onload handler |
|---|
| 258 | } |
|---|
| 259 | }, 10); |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | /* for other browsers */ |
|---|
| 263 | window.onload = init; |
|---|
| 264 | |
|---|
| 265 | // END: fast browser onload init |
|---|
| 266 | |
|---|