1var AJAX_GEO_URL = '/ajax/geo_selects.html'; 2var AJAX_CAPTCHA_URL = '/ajax/captcha.html'; 3 4Object.extend(Prototype.Browser, { 5 IE7: (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ? (Number(RegExp.$1) == 7 ? true : false) : false, 6 IE8: (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ? (Number(RegExp.$1) == 8 ? true : false) : false, 7 IE9: (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ? (Number(RegExp.$1) == 9 ? true : false) : false 8}); 9 10document.observe("dom:loaded", function() { 11 12 if ( $('notification-container') ) { 13 new Ajax.PeriodicalUpdater('notification-container', '/ajax/users/notification.html', { evalScripts: true, frequency: 10, method: 'get' } ); 14 } 15 16 $$('.copy_button').each(function(el) { 17 var id = $(el).identify().replace('clip_button_', ''); 18 var text = $(el).href; 19 var clipboard = new ZeroClipboard.Client(); 20 clipboard.setText(text); 21 clipboard.glue( 'clip_button_' + id, 'clip_cont_' + id ); 22 clipboard.setHandCursor( true ); 23 clipboard.addEventListener( 'onMouseOver', function() { 24 $('item-' + id).addClassName('b-article-part-hover'); 25 } ); 26 clipboard.addEventListener( 'onMouseOut', function() { 27 $('item-' + id).removeClassName('b-article-part-hover'); 28 } ); 29 }); 30 31 if ( Cookies.get('from_social_nw') ) { 32 $('overlay').show(); 33 $$('html').first().addClassName('lightbox-mode'); 34 35 $('popup-overlayed-container').update('<span class="g-loading"></span>'); 36 new Ajax.Updater('popup-overlayed-container', '/ajax/popup/social-welcome.html', { 37 method: 'get', evalScripts: true, 38 onSuccess: function() { 39 $('overlay').addClassName('b-social-welcome'); 40 if ( Cookies.get('from_social_nw') == 'tw' ) { 41 $('overlay').addClassName('b-social-welcome_tw'); 42 } 43 else if ( Cookies.get('from_social_nw') == 'ok' ) { 44 $('overlay').addClassName('b-social-welcome_ok'); 45 } 46 Cookies.erase('from_social_nw'); 47 } 48 }); 49 } 50 51 if ( !isMoscowRegion ) { 52 if ( Cookies.get('from_digitalium_ru') == 1 ) { 53 Cookies.set('from_digitalium_ru', 2, 90000); 54 55 $('overlay').show(); 56 $$('html').first().addClassName('lightbox-mode'); 57 58 $('popup-overlayed-container').update('<span class="g-loading"></span>'); 59 new Ajax.Updater('popup-overlayed-container', '/ajax/social.html', { 60 method: 'get', evalScripts: true 61 }); 62 } 63 else if ( /infoburn\.ru/i.test(document.referrer) ) {
64 if ( !Cookies.get('from_digitalium_ru') ) 65 Cookies.set('from_digitalium_ru', 1, 90000); 66 } 67 } 68 69 if (window.PIE) { 70 $$('.g-button, .p-russia-1990 .l-content, .b-brands-city_inner, .b-brands-dish_pic, .b-brands-cities_pic').each(function (obj) { 71 PIE.attach(obj); 72 }); 73 } 74 75 if (Prototype.Browser.IE9) { 76 $$('html').first().addClassName('ie9'); 77 } 78 79 if( $('attach-uploader') ) { 80 createUploader(true, 'attach-uploader', 'upload_attach'); 81 } 82 83 $$('.b-media-all')[0] 84 .observe('click', function() { 85 var item = $$('.b-media-all').first(); 86 if ( item.hasClassName('on') ) { 87 $('new-articles-container').addClassName('g-hidden'); 88 item.removeClassName('on'); 89 } 90 else { 91 $('new-articles-container').removeClassName('g-hidden'); 92 item.addClassName('on'); 93 } 94 } ); 95 96// if ( $('life-on-site') ) { 97// new Ajax.PeriodicalUpdater('life-on-site', '/ajax/index/life_on_site.html', { method: 'get', evalScripts: true, frequency: 30 } ); 98// } 99 100 if ( $('feature-block') ) { 101 new Ajax.PeriodicalUpdater('feature-block', '/ajax/index/feature.html', { method: 'get', evalScripts: true, frequency: 60 } ); 102 } 103 104 $$('.b-submenu-name').each(function(el) { 105 var span = $(el).firstChild; 106 $(el).up('.b-submenu').setStyle({'display':'block'}); 107 if ( span.getHeight() > 63 ) { 108 $(el).setStyle({'fontSize': '14px', 'lineHeight': '16px'}); 109 } 110 $(el).up('.b-submenu').setStyle({'display':''}); 111 }); 112 113 $$('a.smooth-scroll').invoke('observe', 'click', function(event) { 114 event.stop(); 115 116 var element = event.element(); 117 if ( !element.hasClassName('smooth-scroll') ) element = element.up('a.smooth-scroll'); 118 119 var href = element.readAttribute('href'); 120 var scrollHere = href.substr(href.indexOf('#')+1, href.length); 121 122 if ( !$(scrollHere) ) return false; 123 124 Effect.ScrollTo(scrollHere); 125 126 return false; 127 }); 128 129 if ( $$('.l-header .b-specprojects .b-specprojects-list a').length > 1 ) { 130 new Carousel($$('.b-specprojects .b-specprojects-list')[0], $$('.b-specprojects .b-specprojects-list')[0], $$('.b-specprojects-control'), { 131 wheel: false, circular: true, visibleSlides: 1, scrollSlides: 1, duration: 1, frequency: 5, effect: 'morfing', auto: true, 132 controlClassName: 'b-specprojects-control', prev: $$('.b-specprojects .b-specprojects-control.left')[0], 133 next: $$('b-specprojects b-specprojects-control.right')[0] 134 }); 135 } 136 137 if ( $$('.l-header .b-header-special-banners a').length > 1 ) { 138 new Carousel($$('.l-header .b-header-special-banners')[0], $$('.l-header .b-header-special-banners')[0], null, { 139 wheel: false, circular: true, visibleSlides: 1, scrollSlides: 1, duration: 1, frequency: 5, effect: 'morfing', auto: true 140 }); 141 } 142 143 initTooltips(); 144 145 if ( /most-readed-by-week/.exec(window.location.hash) ) { 146 var ids = window.location.hash.length > 21 ? window.location.hash.substring(21) : ''; 147 toggleIndexMostReadedList('weekly', ids); 148 Effect.ScrollTo($('most-readed')); 149 } 150 else if ( /most-readed-by-month/.exec(window.location.hash) ) { 151 var ids = window.location.hash.length > 22 ? window.location.hash.substring(22) : ''; 152 toggleIndexMostReadedList('monthly', ids); 153 Effect.ScrollTo($('most-readed')); 154 } 155}); 156 157function closeNotification(mId) { 158 if ( $('notification-container') ) { 159 new Ajax.Updater('notification-container', '/ajax/users/notification.html', { evalScripts: true, frequency: 10, parameters: { 'message_id': mId }, method: 'post' } ); 160 } 161 return false; 162} 163 164document.onkeydown = catchKey; 165function catchKey(event) 166{ 167 if($('paging_control_next') || $('paging_control_previous')) { 168 if (window.event) 169 event = window.event; 170 if (event.ctrlKey) { 171 switch (event.keyCode ? event.keyCode : event.which ? event.which : null) { 172 case 39: 173 if( $('paging_control_next') ) { 174 if($('paging_control_next').onclick) 175 $('paging_control_next').onclick(); 176 else 177 if($('paging_control_next').href) { 178 location.href = $('paging_control_next').href; 179 } 180 } 181 break; 182 case 37: 183 if( $('paging_control_previous') ) { 184 if($('paging_control_previous').onclick) 185 $('paging_control_previous').onclick(); 186 else 187 if($('paging_control_previous').href) { 188 location.href = $('paging_control_previous').href; 189 } 190 } 191 break; 192 } 193 } 194 } 195} 196 197var AuthImage = new Class.create(); 198AuthImage.prototype = { 199 initialize: function(auth_img_div, auth_img_link){ 200 this.auth_img_div = $(auth_img_div); 201 this.auth_img_link = $(auth_img_link); 202 this.auth_img_link.onclick = this.get.bindAsEventListener(this); 203 this.get(); 204 }, 205 get: function(e){ 206 new Ajax.Updater( 207 this.auth_img_div, 208 AJAX_CAPTCHA_URL 209 ); 210 } 211}; 212 213/* cookies funcs */ 214 215var Cookies = { 216 set: function(cookieName, cookieContent, cookieExpireTime){ 217 if (cookieExpireTime>0){ 218 var expDate=new Date(); 219 expDate.setTime(expDate.getTime()+cookieExpireTime*1000*60*60); 220 var expires=expDate.toGMTString(); 221 document.cookie=cookieName+"="+escape(cookieContent)+"; path="+escape('/')+"; expires="+expires 222 }else{ 223 document.cookie=cookieName+"="+escape(cookieContent)+"; path="+escape('/')+""; 224 } 225 }, 226 get: function(cookieName){ 227 var ourCookie=document.cookie; 228 if (!ourCookie || ourCookie=="")return ""; 229 ourCookie=ourCookie.split(";"); 230 var i=0; 231 var Cookie; 232 while (i<ourCookie.length){ 233 Cookie=ourCookie[i].split("=")[0]; 234 if (Cookie.charAt(0)==" ") Cookie=Cookie.substring(1);
235 if (Cookie==cookieName) return unescape(ourCookie[i].split("=")[1]); 236 i++; 237 } 238 return ""; 239 }, 240 erase: function(cookieName){ 241 var cookie = Cookies.get(cookieName) || true; 242 Cookies.set(cookieName, '', -1); 243 return cookie; 244 }, 245 accept: function(){ 246 if (typeof navigator.cookieEnabled == 'boolean') return navigator.cookieEnabled; 247 Cookies.set('_test', '1'); 248 return (Cookies.erase('_test') = '1'); 249 } 250} 251 252var found = document.referrer.match(/\/\/([^\/]+)\//); 253if ( found && found.length > 0 ) { 254 var currentDomain = document.domain; 255 currentDomain = currentDomain.replace(/\./g, "\\."); 256 if ( !new RegExp(currentDomain, 'i').test(found[1]) ) { 257 Cookies.set('external_referer', found[1], 90000); 258 } 259} 260 261 262function doFavouritesAction(objId, pos) { 263 new Ajax.Updater('favourite-' + pos, '/ajax/favourite.html', { 264 parameters: { 'action': 'like', 'obj_id': objId, 'position': pos }, 265 onComplete: function(response) { 266 if ( 200 == response.status ) { 267 pos = pos == 'top' ? 'bottom' : 'top'; 268 new Ajax.Updater('favourite-' + pos, '/ajax/favourite.html', { 269 parameters: { 'obj_id': objId, 'position': pos } 270 }); 271 } 272 } 273 }); 274 275 return false; 276} 277 278function doUserSubscribeAction(userId) { 279 new Ajax.Updater('subscribe_block', '/ajax/users/subscribe.html', { 280 parameters: { 281 'action': 'subscribe', 282 'user_id': userId 283 } 284 }); 285 286 return false; 287} 288 289function showItemOpinion(objId, objClass, itemId) { 290 $$('html').first().addClassName('lightbox-mode'); 291 292 $('overlay').appear({ duration: 0.4, from: 0, to: 1, afterFinish: function() { 293 $('popup-overlayed-container').update('<span class="g-loading"></span>'); 294 new Ajax.Updater('popup-overlayed-container', '/ajax/opinion.html', { 295 parameters: { 296 'item_id': itemId, 297 obj_id: objId, obj_class: objClass 298 }, 299 evalScripts: true 300 }); 301 } }); 302 303 return false; 304} 305 306function updateItemComments(objId, objClass, itemId, p, expand) { 307 new Ajax.Updater('opinion-comments-' + itemId, '/ajax/comment/comments.html', { 308 parameters: { 309 'item_id': itemId, 'p': p, 'expand': expand, 310 obj_id: objId, obj_class: objClass 311 } 312 }); 313 314 return false; 315} 316 317function addItemComment(objId, objClass, itemId, p) { 318 new Ajax.Updater('opinion-comments-' + itemId, '/ajax/comment/comments.html', { 319 parameters: { 320 'item_id': itemId, 321 obj_id: objId, obj_class: objClass, 322 'p': p, 323 'body': $('tem_comment_body').value, 324 'action': 'add_comment', 325 'control_charset': $('control_charset').value 326 }, 327 evalScripts: true 328 }); 329 330 return false; 331} 332 333function closePopup() { 334 $('popup-overlayed-container').update(''); 335 $('overlay').fade({ duration: 0.4, from: 1, to: 0, afterFinish: function() { 336 $$('html').first().removeClassName('lightbox-mode'); 337 $('overlay').removeClassName('b-social-welcome_tw'); 338 $('overlay').removeClassName('b-social-welcome'); 339 }}); 340 341 return false; 342} 343 344function changePopupBigPhoto(action, event) { 345 var current = $$('.photo_active')[0]; 346 var newItem; 347 348 if ( action == 'left' ) { 349 newItem = current.previous(0); 350 if ( !newItem ) { 351 newItem = $('popup_gallery').children[$('popup_gallery').children.length-1]; 352 } 353 } 354 if ( action == 'right' ) { 355 newItem = current.next(0); 356 if ( !newItem ) { 357 newItem = $('popup_gallery').children[0]; 358 } 359 } 360 361 if ( newItem ) { 362 newItem.removeClassName('g-hidden'); 363 newItem.addClassName('photo_active'); 364 365 current.addClassName('g-hidden'); 366 current.removeClassName('photo_active'); 367 368// $$('.b-box-gallery-preview-list li').invoke('removeClassName', 'active'); 369// var id = newItem.identify(); 370// $('gallery_preview_' + id.substring(14, id.length)).addClassName('active'); 371 } 372 373 Event.stop(event); 374} 375 376function showBigPhoto(group) { 377 var current = $$('.photo_active')[0]; 378 379 current.addClassName('g-hidden'); 380 current.removeClassName('photo_active'); 381 382 $('gallery_photo_' + group).removeClassName('g-hidden'); 383 $('gallery_photo_' + group).addClassName('photo_active'); 384 385 $$('.b-box-gallery-preview-list li').invoke('removeClassName', 'active'); 386 $('gallery_preview_' + group).addClassName('active'); 387} 388 389function updateUserSubscribes(userId, p) {
390 new Ajax.Updater('user_subscribers', '/ajax/users/subscribes.html', { 391 parameters: { 392 'user_id': userId, 393 'p': p 394 } 395 }); 396 397 return false; 398} 399 400function updateUserMaterials(userId, p) { 401 new Ajax.Updater('user_materials', '/ajax/users/materials.html', { 402 parameters: { 403 'user_id': userId, 404 'p': p 405 } 406 }); 407 408 return false; 409} 410 411function updateProfileActivity(el, userId, action) { 412 var type = ''; 413 414 if ( !$(el).hasClassName('active') ) { 415 type = action; 416 } 417 new Ajax.Updater('user_activity', '/ajax/users/activity.html', { 418 parameters: { 419 'user_id': userId, 420 'type': type 421 }, 422 onSuccess: function(response) { 423 if ( type ) { 424 $(el).addClassName('active'); 425 } 426 else { 427 $(el).removeClassName('active'); 428 } 429 }, 430 evalScripts: true 431 }); 432 433 return false; 434} 435 436function updateUserActivity(userId, type, p) { 437 new Ajax.Updater('user_activity', '/ajax/users/activity.html', { 438 parameters: { 439 'user_id': userId, 440 'type': type, 441 'p': p 442 } 443 }); 444 445 return false; 446} 447 448 449function showCreateItemForm(objId) { 450 $$('html').first().addClassName('lightbox-mode'); 451 452 $('overlay').appear({ duration: 0.4, from: 0, to: 1, afterFinish: function() { 453 $('popup-overlayed-container').update('<span class="g-loading"></span>'); 454 new Ajax.Updater('popup-overlayed-container', '/ajax/create.html', { 455 parameters: { 456 id: objId 457 }, 458 method: 'get', 459 evalScripts: true 460 }); 461 } }); 462 463 return false; 464} 465 466function changeNewItemType(el, type, objId) { 467 new Ajax.Updater('create_form', '/ajax/items/item.html', { 468 parameters: { 469 type: type, 470 id: objId 471 }, 472 method: 'get', 473 evalScripts: true 474 }); 475 476 return false; 477} 478 479var createItemInProcess = false; 480function submitCreateItemFrom() { 481 if ( createItemInProcess ) { 482 return false; 483 } 484 485 createItemInProcess = true; 486 new Ajax.Updater('create_form', '/ajax/items/item.html', { 487 parameters: $('create_item_form').serialize(true), 488 evalScripts: true, 489 onComplete: function(response) { 490 createItemInProcess = true; 491 } 492 }); 493 494 return false; 495} 496 497function createUploader(contId, prefix) { 498 if ( !prefix ) { 499 prefix = ''; 500 } 501 var uploader = new qq.FileUploader({ 502 element: document.getElementById(contId), 503 title: "Äîáàâèòü ôîòî", 504 action: '/ajax/items/photo_store.html', 505 multyFiles: true, 506 multiple: true, 507 template: '<div class="qq-uploader">' + 508 '<div class="qq-upload-drop-area"></div>' + 509 '<a class="qq-upload-button b-upload-placeholder">Äîáàâèòü ôîòî</a>' + 510 '<ul class="qq-upload-list"></ul>' + 511 '</div>', 512 params: { 513 action: 'add_photo', 514 debug: true, 515 control_charset: $('control_charset').value }, 516 onComplete: function(id, fileName, responseJSON){ 517 $(prefix + 'attachments').appendChild(new Element('li', { 'class': 'b-upload-item'}).update( 518 ' <div class="b-upload-item-preview"> ' + 519 ' <img src="' + responseJSON.filepath + responseJSON.preview + '" width="194" height="144" alt=""> ' + 520 ' <span class="b-upload-item-remove" onclick="return removeAttachment(this, \'' + responseJSON.filename + '\', \'' + responseJSON.preview + '\', \'' + prefix + '\');"></span></div>')); 521 var pref = ''; 522 if( $(prefix + 'attachments_names').value ) { 523 pref = ';'; 524 } 525 $(prefix + 'attachments_names').value = $(prefix + 'attachments_names').value + pref + responseJSON.filename; 526 $(prefix + 'previews_names').value = $(prefix + 'previews_names').value + pref + responseJSON.preview; 527 $(prefix + 'attachments_widths').value = $(prefix + 'attachments_widths').value + pref + responseJSON.width; 528 $(prefix + 'attachments_heights').value = $(prefix + 'attachments_heights').value + pref + responseJSON.height; 529 } 530 }); 531} 532 533function removeAttachment(elem, fileName, previewName, prefix) { 534 if ( !prefix ) { 535 prefix = ''; 536 } 537 new Ajax.Request('/ajax/items/photo_store.html', { 538 parameters: { action: 'remove_photo', 539 filename: fileName}, 540 onSuccess: function(r) { 541 var obj = r.responseText.evalJSON(); 542 if(obj.success) { 543 elem.parentNode.parentNode.remove(); 544 var names = $(prefix + 'attachments_names').value.split(';'); 545 var previews = $(prefix + 'previews_names').value.split(';'); 546 var widths = $(prefix + 'attachments_widths').value.split(';'); 547 var heights = $(prefix + 'attachments_heights').value.split(';'); 548 var resnames = '', respreviews = '', reswidths = '', resheights = ''; 549 for(var i=0; i<names.length; i++) { 550 if( names[i] != fileName ) { 551 var pref = ''; 552 if( resnames ) { 553 pref = ';'; 554 } 555 resnames += pref + names[i]; 556 respreviews += pref + previews[i]; 557 reswidths += pref + widths[i]; 558 resheights += pref + heights[i]; 559 } 560 } 561 $(prefix + 'attachments_names').value = resnames; 562 $(prefix + 'previews_names').value = respreviews; 563 $(prefix + 'attachments_widths').value = reswidths; 564 $(prefix + 'attachments_heights').value = resheights; 565 } 566 } 567 }); 568 569 return false;
570} 571 572var clickInBox = false; 573function clickToBox() { 574 clickInBox = true; 575} 576 577function clickToOverlay(el, event) { 578 if ( clickInBox ) { 579 clickInBox = false; 580 return; 581 } 582 583 closePopup(); 584} 585 586function markAsReaded() { 587 new Ajax.Updater('new-articles-container', '/ajax/new_articles/block.html', { 588 parameters: { action: 'clear_published_articles' }, 589 evalScripts: true, 590 onComplete: function(response) { 591 if ( 200 == response.status ) { 592 $$('.b-newarticles')[0].appear({ duration: 0.4, from: 0, to: 1 }); 593 } 594 } 595 }); 596 597 return false; 598} 599 600function loadPhotostream() { 601 var y = document.viewport.getScrollOffsets().top + document.viewport.getHeight(); 602 603 if ( y > $('photostream').cumulativeOffset().top + $('photostream').getHeight() - 20 && $('need_request').value ) { 604 $('need_request').value = ''; 605 new Ajax.Request('/ajax/section/photostream.html', { 606 parameters: { 607 p: parseInt($('current_photostream_page').value) + 1, 608 sect_id: $('section_id').value 609 }, 610 onComplete: function(r) { 611 if ( r.responseText.length > 10 ) { 612 var div = new Element('div').update( r.responseText ); 613 $('photostream').appendChild(div); 614 $('current_photostream_page').value = parseInt($('current_photostream_page').value) + 1; 615 $('need_request').value = 1; 616 } 617 else { 618 $('need_request').value = ''; 619 } 620 } 621 }); 622 623 } 624} 625 626function fixLastLine(el) { 627 if ( $(el).hasClassName('hidden-badge-title') ) { 628 return false; 629 } 630 var srcHeight = $(el).getHeight(); 631 var srcText = $(el).innerHTML; 632 var words = srcText.split(" "); 633 634 var lastLine = ""; 635 var strFounded = false; 636 while ( words.length > 0 || strFounded ) { 637 var word = words.pop(); 638 $(el).update(words.join(" ")); 639 lastLine = word + " " + lastLine; 640 641 if ( $(el).getHeight() != srcHeight ) { 642 var span = new Element('span').update( lastLine ); 643 $(el).appendChild(span); 644 $(el).removeClassName('badge-title'); 645 return; 646 } 647 } 648 var span = new Element('span').update( lastLine ); 649 $(el).appendChild(span); 650 $(el).removeClassName('badge-title'); 651} 652 653function updateAllActivity(el, type) { 654 if ( $(el).hasClassName('active') ) { 655 return false; 656 } 657 $('activity_type').value = type; 658 $('activity-content').update(''); 659 $('current_activity_page').value = 0; 660 loadSiteActivity(); 661 $$('.activity-filter').invoke('removeClassName', 'active'); 662 $(el).addClassName('active'); 663 664 return false; 665} 666 667function loadSiteActivity(p) { 668 $('need_request').value = ''; 669 new Ajax.Request('/ajax/section/activity.html', { 670 parameters: { 671 p: p, 672 type: $('activity_type').value 673 }, 674 evalScripts: true, 675 onComplete: function(r) { 676 if ( r.responseText.length > 10 ) { 677 var div = new Element('div').update( r.responseText ); 678 $('activity-content').appendChild(div); 679 $('current_activity_page').value = parseInt($('current_activity_page').value) + 1; 680 $('need_request').value = 1; 681 } 682 } 683 }); 684} 685 686var methods = ['slide', 'blind', 'appear','slide', 'blind', 'appear','slide', 'blind', 'appear','slide']; 687function showLastActivity() { 688 if ( $$('.hidden-activity').length ) { 689 var el = $$('.hidden-activity').last(); 690 if ( el ) { 691 $(el).removeClassName('hidden-activity'); 692 $(el).removeClassName('g-hidden'); 693 var dn = $(el).down('.hidden-badge-title'); 694 if (dn) { 695 $(dn).removeClassName('hidden-badge-title'); 696 fixLastLine(dn); 697 } 698 } 699 } 700} 701 702function loadAllActivity() { 703 var y = document.viewport.getScrollOffsets().top + document.viewport.getHeight(); 704 705 if ( y > $('activity-content').cumulativeOffset().top + $('activity-content').getHeight() - 100 && $('need_request').value ) { 706 loadSiteActivity(parseInt($('current_activity_page').value) + 1); 707 } 708} 709 710function loadAllArticles() { 711 var y = document.viewport.getScrollOffsets().top + document.viewport.getHeight(); 712 713 if ( y > $('all_container').cumulativeOffset().top + $('all_container').getHeight() - 100 && $('need_request').value ) { 714 $('need_request').value = ''; 715 new Ajax.Request('/ajax/section/all.html', { 716 parameters: { 717 p: parseInt($('current_all_page').value) + 1 718 }, 719 onComplete: function(r) { 720 var obj = r.responseText.evalJSON(); 721 if ( obj.elements ) { 722 var cnt = 1; 723 var col = 1; 724 for (var i=0; i<obj.elements.length; i++) { 725 var item = obj.elements[i]; 726 727 var div = new Element('div', {'class': 'b-reading-item'}).update( item ); 728 $('all_col_' + col).appendChild(div); 729 730 if ( ++cnt > 5 ) { 731 cnt = 1; 732 col++; 733 } 734 } 735 $('current_all_page').value = parseInt($('current_all_page').value) + 1; 736 $('need_request').value = 1; 737 } 738 739/* 740 if ( r.responseText.length > 10 ) { 741 var div = new Element('div').update( r.responseText );
742 div.addClassName('b-reading g-clearfix'); 743 $('all_container').appendChild(div); 744 $('current_all_page').value = parseInt($('current_all_page').value) + 1; 745 } 746 else { 747 } 748*/ 749 } 750 }); 751 752 } 753} 754 755function toggleMostReadedList(type) { 756 new Ajax.Updater('most_readed_container', '/ajax/section/most-readed.html', { 757 evalScripts: true, 758 parameters: { 'type': type } 759 }); 760 761 return false; 762} 763 764function toggleIndexMostReadedList(type, ids) { 765 new Ajax.Updater('most-readed', '/ajax/index/most_readed.html', { 766 evalScripts: true, 767 method: 'get', 768 parameters: { 'type': type, 'articles_ids': ( ids ? ids : '' ) } 769 }); 770 771 return false; 772} 773 774function toggleIndexAuthorsList(sort) { 775 new Ajax.Updater('authors-list', '/ajax/index/authors.html', { 776 evalScripts: true, 777 parameters: { 'sort': sort }, 778 onComplete: function(response) { 779 if ( 200 == response.status ) { 780 initTooltips(); 781 } 782 } 783 }); 784 785 return false; 786} 787 788function updateArchive(sectId, p) { 789 new Ajax.Updater('section-archive', '/ajax/section/archive.html', { 790 evalScripts: true, 791 parameters: { 'p': p, 'section_id': sectId } 792 }); 793 794 return false; 795} 796 797function paginateSearchBlock(block, text, p, sort, scrollTarget) { 798 new Ajax.Updater(block + '-block', '/ajax/search/' + block + '.html', { 799 evalScripts: true, 800 parameters: { 'p': p, 'text': text, 'sort': sort }, 801 onComplete: function(response) { 802 if ( 200 == response.status && scrollTarget ) { 803 new Effect.ScrollTo(scrollTarget); 804 } 805 } 806 }); 807 808 return false; 809} 810 811function showSearchFilter(block) { 812 $('filter-item-' + block).removeClassName('g-hidden'); 813 $(block + '-block').removeClassName('g-hidden'); 814 if ( block == 'articles' ) { 815 $('articles-sort').removeClassName('g-hidden'); 816 } 817 if ( $('search-filter').hasClassName('g-hidden') ) { 818 var count = 0; 819 $$('.filter-item').each(function(el) { 820 if ( !(el).hasClassName('g-hidden') ) { 821 count++; 822 } 823 }); 824 if ( count > 1 ) { 825 $('filter-item-all').removeClassName('g-hidden'); 826 $('search-filter').removeClassName('g-hidden'); 827 } 828 } 829} 830 831function sortSearchArticles(sort, text) { 832 $$('.articles-sort-item').invoke('removeClassName', 'active'); 833 $('sort-' + sort).addClassName('active'); 834 return paginateSearchBlock('articles', text, 1, sort); 835} 836 837function filterSearchLists(block, text) { 838 if ( $('filter-item-' + block).hasClassName('active') ) { 839 return false; 840 } 841 $$('.filter-item').invoke('removeClassName', 'active'); 842 $('filter-item-' + block).addClassName('active'); 843 if ( block == 'all' ) { 844 var paths = ['articles', 'comments', 'authors', 'tags']; 845 for ( var i=0; i<paths.length; i++ ) { 846 if ( $(paths[i] + '-block').hasClassName('g-hidden') ) { 847 paginateSearchBlock(paths[i], text, 1); 848 } 849 } 850 } 851 else { 852 $$('.b-search-section').each(function(el) { 853 if ( $(el).id != block + '-block' ) { 854 $(el).update(''); 855 $(el).addClassName('g-hidden'); 856 } 857 }); 858 if ( block != 'articles' ) { 859 $('articles-sort').addClassName('g-hidden'); 860 $$('.articles-sort-item').invoke('removeClassName', 'active'); 861 $('sort-date').addClassName('active'); 862 } 863 if ( $(block + '-block').hasClassName('g-hidden') ) { 864 paginateSearchBlock(block, text, 1); 865 } 866 } 867 868 return false; 869} 870 871function calculateTotalSearchResult() { 872 var count = 0; 873 $$('.search-type-total').each(function (el) { 874 count += parseInt($(el).innerHTML); 875 }); 876 $('total_count').update(count); 877 $('total_count_description').update(numerate(count, 'ðåçóëüòàò', 'ðåçóëüòàòà', 'ðåçóëüòàòîâ')); 878} 879 880function numerate(num, word1, word234, word567890) { 881 882 if ( !word1 ) 883 word1 = ''; 884 if ( !word234 ) 885 word234 = word1; 886 if ( !word567890 ) 887 word567890 = word1; 888 var spacer = ' '; 889 890 var digit = num % 10; 891 892 var word = ( digit >= 5 || digit == 0 || parseInt((num / 10) % 10) == 1 ) 893 ? word567890 : ( digit == 1 ) ? word1 : word234; 894 895 return word; 896} 897 898function paginateTagBlock(block, docId, p) { 899 new Ajax.Updater(block + '-block', '/ajax/tags/' + block + '.html', { 900 evalScripts: true, 901 parameters: { 'p': p, 'doc_id': docId } 902 }); 903 904 return false; 905} 906 907function filterTagLists(block, docId) { 908 if ( $('filter-item-' + block).hasClassName('active') ) { 909 return false;
910 } 911 $$('.filter-item').invoke('removeClassName', 'active'); 912 $('filter-item-' + block).addClassName('active'); 913 if ( block == 'all' ) { 914 var paths = ['articles', 'authors', 'tags']; 915 for ( var i=0; i<paths.length; i++ ) { 916 if ( $(paths[i] + '-block').hasClassName('g-hidden') ) { 917 paginateTagBlock(paths[i], docId, 1); 918 } 919 } 920 } 921 else { 922 $$('.b-search-section').each(function(el) { 923 if ( $(el).id != block + '-block' ) { 924 $(el).update(''); 925 $(el).addClassName('g-hidden'); 926 } 927 }); 928 if ( $(block + '-block').hasClassName('g-hidden') ) { 929 paginateTagBlock(block, docId, 1); 930 } 931 } 932 933 return false; 934} 935 936function showTagFilter(block) { 937 $('filter-item-' + block).removeClassName('g-hidden'); 938 $(block + '-block').removeClassName('g-hidden'); 939 if ( $('search-filter').hasClassName('g-hidden') ) { 940 var count = 0; 941 $$('.filter-item').each(function(el) { 942 if ( !(el).hasClassName('g-hidden') ) { 943 count++; 944 } 945 }); 946 if ( count > 1 ) { 947 $('filter-item-all').removeClassName('g-hidden'); 948 $('search-filter').removeClassName('g-hidden'); 949 } 950 } 951} 952 953function showPromoVideo(type) { 954 $$('html').first().addClassName('lightbox-mode'); 955 956 $('overlay').appear({ duration: 0.4, from: 0, to: 1, afterFinish: function() { 957 $('popup-overlayed-container').update('<span class="g-loading"></span>'); 958 new Ajax.Updater('popup-overlayed-container', '/ajax/popup/' + type + '.html', { 959 evalScripts: true 960 }); 961 } }); 962 963 return false; 964} 965 966function submitUserEmailForm() { 967 new Ajax.Updater('informer_panel', '/ajax/users/informer.html', { 968 parameters: { 'email': $('user_email').value } 969 }); 970 971 return false; 972} 973 974function closeInformer(type) { 975 $('informer_panel').remove(); 976 Cookies.set('close_imformer_' + type, 1, 24); 977 978 return false; 979} 980 981var newArticlesCurrentPage = 1; 982var newArticlesCarousel; 983function createNewArticlesCarousel() { 984 if (!$$('.b-newarticles .b-newarticles-wrap').length) { 985 return; 986 } 987 newArticlesCarousel = new Carousel($$('.b-newarticles .b-newarticles-wrap')[0], $$('.b-newarticles .b-newarticles-wrap .b-newarticles-list')[0], $$('.b-newarticles .b-newarticles-control'), 988 { wheel: false, circular: false, visibleSlides: 3, scrollSlides: 3, duration: 1, disabledClassName: 'inactive', controlClassName: 'b-newarticles-control', 989 prev: $$('.b-newarticles .b-newarticles-control.prev')[0], next: $$('.b-newarticles .b-newarticles-control.next')[0], 990 beforeMove: function() { 991 if (newArticlesCarousel.current) { 992 var currentIndex = newArticlesCarousel.current._index; 993 var nextIndex = (newArticlesCarousel.slides.length - 1 == currentIndex) ? currentIndex : currentIndex + 1; 994 } else { 995 var nextIndex = 1; 996 } 997 998 if ( nextIndex+3 == newArticlesCarousel.slides.length - newArticlesCarousel.options.visibleSlides ) { 999 if ( newArticlesCurrentPage > 0 ) { 1000 // çàïðàøèâàåì íîâûå ýëåìåíòû 1001 new Ajax.Request('/ajax/new_articles/list.html', { 1002 parameters: { p: newArticlesCurrentPage + 1 }, 1003 onComplete: function(r) { 1004 if ( r.responseText.length > 20 ) { 1005 $('new_articles_countainer').insert(r.responseText); 1006 newArticlesCarousel.slides = newArticlesCarousel.container.childElements() 1007 newArticlesCarousel.slides.each(function(slide, index) { 1008 slide._index = index; 1009 }); 1010 newArticlesCurrentPage += 1; 1011 } 1012 else { 1013 newArticlesCurrentPage = 0; 1014 } 1015 } 1016 }); 1017 1018 } 1019 } 1020 } }); 1021} 1022 1023/* social network badges */ 1024 1025(function(){ 1026 var id = 0, head = $$('head')[0], global = this; 1027 global.getJSON = function(url, callback) { 1028 var script = document.createElement('script'), token = '__jsonp' + id; 1029 1030 // callback should be a global function 1031 global[token] = callback; 1032 1033 // url should have "?" parameter which is to be replaced with a global callback name 1034 script.src = url.replace(/\?(&|$)/, '__jsonp' + id + '$1'); 1035 1036 // clean up on load: remove script tag, null script variable and delete global callback function 1037 script.onload = function() { 1038 script.remove(); 1039 script = null; 1040 delete global[token]; 1041 }; 1042 head.appendChild(script); 1043 1044 // callback name should be unique 1045 id++; 1046 } 1047})(); 1048 1049function checkSocialsLikesCount(objId, vkAppId, vkCount, fbCount, twCount) { 1050 if ( vkCount ) { 1051 VK.Api.call('likes.getList', {type: "sitepage", owner_id: vkAppId, page_url: location.href}, 1052 function(r) { 1053 if(r.response && r.response.count && r.response.count >= vkCount) { 1054 new Ajax.Request('/ajax/badges/add_to_queue.html', { 1055 parameters: { 'obj_id': objId, 'type': 'vkontakte' } 1056 }); 1057 } 1058 }); 1059 } 1060 if ( fbCount ) { 1061 getJSON('https://api.facebook.com/method/fql.query?query=select total_count from link_stat where url="' + encodeURIComponent(location.href) + '"&format=json&callback=?', 1062 function(resp){ 1063 if(resp && resp[0] && resp[0].total_count && resp[0].total_count >= fbCount) { 1064 new Ajax.Request('/ajax/badges/add_to_queue.html', { 1065 parameters: { 'obj_id': objId, 'type': 'facebook' } 1066 }); 1067 1068 } 1069 }); 1070 } 1071 if ( twCount ) { 1072 getJSON('https://urls.api.twitter.com/1/urls/count.json?url=' + encodeURIComponent(location.href) + '&callback=?', 1073 function(resp){ 1074 if(resp.count && resp.count >= twCount) { 1075 new Ajax.Request('/ajax/badges/add_to_queue.html', { 1076 parameters: { 'obj_id': objId, 'type': 'twitter' } 1077 }); 1078 1079 } 1080 }); 1081 } 1082} 1083 1084function checkAuthorsPartsHeights() { 1085 $$('.b-article-body').each(function(el) {
1086 var authorPart = $(el).down('div.b-article-part-author'); 1087 if (authorPart) { 1088 var innerPart = $(el).down('div.b-article-part-inner'); 1089 var authorHeight = $(authorPart).getHeight(); 1090 var innerHeight = $(innerPart).getHeight(); 1091 1092 if ( authorHeight > innerHeight ) { 1093 innerPart.setStyle( { 'marginBottom' : authorHeight - innerHeight + 'px' } ) 1094 } 1095 } 1096 }); 1097} 1098 1099function initTooltips() { 1100 var tooltips = $$('.tooltiped'); 1101 1102 Modernizr.load({ 1103 test: tooltips.length, 1104 yep : '/js/tooltip.js', 1105 complete : function () { 1106 tooltips 1107 .invoke('observe', 'mouseover', function(event) { 1108 tooltip.show( event.findElement('.tooltiped').readAttribute('data-tooltip-text') ); 1109 }) 1110 .invoke('observe', 'mouseout', function(event) { 1111 tooltip.hide(); 1112 }); 1113 } 1114 }); 1115} 1116 1117function updateUserBadges(userId, p) { 1118 new Ajax.Updater('user-badges', '/ajax/users/badges.html', { 1119 parameters: { 1120 'user_id': userId, 1121 'p': p 1122 } 1123 }); 1124 1125 return false; 1126} 1127 1128function createVideoUploader() { 1129 $('video-error').update(''); 1130 var uploader = new qq.FileUploader({ 1131 element: document.getElementById('video-uploader'), 1132 title: "Äîáàâèòü ôàéë", 1133 action: '/ajax/special/video/upload.html', 1134 multyFiles: true, 1135 sizeLimit: 100*1024*1024, 1136 multiple: true, 1137 width: '100px', 1138 height: '20px', 1139 fontSize: '20', 1140 showMessage: function(message){ 1141 $('video-error').update(message); 1142 }, 1143 allowedExtensions: ['avi', 'mkv', 'mov', 'wma', 'mp4', 'flv'], 1144 messages: { 1145 typeError: "Íåêîððåêòíûé ôîðìàò âèäåî. Ðàçðåøåíî çàãðóæàòü ôàéëû â ôîðìàòàõ {extensions}", 1146 sizeError: "Ôàéë íå ìîæåò áûòü áîëüøå 100MB.", 1147 }, 1148 params: { 1149 action: 'add_video', 1150 debug: true, 1151 control_charset: $('control_charset').value 1152 }, 1153 onProgress: function(id, fileName, loaded, total){ 1154 $('video-error').update(''); 1155 }, 1156 onComplete: function(id, fileName, responseJSON){ 1157 $('video-error').update(''); 1158 if ( responseJSON.success ) { 1159 $('video-uploader').update('<a href="' + responseJSON.filepath + responseJSON.filename + '">' + responseJSON.filename + '</a> <span class="b-upload-item-remove" onclick="return removeVideoFile();"></span>'); 1160 $('binary_name').value = responseJSON.filename; 1161 $('binary_size').value = responseJSON.size; 1162 } 1163 else { 1164 $('video-error').update(responseJSON.error_text); 1165 } 1166 } 1167 }); 1168} 1169 1170function removeVideoFile() { 1171 new Ajax.Request('/ajax/special/video/upload.html', { 1172 parameters: { 1173 action: 'remove_video', 1174 filename: $('binary_name').value 1175 }, 1176 onSuccess: function(r) { 1177 var obj = r.responseText.evalJSON(); 1178 if(obj.success) { 1179 createVideoUploader(); 1180 $('binary_name').value = ''; 1181 $('binary_size').value = ''; 1182 } 1183 } 1184 }); 1185 1186 return false; 1187} 1188 1189var loadMoreTagArticlesTimer; 1190function loadMoreTagArticles() { 1191 var y = document.viewport.getScrollOffsets().top + document.viewport.getHeight(); 1192 1193 if ( y > $('articles_container').cumulativeOffset().top + $('articles_container').getHeight() - 100 && $('need_request').value ) { 1194 $('need_request').value = ''; 1195 new Ajax.Request('/ajax/tags/more_articles.html', { 1196 parameters: { 1197 'p': parseInt($('current_articles_page').value) + 1, 1198 'tag_id': $('tag_id').value 1199 }, 1200 onComplete: function(r) { 1201 var obj = r.responseText.evalJSON(); 1202 if ( obj.count ) { 1203 var cnt = 1; 1204 var col = 1; 1205 for (var i=0; i<obj.elements.length; i++) { 1206 var item = obj.elements[i]; 1207 1208 var div = new Element('div', {'class': 'b-reading-item'}).update( item ); 1209 $('articles_container_col_' + col).appendChild(div); 1210 1211 if ( ++cnt > 5 ) { 1212 cnt = 1; 1213 col++; 1214 } 1215 } 1216 1217 $('current_articles_page').value = parseInt($('current_articles_page').value) + 1; 1218 $('need_request').value = 1; 1219 } 1220 else if ( loadMoreTagArticlesTimer ) { 1221 clearInterval(loadMoreTagArticlesTimer); 1222 } 1223 } 1224 }); 1225 1226 } 1227}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.