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