(function(Woodbine,undefined){(function(Video,undefined){let videoVue;function loadData(){return jQuery.ajax({url:woodbinejs.ajax_url,data:{action:'getTracksAndDate',security:woodbinejs.nonce},xhrFields:{withCredentials:true},cache:false,dataType:"json",method:"GET"});}
Video.Save=function(element){var data=jQuery(element).closest("form").serializeArray().reduce(function(obj,item){obj[item.name]=item.value;return obj;},{});data.security=woodbinejs.nonce;jQuery.ajax({url:ajaxurl,data:data,xhrFields:{withCredentials:true},dataType:"json",method:"POST"}).done(function(response){if(response.Success&&response.Result!=null)
{videoVue.list=response.Result
jQuery("#STrackDate").val("");jQuery("#ETrackDate").val("");}});return false;};Video.getLDVideos=function(){var data={action:'get_videos',security:woodbinejs.nonce};return jQuery.ajax({url:woodbinejs.ajax_url,data:data,xhrFields:{withCredentials:true},dataType:"json",method:"POST"}).done(function(response){if(response.Success&&response.Result!=null)
{videoVue.list=response.Result;}});}
function deleteVideo(id){var data={action:'delete_video',id:id,security:woodbinejs.nonce};return jQuery.ajax({url:woodbinejs.ajax_url,data:data,xhrFields:{withCredentials:true},dataType:"json",method:"POST"}).done(function(response){if(response.Success&&response.Result!=null)
{videoVue.list=response.Result;}});}
function saveLead(data){data.action='saveLead';data.security=woodbinejs.nonce;return jQuery.ajax({url:woodbinejs.ajax_url,data:data,xhrFields:{withCredentials:true},dataType:"json",method:"POST"});}
function hideAndStartVideo(){if(Woodbine.settings.isMobile){jQuery(".mobile-video-container").show();jQuery("#swf_placeholder_1502886928423").hide();}else{jQuery(".mobile-video-container").hide();jQuery("#swf_placeholder_1502886928423").show();}
var container=jQuery("#container");var videoInfo={};videoInfo.url=decodeURIComponent(jQuery("#livestream").val());var pairs=((videoInfo.url||'').split('?')[1]||'').split('&');var urlParams={};for(var i=0;i<pairs.length;i++){var pair=pairs[i].split('=');urlParams[decodeURIComponent(pair[0])]=decodeURIComponent(pair[1]||'');}
options={'id':'jsplayer-{0}'.format(+new Date()),'class':'wb-live-player','data-referer':urlParams['cust']||urlParams['referer']||'','data-hash':urlParams['h']||'','data-timestamp':urlParams['t']||'','data-stream':urlParams['stream']||'','data-width':"1170px",'data-height':"0px",'data-speed':urlParams['speed']||'771','data-hd':0,'data-muted':0,'data-hidecontrols':0,'data-videofit':"fill",'data-autoplay':1,'data-usr':urlParams['user']||urlParams['usr']||''};container.empty().append(jQuery('<ins>',options));setTimeout(function(){jQuery(".not-available.tmp").hide();},1000);}
Video.showUserModal=function(){hideAndStartVideo();if(Woodbine.getCookie("vcolected")==""){jQuery("#userinfoModal").modal('show');jQuery("#userinfoModal").on('hidden.bs.modal',function(e){hideAndStartVideo();});jQuery("#frmdata").validate();jQuery("#btnInfo").button().on("click",function(){var btn=jQuery("#btnInfo").html();if(jQuery("#frmdata").valid()){jQuery("#btnInfo").html("<i class='fa fa-spin fa-spinner'></i> Please wait ...").addClass("disabled");let input={"email":jQuery("#pemail").val(),"firstname":jQuery("#pfristname").val(),"lastname":jQuery("#plastname").val(),"dateOfBirth":jQuery("#pdateofbirth").val(),"postalCode":jQuery("#postalcode").val(),"acceptemail":jQuery("#acceptemail").is(":checked")?"yes":"no"};saveLead(input).done(function(data){Woodbine.setCookie("vcolected",true,365);jQuery("#userinfoModal").modal('hide');jQuery("#btnInfo").html(btn).removeClass("disabled");});}});}
else{hideAndStartVideo();}}
Video.init=function(){videoVue=new Vue({el:"#video-widget",data:{dataLoaded:false,list:[],},methods:{deleteVideo:function(e,item){if(confirm("Are you sure you want to delete this item.")){deleteVideo(item.id);}}}});loadData().success(function(data){videoVue.dataLoaded=true;videoVue.list=data.Result;jQuery(document).ready(function(){jQuery('#datetimepicker1').datetimepicker({format:'YYYY-MM-DD HH:mm'});jQuery('#datetimepicker2').datetimepicker({format:'HH:mm'});});});}}(Woodbine.Video=Woodbine.Video||{},Vue,jQuery));}(window.Woodbine=window.Woodbine||{},Vue,jQuery));