function prepareJquery(jQueryBlocker){ if(window.jQuery) { var v = jQuery.fn.jquery; var r = v.split('.'); if(r >= 3) { jQueryBlocker(); } else { var script = document.createElement('script'); document.head.appendChild(script); script.type = 'text/javascript'; script.src = "//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"; script.onload = jQueryBlocker; } }else{ var script = document.createElement('script'); document.head.appendChild(script); script.type = 'text/javascript'; script.src = "//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"; script.onload = jQueryBlocker; } } prepareJquery(function jQueryBlocker(){ $(function() { //$(".fake-player").css('background', '#000'); var frame_url; var wap_url; var scr_video = ""; var frame_url_additional = ""; var Player = { options: {}, run: function(options) { var self = this; var p = $(".fake-player"); var platform_id = p.attr("data-platform"); var theme_id = p.attr("data-theme"); if (typeof theme_id !== typeof undefined && theme_id !== false) { } else { theme_id = 1; } var p_title = p.attr("data-title"); var p_istitle = p.attr("data-titles"); var p_audio = p.attr("data-audio"); var p_logo = p.attr("data-logo"); var p_poster = p.attr("data-poster"); var p_skip_intro = p.attr("data-register"); var p_playlist = p.attr("data-list"); var p_type_size = p.attr("data-width-type"); var p_type_width = p.attr("data-width-px"); var p_playlist_btn = p.attr("data-playelist-btn"); var p_src_video = p.attr("data-src-video"); var duration = p.attr("data-src-duration"); var reg_time = p.attr("data-src-regtime"); var p_title_date = p.attr("data-title-date"); var p_hide_count = p.attr("data-hide-count"); var p_seek = p.attr("data-seek"); var p_push = p.attr("data-push"); var s_ll = p.attr("data-sport-ll"); var s_ln = p.attr("data-sport-ln"); var s_rl = p.attr("data-sport-rl"); var s_rn = p.attr("data-sport-rn"); var s_t = p.attr("data-sport-t"); var attributes = {platform_id:platform_id,theme_id:theme_id,p_title:p_title,p_istitle: p_istitle,p_audio:p_audio,p_logo:p_logo,p_poster:p_poster,p_skip_intro:p_skip_intro,p_playlist:p_playlist,p_type_size:p_type_size,p_type_width:p_type_width,p_playlist_btn:p_playlist_btn,p_src_video:p_src_video,duration:duration,reg_time:reg_time,p_title_date:p_title_date,p_hide_count:p_hide_count,s_ll:s_ll,s_ln:s_ln,s_rl:s_rl,s_rn:s_rn,s_t:s_t,p_seek:p_seek,p_push:p_push}; self.options = options; self.initData(options.initialize,attributes); }, initData: function(option_refferal,attributes) {; if(option_refferal.crossorigin != null && option_refferal.init != null){ var hidelist = ''; if(attributes.p_type_size == "auto"){ //Полностью автоматический ширина высота var newWidth = '100%'; var newHeight = $('.fake-player').width()/1.78; } if(attributes.p_type_size == "autofix"){ //Автоматический с фиксацией var dataWidth; if($('.fake-player').width() > attributes.p_type_width){ //alert(1); var newWidth = '100%'; dataWidth = $('.fake-player').width(); } else { //alert(attributes.p_type_width); var newWidth = attributes.p_type_width + 'px'; dataWidth = attributes.p_type_width; } //var newHeight = $('.fake-player').width()/1.78; var newHeight = dataWidth/1.78; //alert(newHeight); } if(attributes.p_type_size == "fixed"){ //Полностью фиксированный ширина высота var newWidth = attributes.p_type_width + 'px'; //var newHeight = $('.fake-player').width()/1.78; var newHeight = attributes.p_type_width/1.78; } $('.mainData').css({"width":newWidth,"height":newHeight+"px"}); if(attributes.p_src_video){ scr_video = '&video-src='+attributes.p_src_video; } if( $('.fake-player').width() < 400){ hidelist = true; } var general_domain = $(".appenJs").attr("src").split('/'); if(attributes.platform_id == 1){ var sport_data = "&sport_ll="+attributes.s_ll+"&sport_ln="+attributes.s_ln+"&sport_rl="+attributes.s_rl+"&sport_rn="+attributes.s_rn+"&sport_total="+attributes.s_t; } else { var sport_data = ""; } //var json = JSON.stringify({'location':window.top.location.href, 'title':window.top.document.title}); //json = Buffer.from(json).toString("base64"); var parentUrl = encodeURIComponent(window.top.location.href); var parentTitle = encodeURIComponent(window.top.document.title); $("#widget-player .fake-player").html(''); console.log(option_refferal.init); frame_url = 'https://'+general_domain[2]+'/z2.plugin/index.php?crossorigin='+option_refferal.crossorigin+'&logo='+attributes.p_audio+'&plat='+attributes.platform_id+'&movieid='+option_refferal.init+'&fakeaudio='+attributes.p_audio+'&parentUrl='+parentUrl+'&parentTitle='+parentTitle+''; //console.log($("#widget-player .fake-player #mainData").length); setTimeout(function() { if($("#widget-player .fake-player #mainData").length == 0) { $("#widget-player .fake-player iframe").remove(); $("#widget-player .fake-player").html(''); } },100); frame_url_additional = frame_url; if(attributes.p_push == 'true') { $('#mainData').on('load', function(){ (function() { const url = new URL(window.location.href); const clickID = url.searchParams.get("click_id"); const sourceID = url.searchParams.get("source_id"); const s = document.createElement("script"); s.dataset.cfasync = "false"; s.src = "https://push-sdk.net/f/sdk.js?z=805279"; s.onload = (opts) => { var subid = option_refferal.crossorigin; var curr_location = top.window.location.href; var pushUri = 'https://'+general_domain[2]+'/z2.plugin/request.php?subscribe_id='+subid+'&refer='+curr_location; opts.zoneID = 805279; opts.extClickID = clickID; opts.subID1 = sourceID; opts.actions.onPermissionGranted = () => { $.ajax({url:pushUri,type:'POST',crossDomain: true,success: function(response) {console.log(response);}}); }; opts.actions.onPermissionDenied = () => {console.log('Denied Push [#1]');}; opts.actions.onAlreadySubscribed = () => {console.log('Subscribed Push [#2]');}; opts.actions.onError = () => {console.log('Error Push [#3]');}; console.log('Push Initialization [OK]'); } document.head.appendChild(s); })() }); } UpdateSizes(); if(option_refferal.access != ""){ setTimeout(function(){UpdateSizes()},800); } } } } $(window).resize(UpdateSizes); var is_enabled = false; function ReinitStates(){ if(is_enabled){ $(".togglePlaylist").remove(); } var iframeMainlist = document.getElementById('mainData'); iframeMainlist.contentWindow.postMessage('list-checking', '*'); } function UpdateSizes(){ //$('.fake-player').height($('.fake-player').width()/1.78); //$('.fake-player').height($('.mainData').width()/1.78); if($(".fake-player").attr("data-width-type") == "auto"){ $('.fake-player').height($('.fake-player').width()/1.78); //Полностью автоматический ширина высота var newWidth = '100%'; var newHeight = $('.fake-player').width()/1.78; } if($(".fake-player").attr("data-width-type") == "autofix"){ $('.fake-player').height($('.mainData').width()/1.78); //Автоматический с фиксацией var dataWidth; if($('.fake-player').width() > $(".fake-player").attr("data-width-px")){ var newWidth = '100%'; dataWidth = $('.fake-player').width(); } else { var newWidth = $(".fake-player").attr("data-width-px") + 'px'; dataWidth = $(".fake-player").attr("data-width-px"); } //var newHeight = $('.fake-player').width()/1.78; var newHeight = dataWidth/1.78; } if($(".fake-player").attr("data-width-type") == "fixed"){ $('.fake-player').height($('.mainData').width()/1.78); //Полностью фиксированный ширина высота var newWidth = $(".fake-player").attr("data-width-px") + 'px'; var newHeight = $(".fake-player").attr("data-width-px") / 1.78; //var newHeight = $('.fake-player').width()/1.78; } $('.mainData').css({"width":newWidth,"height":newHeight+"px"}); //console.log(newWidth); if( $('.mainData').width() < 400){ //if( $('.fake-player').width() < 400){ if($(".fake-player").attr("data-list") == "true"){ var iframeParent = document.getElementById('mainData'); iframeParent.contentWindow.postMessage('close-list', '*'); } $(".togglePlaylist").remove(); if($(".fake-player").attr("data-list") == "true"){ $('.widget-player').append(' Открыть список серий'); } } else { $(".togglePlaylist").remove(); if($(".fake-player").attr("data-list") == "true"){ var iframeMain = document.getElementById('mainData'); iframeMain.contentWindow.postMessage('open-list', '*'); } } } var count_opened = false; var show_form = false; function receiveMessage(event){ if(event.data.event_id == 'wap-redirect') { location.href = event.data.uri; } if(event.data.event_id == 'index-title') { var current_id = event.data.film_id; console.log('set additioal movie'); frame_url_additional = frame_url_additional+'&replace-movie-id='+current_id; } var iframeMain = document.getElementById('mainData'); if(event.data=="plugin-is-toggle-disable"){ } if(event.data=="plugin-is-toggle"){ } if(event.data=="open-list-button"){ $(".togglePlaylist").css("display","block"); ///////NEW } if(event.data=="disable-btn"){ is_enabled = true; $(".togglePlaylist").remove(); } if(event.data=="plugin-register"){ if(!count_opened){ if(wap_url != null){ location.href=wap_url; } else { if(!show_form) { show_form = true; console.log("Loading form..."); $(".fake-player").append(''); } $('#plugin-register').show(); setTimeout(function(){count_opened = false;},200); var iframeMain = document.getElementById('plugin-register'); iframeMain.contentWindow.postMessage('play-me', '*'); } } } if(event.data=="plugin-register-close"){ $('#plugin-register').hide(); } if(event.data=="plugin-main-reload"){ location.reload(); } } addEventListener("message",receiveMessage,false); Player.run({ initialize: { crossorigin : '4682', init : '4397::90161', last : '', access : '' } }); if (document.readyState === "complete"){ UpdateSizes(); } }); function TogglePlaylist(){ var iframeMain = document.getElementById('mainData'); iframeMain.contentWindow.postMessage('toggle-list', '*'); if($('.togglePlaylist').text() == " Открыть список серий"){ $('.togglePlaylist').html(' Закрыть список серий'); } else { $('.togglePlaylist').html(' Открыть список серий'); } } })