| 1 | |
|---|
| 2 | function hideDocumentElement(id) { |
|---|
| 3 | var el = document.getElementById(id); |
|---|
| 4 | if (el) el.style.display = 'none'; |
|---|
| 5 | } |
|---|
| 6 | |
|---|
| 7 | function showDocumentElement(id) { |
|---|
| 8 | var el = document.getElementById(id); |
|---|
| 9 | if (el) el.style.display = 'block'; |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | function showAnonymousForm() { |
|---|
| 13 | showDocumentElement('comments-form'); |
|---|
| 14 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 15 | captcha_timer = setInterval('delayShowCaptcha()', 1000); |
|---|
| 16 | </MTIfNonEmpty> |
|---|
| 17 | } |
|---|
| 18 | <MTIfNonEmpty tag="MTCaptchaFields"> |
|---|
| 19 | var captcha_timer; |
|---|
| 20 | function delayShowCaptcha() { |
|---|
| 21 | clearInterval(captcha_timer); |
|---|
| 22 | var div = document.getElementById('comments-open-captcha'); |
|---|
| 23 | if (div) { |
|---|
| 24 | div.innerHTML = '<$MTCaptchaFields$>'; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | </MTIfNonEmpty> |
|---|
| 28 | |
|---|
| 29 | var commenter_name; |
|---|
| 30 | var commenter_blog_ids; |
|---|
| 31 | var is_preview; |
|---|
| 32 | var mtcmtmail; |
|---|
| 33 | var mtcmtauth; |
|---|
| 34 | var mtcmthome; |
|---|
| 35 | |
|---|
| 36 | function individualArchivesOnLoad(commenter_name) { |
|---|
| 37 | <MTIfCommentsAccepted> |
|---|
| 38 | <MTElse> |
|---|
| 39 | hideDocumentElement('comments-open'); |
|---|
| 40 | </MTIfCommentsAccepted> |
|---|
| 41 | <MTIfPingsAccepted> |
|---|
| 42 | <MTElse> |
|---|
| 43 | hideDocumentElement('trackbacks-info'); |
|---|
| 44 | </MTIfPingsAccepted> |
|---|
| 45 | <MTIfRegistrationAllowed> |
|---|
| 46 | <MTIfRegistrationRequired> |
|---|
| 47 | if ( commenter_name && |
|---|
| 48 | ( !commenter_id |
|---|
| 49 | || commenter_blog_ids.indexOf("'<$MTBlogID$>'") > -1)) |
|---|
| 50 | { |
|---|
| 51 | hideDocumentElement('comment-form-name'); |
|---|
| 52 | hideDocumentElement('comment-form-email'); |
|---|
| 53 | showDocumentElement('comments-open-text'); |
|---|
| 54 | showDocumentElement('comments-open-footer'); |
|---|
| 55 | } else { |
|---|
| 56 | hideDocumentElement('comments-open-data'); |
|---|
| 57 | hideDocumentElement('comments-open-text'); |
|---|
| 58 | hideDocumentElement('comments-open-footer'); |
|---|
| 59 | } |
|---|
| 60 | <MTElse> |
|---|
| 61 | // comments are allowed but registration not required |
|---|
| 62 | if ( commenter_name && |
|---|
| 63 | ( !commenter_id |
|---|
| 64 | || commenter_blog_ids.indexOf("'<$MTBlogID$>'") > -1)) |
|---|
| 65 | { |
|---|
| 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 | if (document.comments_form) { |
|---|
| 79 | if (!commenter_name && (document.comments_form.email != undefined) && |
|---|
| 80 | (mtcmtmail = getCookie("mtcmtmail"))) |
|---|
| 81 | document.comments_form.email.value = mtcmtmail; |
|---|
| 82 | if (!commenter_name && (document.comments_form.author != undefined) && |
|---|
| 83 | (mtcmtauth = getCookie("mtcmtauth"))) |
|---|
| 84 | document.comments_form.author.value = mtcmtauth; |
|---|
| 85 | if (document.comments_form.url != undefined && |
|---|
| 86 | (mtcmthome = getCookie("mtcmthome"))) |
|---|
| 87 | document.comments_form.url.value = mtcmthome; |
|---|
| 88 | if (document.comments_form["bakecookie"]) { |
|---|
| 89 | if (mtcmtauth || mtcmthome) { |
|---|
| 90 | document.comments_form.bakecookie.checked = true; |
|---|
| 91 | } else { |
|---|
| 92 | document.comments_form.bakecookie.checked = false; |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) { |
|---|
| 99 | <MTIfRegistrationAllowed> |
|---|
| 100 | if ( commenter_name && |
|---|
| 101 | ( !commenter_id |
|---|
| 102 | || commenter_blog_ids.indexOf("'" + blog_id + "'") > -1)) |
|---|
| 103 | { |
|---|
| 104 | var url; |
|---|
| 105 | if (commenter_id) { |
|---|
| 106 | url = '<$MTCGIPath$><$MTCommentScript$>?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=' + blog_id; |
|---|
| 107 | if (entry_id) { |
|---|
| 108 | url += '&entry_id=' + entry_id; |
|---|
| 109 | } else { |
|---|
| 110 | url += '&static=1'; |
|---|
| 111 | } |
|---|
| 112 | } else if (commenter_url) { |
|---|
| 113 | url = commenter_url; |
|---|
| 114 | } else { |
|---|
| 115 | url = null; |
|---|
| 116 | } |
|---|
| 117 | var content = '<__trans phrase="Thanks for signing in," escape="js"> '; |
|---|
| 118 | if (url) { |
|---|
| 119 | content += '<a href="' + url + '">' + commenter_name + '</a>'; |
|---|
| 120 | } else { |
|---|
| 121 | content += commenter_name; |
|---|
| 122 | } |
|---|
| 123 | 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>)'; |
|---|
| 124 | document.write(content); |
|---|
| 125 | } else if (commenter_name) { |
|---|
| 126 | 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>)'); |
|---|
| 127 | } else { |
|---|
| 128 | <MTIfRegistrationRequired> |
|---|
| 129 | 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">'); |
|---|
| 130 | <MTElse> |
|---|
| 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"> <__trans phrase="or " escape="js"><a href="javascript:void(0);" onclick="showAnonymousForm();"><__trans phrase="comment anonymously." escape="js"></a>'); |
|---|
| 132 | </MTIfRegistrationRequired> |
|---|
| 133 | } |
|---|
| 134 | </MTIfRegistrationAllowed> |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | <MTIfRegistrationAllowed> |
|---|
| 138 | if ('<$MTCGIHost exclude_port="1"$>' != '<$MTBlogHost exclude_port="1"$>') { |
|---|
| 139 | document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_name_js&blog_id=<$MTBlogID$>"></script>'); |
|---|
| 140 | } else { |
|---|
| 141 | commenter_name = getCookie('commenter_name'); |
|---|
| 142 | ids = getCookie('commenter_id').split(':'); |
|---|
| 143 | commenter_id = ids[0]; |
|---|
| 144 | commenter_blog_ids = ids[1]; |
|---|
| 145 | commenter_url = getCookie('commenter_url'); |
|---|
| 146 | } |
|---|
| 147 | </MTIfRegistrationAllowed> |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | // Copyright (c) 1996-1997 Athenia Associates. |
|---|
| 151 | // http://www.webreference.com/js/ |
|---|
| 152 | // License is granted if and only if this entire |
|---|
| 153 | // copyright notice is included. By Tomer Shiran. |
|---|
| 154 | |
|---|
| 155 | function setCookie (name, value, expires, path, domain, secure) { |
|---|
| 156 | var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires.toGMTString() : "") + |
|---|
| 157 | (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : ""); |
|---|
| 158 | document.cookie = curCookie; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | function getCookie (name) { |
|---|
| 162 | var prefix = name + '='; |
|---|
| 163 | var c = document.cookie; |
|---|
| 164 | var nullstring = ''; |
|---|
| 165 | var cookieStartIndex = c.indexOf(prefix); |
|---|
| 166 | if (cookieStartIndex == -1) |
|---|
| 167 | return nullstring; |
|---|
| 168 | var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); |
|---|
| 169 | if (cookieEndIndex == -1) |
|---|
| 170 | cookieEndIndex = c.length; |
|---|
| 171 | return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | function deleteCookie (name, path, domain) { |
|---|
| 175 | if (getCookie(name)) |
|---|
| 176 | document.cookie = name + "=" + ((path) ? "; path=" + path : "") + |
|---|
| 177 | ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | function fixDate (date) { |
|---|
| 181 | var base = new Date(0); |
|---|
| 182 | var skew = base.getTime(); |
|---|
| 183 | if (skew > 0) |
|---|
| 184 | date.setTime(date.getTime() - skew); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | function rememberMe (f) { |
|---|
| 188 | var now = new Date(); |
|---|
| 189 | fixDate(now); |
|---|
| 190 | now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); |
|---|
| 191 | now = now.toGMTString(); |
|---|
| 192 | if (f.author != undefined) |
|---|
| 193 | setCookie('mtcmtauth', f.author.value, now, '/', '', ''); |
|---|
| 194 | if (f.email != undefined) |
|---|
| 195 | setCookie('mtcmtmail', f.email.value, now, '/', '', ''); |
|---|
| 196 | if (f.url != undefined) |
|---|
| 197 | setCookie('mtcmthome', f.url.value, now, '/', '', ''); |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | function forgetMe (f) { |
|---|
| 201 | deleteCookie('mtcmtmail', '/', ''); |
|---|
| 202 | deleteCookie('mtcmthome', '/', ''); |
|---|
| 203 | deleteCookie('mtcmtauth', '/', ''); |
|---|
| 204 | f.email.value = ''; |
|---|
| 205 | f.author.value = ''; |
|---|
| 206 | f.url.value = ''; |
|---|
| 207 | } |
|---|
| 208 | |
|---|