PageSourceSearch

https://ukraina.ru/js/libs/ria.get.banners.js?9742ae002

js ukraina.ru collected 2026-10-02 03:58:46 UTC 4,294 bytes, 118 lines download raw bytes

1"use strict";
2
3$(function() {
4
5    var getBanners = function( element, options ){
6
7        var	defaults = {
8            loadingCounter : 0,
9            loadingCount : 3,
10            loadingTimeout : 2000,
11            loadingUrl: '/services/banners/get/',
12            loadingParams: [ 'type', 'id', 'adfox_name', 'adfox_value' ],
13            filter: false
14        };
15
16        this.defOptions = defaults;
17        this.userOptions = options;
18        this.options = $.extend( true, {}, defaults, options );
19
20        this.$element = $( element );
21
22        this.getUrl();
23
24        //console.log( ' ### getBanners ###   $element = ', this.$element );
25        //console.log( ' ### getBanners ###   options = ', this.options );
26        //console.log( ' ### getBanners ###   loadingUrl = ', this.loadingUrl );
27
28        this.getData();
29
30    };
31
32    getBanners.prototype.getUrl = function(){
33        var _this = this,
34            c = 0;
35        _this.loadingUrl = _this.options.loadingUrl;
36        $.each( _this.options.loadingParams, function( i, v ){
37            if ( _this.options[ v ] ) {
38                _this.loadingUrl = ( _this.loadingUrl + ( c++ ? '&' : '?' ) + v + '=' + _this.options[ v ] );
39            }
40        });
41        if ( $( '#page' ).data('get-banners-params') != '' ){
42            _this.loadingUrl = _this.loadingUrl + ( c ? '&' : '?' ) + $( '#page' ).data( 'get-banners-params' );
43        }
44    };
45
46    getBanners.prototype.getData = function(){
47        var _this = this;
48        $.ajax({
49            url: _this.loadingUrl,
50            dataType: 'html',
51            type: 'GET',
52            success: function ( data ) {
53                _this.$data = $( data );
54                _this.successData();
55            },
56            error: function (){
57                if ( _this.options.loadingCounter < _this.options.loadingCount ){
58                    setTimeout( _this.getData() , _this.options.loadingTimeout );
59                    _this.options.loadingCounter++;
60                } else {
61                    _this.errorData();
62                }
63            }
64        });
65    };
66
67    getBanners.prototype.successData = function(){
68        var _this = this;
69        //console.log( '### getBanners ### SUCCESS GetData - URL = ' + _this.loadingUrl );
70        //console.log( _this.$data );
71        _this.pushBanners();
72    };
73
74    getBanners.prototype.errorData = function(){
75        var _this = this;
76        console.log( '--- getBanners ERROR GetData --- ' + _this.loadingUrl );
77    };
78
79    getBanners.prototype.pushBanners = function(){
80        /* data-hide-banners - помечаются места где загружена заглушка для показа места */
81        /* data-banner-inserted - место в которое уже вставлен баннер */
82        if ( this.$data ) {
83            var _this = this,
84                $banners = $( '.banner[data-position]:not([data-hide-banners]):not([data-banner-inserted])', _this.$element );
85
86            if ( typeof _this.options.filter == 'function' ){
87                $banners = $banners.filter( _this.options.filter );
88            }
89
90            $banners.each( function () {
91                var $bannerPlace = $( this ),
92                    position = $bannerPlace.data('position'),
93                    $bannerContent = $( '.banner__content', $bannerPlace ),
94                    $dynamicBanner = $( 'div[data-position=' + position + ']', _this.$data );
95
96                if ( $bannerContent.html() == '' ) {
97                    //console.log( '### getBanners ### ' + position + ' => EMPTY => ADDED BANNER' ); //TODO DELETE AFTER TEST DYNAMIC BANNERS
98                    $bannerContent.append( $dynamicBanner.html() );
99                    $bannerPlace.attr( 'data-banner-inserted', 1 );
100                } else {
101                    //console.log( '### getBanners ### ' + position + ' => FULL' ); //TODO DELETE AFTER TEST DYNAMIC BANNERS
102                }
103            })
104        }
105    };
106
107    $.fn.getBanners = function( options ) {
108        return this.each( function(){
109            var instance = $.data( this, 'getBanners' );
110            if ( !instance ){
111                instance = new getBanners( this, options );
112                $.data( this, 'getBanners', instance );
113            }
114        });
115    };
116
117
118});

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.