Changeset 2393 for branches/release-38/default_templates/javascript.mtml
- Timestamp:
- 05/19/08 19:10:48 (19 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/release-38/default_templates/javascript.mtml
r2377 r2393 130 130 <mt:Ignore> 131 131 /*** 132 * Called when an input field on the comment form receives focus. 133 */ 134 </mt:Ignore> 135 function mtCommentFormOnFocus() { 136 // if CAPTCHA is enabled, this causes the captcha image to be 137 // displayed if it hasn't been already. 138 mtShowCaptcha(); 139 } 140 141 <mt:Ignore> 142 /*** 132 143 * Displays a captcha field for anonymous commenters. 133 144 */ … … 218 229 if (u.profile) str += "profile:'" + mtEscapeJS(u.profile) + "';"; 219 230 if (u.userpic) str += "userpic:'" + mtEscapeJS(u.userpic) + "';"; 231 if (u.sid) str += "sid:'" + mtEscapeJS(u.sid) + "';"; 220 232 str += "is_trusted:'" + (u.is_trusted ? "1" : "0") + "';"; 221 233 str += "is_author:'" + (u.is_author ? "1" : "0") + "';"; … … 238 250 var u = {}; 239 251 var m; 240 while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic| is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) {252 while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic|sid|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) { 241 253 s = s.substring(m[1].length); 242 254 if (m[2].match(/^(is|can)_/)) // boolean fields … … 286 298 */ 287 299 </mt:Ignore> 300 var mtFetchedUser = false; 288 301 function mtFetchUser(cb) { 289 302 if (!cb) cb = 'mtSetUser'; … … 296 309 // we aren't using AJAX for this, since we may have to request 297 310 // from a different domain. JSONP to the rescue. 311 mtFetchedUser = true; 298 312 var script = document.createElement('script'); 299 313 script.src = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=session_js&blog_id=<$mt:BlogID$>&jsonp=' + cb; … … 337 351 if (f.preview_button) f.preview_button.disabled = true; 338 352 if (f.post) f.post.disabled = true; 353 354 var u = mtGetUser(); 355 if ( !is_preview && ( u && u.is_authenticated ) ) { 356 // validate session; then submit 357 mtFetchedUser = false; 358 mtFetchUser('mtCommentSessionVerify'); 359 return false; 360 } 361 339 362 return true; 340 363 } 341 364 return false; 365 } 366 367 function mtCommentSessionVerify(app_user) { 368 var u = mtGetUser(); 369 var f = document['comments_form']; 370 if ( u && app_user && app_user.sid && ( u.sid == app_user.sid ) ) { 371 f.submit(); 372 } else { 373 alert('<__trans phrase="Your session has expired. Please sign in again to comment." escape="js">'); 374 mtClearUser(); 375 mtFireEvent('usersignin'); 376 <mt:IfRegistrationRequired> 377 mtShow('comments-form'); 378 mtHide('comments-open-footer'); 379 </mt:IfRegistrationRequired> 380 } 342 381 } 343 382 … … 377 416 if (cf.bakecookie) 378 417 cf.bakecookie.checked = u.name || u.email; 418 } else { 419 if (u && u.sid && cf.sid) 420 cf.sid.value = u.sid; 379 421 } 380 if (cf.post.disabled) {422 if (cf.post.disabled) 381 423 cf.post.disabled = false; 382 cf.post.value = '<__trans phrase="Submit">'; 383 } 384 if (cf.preview_button.disabled) { 424 if (cf.preview_button.disabled) 385 425 cf.preview_button.disabled = false; 386 cf.preview_button.value = '<__trans phrase="Preview">'; 387 } 426 mtRequestSubmitted = false; 388 427 } 389 428 } … … 478 517 var reg_reqd = <mt:IfRegistrationRequired>true<mt:Else>false</mt:IfRegistrationRequired>; 479 518 480 var cf = document .comments_form;519 var cf = document['comments_form']; 481 520 if (!cf) return; 482 521 … … 615 654 </mt:Ignore> 616 655 function mtClearUser() { 656 user = null; 617 657 mtDeleteCookie(mtCookieName, mtCookiePath, mtCookieDomain, 618 658 location.protocol == 'https:');
