function ISODateString(d){function pad(n){return n<10?'0'+n:n} return d.getUTCFullYear()+'-' +pad(d.getUTCMonth()+1)+'-' +pad(d.getUTCDate())} function getMonday(d,offset){var day=d.getDay()+offset,diff=d.getDate()-day+(day==0?-6:1);return diff;} Date.prototype.getMonthFormatted=function(offset){var month=this.getMonth()+1+offset;return month<10?'0'+(month):(month);} if(!Date.prototype.adjustDate){Date.prototype.adjustDate=function(days){var date;days=days||0;if(days===0){date=new Date(this.getTime());}else if(days>0){date=new Date(this.getTime());date.setDate(date.getDate()+days);}else{date=new Date(this.getFullYear(),this.getMonth(),this.getDate()-Math.abs(days),this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds());} this.setTime(date.getTime());return this;};} function getDatesByInterval(value) {var begin=new Date();var end=new Date();var resultdate={};switch(value){case'today':break;case'thisweek':begin.setDate(getMonday(begin,0));break;case'thismonth':begin=new Date(begin.getFullYear()+'-'+begin.getMonthFormatted(0)+'-01');break;case'thisyear':begin=new Date(begin.getFullYear()+'-01-01');break;case'2weeks':begin=new Date(begin).adjustDate(-14);break;case'3weeks':begin=new Date(begin).adjustDate(-21);break;case'lastweek':begin.setDate(getMonday(begin,7));end.setDate(getMonday(end,1));break;case'lastmonth':begin=new Date(begin.getFullYear()+'-'+begin.getMonthFormatted(-1)+'-01');end=new Date(end.getFullYear()+'-'+end.getMonthFormatted(0)+'-01');break;case'lastyear':begin=new Date((begin.getFullYear()-1)+'-01-01');end=new Date((end.getFullYear())+'-01-01');break;} if(value==undefined||value=='alltime'){resultdate.date_from='';resultdate.date_to='';}else{resultdate.date_from=ISODateString(begin);resultdate.date_to=ISODateString(end);} return resultdate;} var isArray=(function(){if(Array.isArray){return Array.isArray;} var objectToStringFn=Object.prototype.toString,arrayToStringResult=objectToStringFn.call([]);return function(subject){return objectToStringFn.call(subject)===arrayToStringResult;};}());;angular.module('RestService',[]).service('rest',function($http,$location,$routeParams){return{baseurl:undefined,models:function(){return $http.get(this.url+location.search);},model:function(){return $http.get(this.url+"/"+$routeParams.id);},get:function(options){return $http.get(this.baseurl,{params:options})},postModel:function(model){return $http.post(this.url,model);},putModel:function(model){return $http.put(this.url+"/"+$routeParams.id,model);},deleteModel:function(model){return $http.delete(this.url+"/"+$routeParams.id,model);}};});;angular.module('ElasticService',['elasticsearch']).service('es',function(esFactory){return new esFactory({host:'https://esltv:glghs5z1vttmgseafgdyi10qziwcnq9p@balin-eu-west-1.searchly.com'});});angular.module('ElasticServiceUtil',[]).factory('esUtil',function(){function hasWildcard(str){return str.match(/(^|[^\\])[\*\?]/);} function unescWildcard(str){return str.replace(/\\([\?\*])/g,'$1');} function esEscape(str){return str.replace(/([\+\-\&\|\!\(\)\{\}\[\]\^\"\~\:\/\\])/g,'\\$1');} return{test:function(x){console.log(x);},addQueryCriteria:function(qobj,criteria){if(!qobj.query){qobj.query=criteria;}else if(!qobj.query.and){var arr=[];arr.push(qobj.query);arr.push(criteria);qobj.query={and:arr};}else{qobj.query.and.push(criteria);}},addCriteria:function(qobj,criteria,type){if(!qobj.filter){qobj.filter={};} if(!qobj.filter.bool){qobj.filter.bool={};} if(type=='must'){if(!qobj.filter.bool.must){qobj.filter.bool.must=[];} qobj.filter.bool.must.push(criteria);} if(type=='must_not'){if(!qobj.filter.bool.must_not){qobj.filter.bool.must_not=[];} qobj.filter.bool.must_not.push(criteria);}},addNotCriteria:function(qobj,criteria){if(!qobj.filter){qobj.filter=criteria;}else if(!qobj.filter.not){var arr=[];arr.push(qobj.filter);arr.push(criteria);qobj.filter={not:arr};}else{qobj.filter.not.push(criteria);}},notStringCriteria:function(src,qobj,prop){if(src){var input=src.trim(),len=input.length;if(len>0){if(hasWildcard(src)){var wildcard={};wildcard[prop]=esEscape(src);this.addCriteria(qobj,{query:{wildcard:wildcard}},'must_not');}else{var term={};term[prop]=unescWildcard(src);this.addCriteria(qobj,{query:{term:term}},'must_not');}}}},stringCriteria:function(src,qobj,prop){if(src){var input=src.trim(),len=input.length;if(len>0){if(hasWildcard(src)){var wildcard={};wildcard[prop]=esEscape(src);this.addCriteria(qobj,{query:{wildcard:wildcard}},'must');}else{var term={};term[prop]=unescWildcard(src);this.addCriteria(qobj,{query:{term:term}},'must');}}}},rangeCriteria:function(from,to,qobj,prop){var term={};term[prop]={};term[prop]['from']=from;term[prop]['to']=to;this.addCriteria(qobj,{range:term},'must');},sortCriteria:function(sortby,direction,qobj){qobj.sort=[] var sortcriteria={};sortcriteria[sortby]={};sortcriteria[sortby]['order']=direction;qobj.sort.push(sortcriteria);},selectCriteria:function(src,qobj,prop){var r=src;var term={};if(r.length===1){term[prop]=r[0];this.addCriteria(qobj,{term:term},'must');}else if(r.length>1){term[prop]=r.sort();this.addCriteria(qobj,{terms:term},'must');}},}});;angular.module('VideoService',[]).service('VideoService',['$rootScope','Restangular','es','esUtil',function($rootScope,Restangular,es,esUtil){var Video=new Restangular.all('video/list');var restVideo=new Restangular.all('video/list');var options=[];var busy=false;var foundNothing=false;var service={defaultOptions:{set:'',date_from:'',date_to:'',dateinterval:'',language:'en',page:'1',game:'',basetags:'',hidden:'0',tags:'',deleted:'0',hidden:'0',eslcontent:'1',orderby:'air_time_ts',orderdir:'desc',source_type:['twitch','youtube'],},videos:[],options:[],resultVideos:[],fetchVideos:function(){Video.getList(service.options).then(function(fetchedItems){service.videos=fetchedItems;$rootScope.$broadcast('videos.update');});},resetResults:function(resulttype){service.resultVideos[resulttype]={};foundNothing=false;},fetchData_Json:function(customOptions,resulttype) {var options={};angular.extend(options,service.defaultOptions,customOptions) restVideo.getList(options).then(function(videos){service.resultVideos[resulttype]=videos;$rootScope.$broadcast('resultvideos.update');});},fetchData_Elastic:function(customOptions,resulttype) {var gameSearch=[] var languageSearch=[];var maxHits=30;var dateobj_from,dateobj_to;var debugStartTs,debugEndTs;var hits=new Array;var index;var from;var textSearchParts=[];var notTextSearchParts=[];var options={};var alltags='';foundNothing=false if(customOptions.tags==undefined){customOptions.tags='';} if(customOptions.basetags==undefined){customOptions.basetags='';} if(customOptions.basetags.length>0){if(customOptions.tags.length>0){alltags=customOptions.basetags+' '+customOptions.tags;}else{var alltags=customOptions.basetags;}}else{alltags=customOptions.tags;} console.log("searching for tags: "+alltags);angular.extend(options,service.defaultOptions,customOptions);if(alltags.length>0){var aStr=alltags.match(/[\-\_(a-z)(A-Z)(0-9)]+|"[^"]+"/g),i=aStr.length;while(i--){if(aStr[i][0]!='-'){aStr[i]="*"+aStr[i].replace(/"|/g,"")+"*";}else{notTextSearchParts.push("*"+aStr[i].replace(/"|\ |\-|\_/g,"")+"*");aStr[i]='';}} textSearchParts=aStr;} if(options.game){gameSearch=options.game.split(",");} if(options.language){languageSearch=options.language.split(",");} if(options.date_from==''){options.date_from='1970-01-01';} dateobj_from=new Date(options.date_from);if(options.date_to==''){dateobj_to=new Date();}else{dateobj_to=new Date(options.date_to);} from=((options.page-1)*maxHits)-1;if(from<0){from=0;} var q={};if(textSearchParts.length){for(index=0;index0){channelselect_width=channelselect_width+6;} var maxWidth=window.innerWidth-4-live_sidebar_width-channelselect_width;}else{var maxWidth=container.clientWidth;} if((maxHeight/maxWidth)<0.5625){var newHeight=maxHeight;var newWidth=newHeight/0.5625;}else{var newWidth=maxWidth;var newHeight=newWidth*0.5625;} jQuery(elem).height(newHeight);jQuery(elem).width(newWidth);},100);} scope.onResize();angular.element($window).bind('resize',function(){scope.onResize();})}}}]);UIresize.directive('setplayermode',function(VideoplayerService){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){Videoplayer.setPlayerMode(attrs.newmode);});};});UIresize.directive('setchatmode',function(VideoplayerService){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){Videoplayer.setChatMode('toggle');});};});UIresize.directive('customstyle',function(){return{restrict:'E',transclude:true,replace:true,scope:{event:'='},template:''}});;var VideoModule=angular.module('VideoDirective',[]);VideoModule.directive("tagCloud",function($filter,$compile){var linker=function(scope,element,attrs){attrs.$observe('tags',function(alltags){var tags=angular.fromJson(alltags);var outhtml='';outhtml='
Tags
';var length=tags.length,tag=null;var manual_tags=0;for(var i=0;i'+tag+'';}} outhtml+='
';element.html(outhtml);$compile(element.contents())(scope);});} return{restrict:"E",replace:true,link:linker,scope:{content:'='}}});VideoModule.directive("videoInfo",function($filter){var linker=function(scope,element,attrs){attrs.$observe('video',function(videoJson){var video=JSON.parse(videoJson);if(video.air_time_ts!=undefined){var downloadlinkhtml='';if(video.downloadlink){downloadlinkhtml='
Download HD File
';} element.html('
'+'
'+'
'+$filter('date')(video.air_time_ts*1000,'MMM dd, yyyy')+'
'+'
'+video.game+'
'+'
'+$filter('number')(video.views,0)+'
'+ downloadlinkhtml+'
'+'
');}else{element.html('
'+'
'+'
'+video.name+'
'+'
'+$filter('number')(video.viewers,0)+' viewers
'+'
'+video.game+'
'+'
'+'
');}});} return{restrict:"E",replace:true,link:linker,scope:{content:'='}}});VideoModule.directive("showContentArea",function(VideoplayerService,VideoService){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){if(Videoplayer.currentPlayerMode=='player_theatre'||Videoplayer.currentPlayerMode=='player_fullscreen'){Videoplayer.setPlayerMode('medium');}});};});VideoModule.directive("playstvVideo",function(){var linker=function(scope,element,attrs){attrs.$observe('source',function(srcJson){var src=JSON.parse(srcJson);if(src.source_id){element.html('
'+''+'
');}else{element.html("
");}});} return{restrict:"E",replace:true,link:linker,scope:{content:'='}}});VideoModule.directive("twitchVideo",function(){var linker=function(scope,element,attrs){attrs.$observe('source',function(srcJson){var src=JSON.parse(srcJson);if(src.source_id){element.html('
'+' '+' '+' '+' '+' '+' '+' '+'
');}else{element.html("
");}});} return{restrict:"E",replace:true,link:linker,scope:{content:'='}}});VideoModule.directive("twitchLive",function(){var linker=function(scope,element,attrs){attrs.$observe('source',function(srcJson){var src=JSON.parse(srcJson);if(src.twitch_account){element.html('');}else{element.html("
");}});} return{restrict:"E",replace:true,link:linker,scope:{content:'='}}});VideoModule.directive("playLiveevent",function(VideoplayerService,VideoService,$location,$window){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){var url=$location.url();if(url.includes(attrs.eventurl)){var base_url=attrs.eventurl+'/';}else{var base_url='/';} Videoplayer.playLive(attrs.channelurl,attrs.channelservice);if(window.innerWidth>1000){$location.path(base_url+attrs.channelservice+'/'+attrs.channelurl+'/',false);} if($scope.event.gosquaredaccount){_gs($scope.event.gosquaredaccount);}});};});VideoModule.directive("playLive",function(VideoplayerService,VideoService,$location,$window){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){$location.path('/channel/'+attrs.channelurl,false);$window.scrollTo(0,0);Videoplayer.playLive(attrs.channelurl);if(Videoplayer.currentPlayerMode=='player_off'||Videoplayer.currentPlayerMode=='player_close'){Videoplayer.setPlayerMode(Videoplayer.default_layout);}});};});VideoModule.directive("setSearch",function(VideoService,$location,$window){var sVideos=VideoService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){$location.path(attrs.path,false).search({tags:attrs.tag});;$location.$$compose();console.log("setting search to: "+attrs.tag);$scope.$emit('videosearch.forceupdate');});};});VideoModule.directive("playVideo",function(VideoplayerService,VideoService,$location,$window){var Videoplayer=VideoplayerService;return function($scope,elem,attrs){jQuery(elem).on('click',function(){$location.path('/video/'+attrs.videourl,false);$location.$$search={};$location.$$compose();$window.scrollTo(0,0);Videoplayer.setChatMode('off');Videoplayer.playVideo(attrs.videourl);if(Videoplayer.currentPlayerMode=='player_off'||Videoplayer.currentPlayerMode=='player_close'){Videoplayer.setPlayerMode(Videoplayer.default_layout);}});};});VideoModule.directive("videoItem",function($compile){var imageTemplate='

 

entry photo
{{content.title}}
{{content.description}}
';var videoTemplate='

 

{{content.title}}
{{content.description}}
';var noteTemplate='

 

{{content.title}}
{{content.data}}
';var shortTemplate='
'+'
{{content.game}}
'+'
'+'

{{content.title_clean}}

'+'
';var mediumTemplate=''+'
'+' '+' '+'
{{ content.title | limitTo : 100 }}
'+'
'+' {{ content.game }}'+' {{ content.air_time_ts * 1000 | date:\'MMM dd, yyyy\' }}'+' {{ content.views | number:0 }}'+'
'+'
';var largeTemplate=''+'
'+'
'+'
{{ content.title_clean | removeTitle:titleremove | limitTo : 100 }}
'+'
'+'
'+'
'+'
';var wideTemplate=''+'
'+'
'+'
'+'

{{ content.air_time_ts * 1000 | date:\'MMM dd, yyyy\' }}

{{ content.air_time_ts * 1000 | date:\'HH:mm\' }}

'+'

{{ content.game | game2dir }}

'+'
'+'

{{ content.title_clean | removeTitle:titleremove | limitTo : 100 }} ({{content.language}})

'+'

{{ content.views | number:0 }}

'+' '+'
'+'
'+'
';var largeTemplateVideoset=''+'
'+'
'+'
{{ content.title }}
'+'
'+' '+'
';var playerYoutubeTemplate=''+''+'';var playerTwitchTemplate=''+'
'+' '+' '+' '+' '+' '+' '+' '+'
'+'';var getTemplate=function(contentType){var template='';switch(contentType){case'image':template=imageTemplate;break;case'video':template=videoTemplate;break;case'short':template=shortTemplate;break;case'medium':template=mediumTemplate;break;case'large':template=largeTemplate;break;case'videoset_large':template=largeTemplateVideoset;break;case'wide':template=wideTemplate;break;case'youtube':template=playerYoutubeTemplate;break;case'twitch':template=playerTwitchTemplate;break;} return template;} var linker=function(scope,element,attrs){element.html(getTemplate(attrs.layout));$compile(element.contents())(scope);} return{replace:true,link:linker,scope:{content:'=',titleremove:'=',}};});;(function(){var moduleName='angularUtils.directives.dirDisqus';var module;try{module=angular.module(moduleName);}catch(err){module=angular.module(moduleName,[]);} module.directive('dirDisqus',['$window',function($window){return{restrict:'E',scope:{disqus_shortname:'@disqusShortname',disqus_identifier:'@disqusIdentifier',disqus_title:'@disqusTitle',disqus_url:'@disqusUrl',disqus_category_id:'@disqusCategoryId',disqus_disable_mobile:'@disqusDisableMobile',disqus_config_language:'@disqusConfigLanguage',disqus_remote_auth_s3:'@disqusRemoteAuthS3',disqus_api_key:'@disqusApiKey',readyToBind:"@"},template:'
comments powered by Disqus',link:function(scope){if(typeof scope.disqus_identifier==='undefined'||typeof scope.disqus_url==='undefined'){throw"Please ensure that the `disqus-identifier` and `disqus-url` attributes are both set.";} scope.$watch("readyToBind",function(isReady){if(!angular.isDefined(isReady)){isReady="true";} if(scope.$eval(isReady)){console.log('remote'+scope.disqus_remote_auth_s3);$window.disqus_shortname=scope.disqus_shortname;$window.disqus_identifier=scope.disqus_identifier;$window.disqus_title=scope.disqus_title;$window.disqus_url=scope.disqus_url;$window.disqus_developer=1;$window.disqus_category_id=scope.disqus_category_id;$window.disqus_disable_mobile=scope.disqus_disable_mobile;$window.disqus_config=function(){this.language=scope.disqus_config_language;this.page.remote_auth_s3=scope.disqus_remote_auth_s3;this.page.api_key=scope.disqus_api_key;};if(!$window.DISQUS){var dsq=document.createElement('script');dsq.type='text/javascript';dsq.async=true;dsq.src='//'+scope.disqus_shortname+'.disqus.com/embed.js';(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(dsq);}else{$window.DISQUS.reset({reload:true,config:function(){this.page.identifier=scope.disqus_identifier;this.page.url=scope.disqus_url;this.page.developer=scope.disqus_developer;this.page.title=scope.disqus_title;this.language=scope.disqus_config_language;this.page.remote_auth_s3=scope.disqus_remote_auth_s3;this.page.api_key=scope.disqus_api_key;}});}}});}};}]);})();;angular.module('MainCtrl',[]).controller('MainController',function($scope,$window,$location,$timeout,VideoplayerService,GameService){var PlayerService=VideoplayerService;var sGames=GameService;$scope.$on('videoplayer.newmode',function(event){$scope.currentPlayerMode=PlayerService.currentPlayerMode;$scope.currentChatMode=PlayerService.currentChatMode;$scope.allchannelsbyurl=PlayerService.allchannelsbyurl;$timeout(function(){jQuery(window).trigger("resize");},50);});$scope.currentPlayerMode=PlayerService.currentPlayerMode;$scope.currentChatMode=PlayerService.currentChatMode;$scope.allchannelsbyurl=PlayerService.allchannelsbyurl;$scope.$on('videosearch.forceupdate',function(event,next,current){$scope.$broadcast('videosearch.showdata');});$scope.$on('$routeChangeSuccess',function(event){dataLayer.push({'event':'VirtualPageview','virtualPageURL':$location.url()});});$scope.$on('games.update',function(event){$scope.games=sGames.games;});$scope.games=sGames.games;});;angular.module('HomeCtrl',[]).controller('HomeController',function($scope,GameService){var sGames=GameService;sGames.fetchGames();});;angular.module('ScheduleCtrl',[]).controller('ScheduleController',function($scope,$document,$rootScope,rest,$filter){$scope.channel={};$scope.alldays=[];$scope.days2show=3;$scope.totalshows=0;$scope.schedulePadding=0;$scope.showLoadingIndicator=true;var showNumPerGame={};var numBig=0;var day_index=1;var alldays=[];var alldayspergame=[];var page=0;var foundNothing=false;function loadItems(){var foundItems=0;rest.baseurl='http://dev.api.esl.tv/v1/schedule/byweek?language=&page='+page;rest.get().success(function(response){Object.keys(response.items).forEach(function(element_w,index_w){Object.keys(response.items[index_w].days).forEach(function(element_d,index_d){if($scope.totalshows<=12&&day_index<=7){$scope.days2show=day_index;} foundItems++;if(angular.isObject(response.items[index_w].days[index_d].shows)){day_index++;Object.keys(response.items[index_w].days[index_d].shows).forEach(function(element,index){var game=response.items[index_w].days[index_d].shows[index].game_icon;if(showNumPerGame[game]==undefined){showNumPerGame[game]=1;}else{showNumPerGame[game]+=1;} $scope.totalshows++;response.items[index_w].days[index_d].shows[index].numingame=showNumPerGame[game];if(showNumPerGame[game]<=1){response.items[index_w].days[index_d].shows[index].numwithingameclass='bigitem';} if((showNumPerGame[game]<=1&&numBig<1)||(response.items[index_w].days[index_d].shows[index].islive&&!response.items[index_w].days[index_d].shows[index].rerun)){response.items[index_w].days[index_d].shows[index].numclass='bigitem';numBig+=1;}else{response.items[index_w].days[index_d].shows[index].numclass='';}});} alldays.push(response.items[index_w].days[index_d]);});});$scope.alldays=alldays;$scope.allweeks=response.items;$scope.showLoadingIndicator=false;$scope.$broadcast('content.changed');if(foundItems==0){foundNothing=true;}});} loadItems();function getChannelInfo(channelurl){rest.baseurl='http://cdn1.api.esl.tv/v1/channel/viewbyurl/'+channelurl;rest.get().success(function(response){$scope.channel[channelurl]=response.items[0];});} $scope.moveSchedule=function(direction) {var offset=300;if(direction=='down'){$scope.schedulePadding=$scope.schedulePadding-offset;}else{$scope.schedulePadding=$scope.schedulePadding+offset;} if($scope.schedulePadding>0){$scope.schedulePadding=0;} $scope.schedulestyle={'top':$scope.schedulePadding+'px'}} $scope.loadMore=function(overridemax) {if(foundNothing==false||foundNothing==undefined){page++;loadItems();}} $scope.showsWithFilter=function(day,filter){var hasShows=0;if(day.shows){Object.keys(day.shows).forEach(function(element,index){if(filter['game']){if(day.shows[index].game==filter['game']){hasShows=1;}} if(filter['event_short']){if(day.shows[index].event_short==filter['event_short']){hasShows=1;}}});} return hasShows;} $scope.isToday=function(ts){if($filter('date')(ts*1000,"y-MM-d")==$filter('date')(new Date().getTime(),"y-MM-d")){return 1;}else{return 0;}} $scope.isTomorrow=function(ts){var d=new Date().getTime();if($filter('date')(ts*1000,"y-MM-d")==$filter('date')(d+60*60*24*1000,"y-MM-d")){return 1;}else{return 0;}}});;angular.module('ChangelogCtrl',[]).controller('ChangelogController',function($scope,rest){$scope.showLoadingIndicatorChangelog=true;$scope.showLoadingIndicatorTodo=true;rest.baseurl='http://dev.api.esl.tv/v1/changelog/list';rest.get().success(function(response){$scope.allItems=response;$scope.showLoadingIndicatorChangelog=false;});rest.baseurl='http://dev.api.esl.tv/v1/changelog/todo';rest.get().success(function(response){$scope.allItemsTodo=response;$scope.showLoadingIndicatorTodo=false;});});;angular.module('ChannelCtrl',[]).controller('ChannelController',function($scope,rest,$routeParams,VideoplayerService){var Videoplayer=VideoplayerService;if($routeParams.channelUrl=='esl-lol'&&$routeParams.serviceProvider==undefined){var targeturls=new Array("channel/esl-lol/twitch/","channel/esl-lol/hitbox/","channel/esl-lol/azubu/");var targetindex=Math.floor(Math.random()*targeturls.length);var targeturl=targeturls[targetindex];window.location.replace(targeturl);} if($routeParams.channelUrl){Videoplayer.setPlayerMode('theatre');Videoplayer.playLive($routeParams.channelUrl,$routeParams.serviceProvider);}});;angular.module('VideoArchiveCtrl',[]).controller('VideoArchiveController',function($scope,$timeout,$route,$location,EventService,GameService,Restangular,VideoplayerService,$routeParams,VideoService){var sEvents=EventService;var Videoplayer=VideoplayerService;var sGames=GameService;var eventInfo={};var topVideos;var videoscope='esltv';if($scope.cmsparams!==undefined){if($scope.cmsparams['scope']){videoscope=$scope.cmsparams['scope'];}} var restVideoset=Restangular.all('videoset/list?scope='+videoscope);restVideoset.getList().then(function(items){$scope.sets=items;});$scope.$on('games.update',function(event){$scope.games=sGames.games;});$scope.games=sGames.games;sGames.fetchGames($scope.cmsparams);$scope.videoOptions={};$scope.videoOptions.tags='';$scope.videoOptions.orderby='air_time_ts';$scope.videoOptions.language='en';$scope.videoOptions.dateinterval='alltime';for(var key in $scope.cmsparams){if($scope.cmsparams[key]){$scope.videoOptions[key]=$scope.cmsparams[key];}} $scope.$broadcast('videosearch.showdata');if($routeParams.videoUrl){Videoplayer.setPlayerMode('theatre');Videoplayer.playVideo($routeParams.videoUrl);}else{if($location.url()){var hashurlvideoid=$location.url().split('/')[2];if(hashurlvideoid){hashurlvideoid=hashurlvideoid.split('?')[0];if(hashurlvideoid){Videoplayer.setPlayerMode('theatre');Videoplayer.playVideo(hashurlvideoid);}}}}});;angular.module('VideoCtrl',[]).controller('VideoController',function($scope,VideoService,EventService,GameService,$timeout,$cookies){$scope.options={};var Videos=VideoService;var sEvents=EventService;var sGames=GameService;$scope.topvideos={};$scope.$on('resultvideos.update',function(event){$scope.items=Videos.resultVideos.latest;});$scope.items=Videos.resultVideos.latest;var default_options={event:'',date_from:'',date_to:'',dateinterval:'',language:'en',featured:'',page:'1',game:'',tags:'',hidden:'0',eslcontent:'1',orderby:'air_time_ts',};$scope.setDefaultOptions=function(){for(var key in default_options){if(default_options.hasOwnProperty(key)){$scope.setOption(key,default_options[key]);}}} $scope.setOption=function(field,value) {if(value==undefined){value='';} $scope.options[field]=value;} function showDataJsonData() {Videos.fetchData_Json($scope.options,'latest');} $scope.$on('currentevent.update',function(event){var tempOptions={};$scope.currentevent=sEvents.currentevent;tempOptions.tags=$scope.currentevent.tags;tempOptions.orderby='views';Videos.fetchData_Elastic(tempOptions,'featured');$scope.$on('resultvideos.update',function(event){$scope.featuredvideos=Videos.resultVideos.featured;});});$scope.$on('currentgame.update',function(event){var tempOptions={};$scope.currentgame=sGames.currentgame;tempOptions.game=$scope.currentgame.fullname;tempOptions.orderby='views';var begin=new Date();var end=new Date();begin=new Date(begin.getFullYear()+'-'+begin.getMonthFormatted(-6)+'-01');end=new Date(end.getFullYear()+'-'+end.getMonthFormatted(0)+'-01');tempOptions.date_from=ISODateString(begin);tempOptions.date_to=ISODateString(end);Videos.fetchData_Elastic(tempOptions,'featured');$scope.$on('resultvideos.update',function(event){$scope.featuredvideos=Videos.resultVideos.featured;});});$scope.setDefaultOptions();showDataJsonData();});;angular.module('VideosearchCtrl',[]).controller('VideosearchController',function($rootScope,$scope,$location,$routeParams,VideoService,VideoplayerService,Restangular,$routeParams,$timeout){$scope.dateintervals=[{name:'Alltime',value:'alltime'},{name:'Today',value:'today'},{name:'This week',value:'thisweek'},{name:'This Month',value:'thismonth'},{name:'This Year',value:'thisyear'},{name:'Last week',value:'lastweek'},{name:'Last Month',value:'lastmonth'},{name:'Last Year',value:'lastyear'},];$scope.orderbys=[{name:'Date',value:'air_time_ts',direction:'desc'},{name:'Views',value:'views',direction:'desc'},{name:'Trending',value:'score',direction:'desc'},];$scope.languages=[{name:'All',value:'','icon':'global'},{name:'German',value:'de','icon':'de'},{name:'English',value:'en','icon':'en'},{name:'French',value:'fr','icon':'fr'},{name:'Russian',value:'ru','icon':'ru'},{name:'Spanish',value:'es','icon':'es'},{name:'Polish',value:'pl','icon':'pl'},];if($scope.cmsparams!==undefined){if($scope.cmsparams['localeString']=='ru-ru'){$scope.dateintervals=[{name:'За все время',value:'alltime'},{name:'Сегодня',value:'today'},{name:'Текущая неделя',value:'thisweek'},{name:'Текущий месяц',value:'thismonth'},{name:'Текущий год',value:'thisyear'},{name:'Прошлая неделя',value:'lastweek'},{name:'Прошлый месяц',value:'lastmonth'},{name:'Прошлый год',value:'lastyear'},];$scope.orderbys=[{name:'Дате',value:'air_time_ts',direction:'desc'},{name:'Просмотрам',value:'views',direction:'desc'},{name:'Популярности',value:'score',direction:'desc'},];$scope.languages=[{name:'*',value:'','icon':'global'},{name:'German',value:'de','icon':'de'},{name:'English',value:'en','icon':'en'},{name:'French',value:'fr','icon':'fr'},{name:'Русский',value:'ru','icon':'ru'},{name:'Spanish',value:'es','icon':'es'},{name:'Polish',value:'pl','icon':'pl'},];}} var default_options={set:'',date_from:'',date_to:'',dateinterval:'',language:'en',page:'1',game:'',tags:'',eslcontent:'1',orderby:'air_time_ts',orderdir:'desc',};var base_options={} var isGetParamSearch;var sVideos=VideoService;var Videoplayer=VideoplayerService;var today=new Date();var numVideos=0;var busy=1;$scope.$on('resultvideos.update',function(event){$scope.videos=sVideos.resultVideos.search;$scope.foundNothing=sVideos.foundNothing;if($scope.videos!=undefined){$scope.numVideos=$scope.videos.length;}});$scope.$on('videosearch.showdata',function(event,next,current){$scope.setGetParams();sVideos.resetResults();showData();});$scope.setGetParams=function(){for(var key in default_options){var $fieldname=key;var fieldvalue=$location.search()[$fieldname];if($location.search()[$fieldname]){$scope.setOption(key,fieldvalue);isGetParamSearch=true;}else if(base_options[$fieldname]){$scope.setOption($fieldname,base_options[$fieldname]);}else{if($scope.videoOptions[key]==undefined){$scope.setOption(key,default_options[key]);}else{}}} $scope.userinputsearch=$scope.videoOptions.tags;} $scope.setDefaultOptions=function() {for(var key in default_options){var $fieldname=key;var fieldvalue=default_options[$fieldname];if($fieldname!='game'&&$fieldname!='event'){$scope.setOption($fieldname,fieldvalue);}} showdata();} $scope.loadMore=function(overridemax) {if(sVideos.foundNothing==false||sVideos.foundNothing==undefined){if($scope.videoOptions.page<=50||overridemax==1){$scope.videoOptions.page++;showData();}}} $scope.getSetData=function(key) {} $scope.isActive=function(field,value) {if(value==''){if($scope.videoOptions[field]==''){return true;}else{return false;}} var re=new RegExp(value+"","i");return re.test($scope.videoOptions[field]);} $scope.setOption=function(field,value){$scope.videoOptions[field]=value;setUrlGetParam(field,value);} $scope.setBaseOption=function(field,value){base_options[field]=value;} $scope.setOptionAndReload=function(field,value){resetResults();if($scope.videoOptions[field]==value){if(field=='orderby'){if($scope.videoOptions['orderdir']=='asc'){$scope.videoOptions['orderdir']='desc';}else{$scope.videoOptions['orderdir']='asc';}}else{$scope.videoOptions[field]='';}}else{$scope.videoOptions[field]=value;} setUrlGetParam(field,value);showData();} var resetResults=function(){sVideos.resetResults('search');if($scope.videoOptions!==undefined){$scope.videoOptions.page=1;}} var setUrlGetParam=function(field,value){if(field!='eslcontent'&&(value!=default_options[field]||(value!=$location.search()[field]&&$location.search()[field]!=undefined))){$location.search(field,value);}} $scope.setItemsize=function(size){switch(size){case'wide':$scope.itemsize_type='wide';$scope.itemsize_class='widevideo-item';break;case'large':$scope.itemsize_type='large';$scope.itemsize_class='bigvideo-item';break;default:$scope.itemsize_type='wide';$scope.itemsize_class='widevideo-item';}} $scope.setLanguages=function(langsstr){var langs=langsstr.split(",");var showlang=[] for(var key in langs){showlang[langs[key]]=true;} var new_languages=[] for(var key in $scope.languages){if(showlang[$scope.languages[key]['value']]==true||key==0){new_languages.push($scope.languages[key])}} $scope.languages=new_languages} if($scope.cmsparams!==undefined){$scope.setItemsize($scope.cmsparams['defaultitemsize']);$scope.setLanguages($scope.cmsparams['languages']);}else{$scope.setItemsize();} $scope.setOptionsAndReload=function(field,unique,setdata){resetResults();$scope.setOption(field,unique);$scope.set=setdata;var begingate=new Date();if(setdata.option_date_from_special=='2weeks'){begingate.setDate(begingate.getDate()-14);setdata.option_date_from=ISODateString(begingate);} if(setdata.option_date_from_special=='4weeks'){begingate.setDate(begingate.getDate()-28);setdata.option_date_from=ISODateString(begingate);} if(setdata.option_date_from_special=='1week'){begingate.setDate(begingate.getDate()-7);setdata.option_date_from=ISODateString(begingate);} if(setdata.option_date_to=='today'){setdata.option_date_to=ISODateString(today);} for(var key in setdata){if(key.substring(0,7)=='option_'){option_key=key.substring(7);$scope.setOption(option_key,setdata[key]);}} $scope.userinputsearch=$scope.videoOptions.tags;} $scope.setTagsAndReload=function(value){$scope.videoOptions['tags']=value;$scope.userinputsearch=value;showData();} $scope.resetOptionsAndReload=function(){$scope.userinputsearch='';showData();} $scope.setIntervallAndReload=function(value){resetResults();var begin=new Date();var end=new Date();switch(value){case'today':break;case'thisweek':begin.setDate(getMonday(begin,0));break;case'thismonth':begin=new Date(begin.getFullYear()+'-'+begin.getMonthFormatted(0)+'-01');break;case'thisyear':begin=new Date(begin.getFullYear()+'-01-01');break;case'lastweek':begin.setDate(getMonday(begin,7));end.setDate(getMonday(end,1));break;case'lastmonth':begin=new Date(begin.getFullYear()+'-'+begin.getMonthFormatted(-1)+'-01');end=new Date(end.getFullYear()+'-'+end.getMonthFormatted(0)+'-01');break;case'lastyear':begin=new Date((begin.getFullYear()-1)+'-01-01');end=new Date((end.getFullYear())+'-01-01');break;} if(value=='alltime'){$scope.setOption('dateinterval','');$scope.setOption('date_from','');$scope.setOption('date_to','');$scope.videoOptions.date_from='';$scope.videoOptions.date_to='';}else{$scope.setOption('dateinterval',value);$scope.setOption('date_from',ISODateString(begin));$scope.setOption('date_to',ISODateString(end));$scope.videoOptions.date_from=ISODateString(begin);$scope.videoOptions.date_to=ISODateString(end);} showData();} $scope.$watch('userinputsearch',function(newValue,oldValue){if(newValue===oldValue){return;} resetResults();$scope.videoOptions.tags=newValue;setUrlGetParam('tags',newValue);showData();});function updateSubsets() {var restSubset=new Restangular.all('videosubset/list');var options={};options.event=$scope.videoOptions.event_uid;options.game=$scope.videoOptions.game_uid;options.videoset=$scope.videoOptions.videoset_uid;restSubset.getList(options).then(function(items){$scope.subsets=items;});} function showData() {sVideos.fetchData_Elastic($scope.videoOptions,'search');} resetResults();$scope.setGetParams();if(isGetParamSearch){showData();}else{showData();}});;angular.module('VideofeaturedCtrl',[]).controller('VideofeaturedController',function($scope,$rootScope,VideoService,GameService){var Videos=VideoService;var sGames=GameService;var searchOptions={};var identifier;$scope.setOptions=function(argIdentifier,argOptions){var interval=getDatesByInterval(argOptions.interval);argOptions.date_from=interval.date_from;argOptions.date_to=interval.date_to;argOptions.interval='';searchOptions=argOptions;identifier=argIdentifier;} $scope.setOptionsAndLoad=function(argIdentifier,argOptions){Videos.resetResults();$scope.setOptions(argIdentifier,argOptions);$rootScope.$broadcast('fetchvideos.featured',argOptions,identifier);} $scope.$on('currentgame.update',function(event){$scope.currentgame=sGames.currentgame;searchOptions.game=$scope.currentgame.fullname;$rootScope.$broadcast('fetchvideos.featured',searchOptions,identifier);});$rootScope.$on('resultvideos.update',function(event){console.log(identifier);$scope.homefeaturedvideos=Videos.resultVideos[identifier];});});;angular.module('VideosetCtrl',[]).controller('VideosetController',function($scope,$rootScope,Restangular){var restVideosets=new Restangular.all('videoset/list?type=feature');var searchOptions={};var videosets={};$scope.setOptions=function(argOptions){searchOptions=argOptions;} $scope.setOptionsAndLoad=function(argOptions){searchOptions=argOptions;$scope.fetchItems();} $scope.fetchItems=function(){restVideosets.getList(searchOptions).then(function(fetchedItems){$scope.videosets=fetchedItems;});}});;angular.module('GameCtrl',[]).controller('GameController',function($scope,GameService,$routeParams){var sGames=GameService;var gameInfo={};$scope.videoOptions={};$scope.videoOptions.orderby='air_time_ts';$scope.videoOptions.language='en';$scope.videoOptions.dateinterval='alltime';if($routeParams.gameUrl){sGames.getGameinfoByUrl($routeParams.gameUrl);$scope.$on('currentgame.update',function(event){$scope.currentgame=sGames.currentgame;$scope.videoOptions.game=$scope.currentgame.fullname;$scope.videoOptions.game_uid=$scope.currentgame.uid;$scope.$broadcast('videosearch.showdata');$scope.$broadcast('content.changed');});}else{}});;angular.module('CoffeescreenCtrl',[]).controller('CoffeescreenController',function($scope,$interval,Restangular,VideoService,VideoplayerService){var maxMinutesPerVideo=10;var maxVideos=50;var isTopShowLive=0;var sVideos=VideoService;$scope.currentVideoIndex=-1;$scope.totalVideos=0;$('#networkbar_tvouter').css('display','none');$scope.playTopLive=function(){var Videoplayer=VideoplayerService;var restSchedule=new Restangular.all('schedule/list');var scheduleOptions=[];var shows;var liveshow=[];liveshow['channel']=[];liveshow['channel']['viewers']=0;restSchedule.getList(scheduleOptions).then(function(fetchedItems){shows=fetchedItems;var index;for(index=0;index20000){if(shows[index]['channel']['viewers']>liveshow['channel']['viewers']){liveshow=shows[index];}}} if(liveshow['islive']){$scope.theBestVideo='';isTopShowLive=1;Videoplayer.setPlayerMode('fullscreen');Videoplayer.playLive(liveshow['channel_url']);}else{isTopShowLive=0;} $scope.$broadcast('topshowchecked');});} $scope.playerVars={controls:1,autoplay:1};$scope.videoOptions={};$scope.videoOptions.orderby='score';$scope.videoOptions.orderdir='desc';$scope.videoOptions.language='en';$scope.$broadcast('videosearch.showdata');sVideos.fetchData_Elastic($scope.videoOptions,'search');$scope.$on('resultvideos.update',function(event){$scope.videos=sVideos.resultVideos.search;$scope.playTopLive();$scope.$on('topshowchecked',function(event){if(!isTopShowLive){$scope.totalVideos=$scope.videos.length;$scope.nextvideo();}});});$scope.$on('youtube.player.ended',function($event,player){$scope.playTopLive();$scope.$on('topshowchecked',function(event){if(!isTopShowLive){console.log("starting next video..");}});});$scope.nextvideo=function(){console.log("nextvideo loop..");$scope.currentVideoIndex++;if($scope.currentVideoIndex==$scope.videos.length||$scope.currentVideoIndex==maxVideos){$scope.currentVideoIndex=0;location.reload();} if(!isTopShowLive){$scope.theBestVideo=$scope.videos[$scope.currentVideoIndex]['youtube_id'];$scope.currentVideo=$scope.videos[$scope.currentVideoIndex];} var stop=$interval(function(){$scope.nextvideo();},maxMinutesPerVideo*60*1000);}});;angular.module('LiveCtrl',[]).controller('LiveController',function($scope,$interval,$window,$timeout,$cookies,Restangular,VideoService,EventService,$routeParams,$route,rest,VideoplayerService,$location){var sEvents=EventService;var eventInfo={};var Videoplayer=VideoplayerService;$scope.channelselectstate='open';$scope.sidebarstate='sidebaropen';$scope.hideService={};$scope.hideGame={};if(window.innerWidth<1224){$scope.sidebarstate='sidebarclosed';} if($cookies.get('hideModal')&&$routeParams.modal!=1){$scope.hideModal=true;};var islivestats=0;if($route.current.$$route.livestats=='livestats'){islivestats=1;};$scope.stats={};$scope.partner_count_modifier=1;var eventUrl=$routeParams.eventUrl var channelUrl=$routeParams.channelUrl var channelService=$routeParams.channelService var livedomain=$location.host();var liveurl="/"+eventUrl;$scope.liveurl=liveurl;var hash=$location.hash();if(liveurl==''||liveurl=="/undefined"){liveurl='/';} if($routeParams.livedomain){livedomain=$routeParams.livedomain;}else{if(livedomain=='dev.tv.eslgaming.com'){livedomain='live.esl-one.com';}} if($routeParams.fullscreen==1){$scope.fullscreen='fullscreen';}else{$scope.fullscreen='nofullscreen';} sEvents.getEventinfoByUrl(livedomain,liveurl);$scope.$on('currentevent.update',function(event){$scope.event=sEvents.currentevent;$window.document.title=$scope.event.fulltitle+" LIVE";if($scope.event.games){$scope.games=$scope.event.games.split(",");} $scope.updateChannels();if(channelUrl==undefined){var defaultchannels=JSON.parse($scope.event.defaultchannels);var numchannels=defaultchannels['channels']["/"].length;var randomchannelid=Math.floor((Math.random()*numchannels)) var startchannel=defaultchannels['channels']["/"][randomchannelid];Videoplayer.playLive(startchannel.url);}else{Videoplayer.playLive(channelUrl,channelService);} var sidepanels=JSON.parse($scope.event.sidepanels);$scope.sidepanels=sidepanels.games.default;for(var prop in $scope.sidepanels){$scope.visible_sidepanel=$scope.sidepanels[prop].id;break;} $scope.updateStatstotal();rest.baseurl='https://cdn1.api.esl.tv/v1/partner/list?pid='+$scope.event.pidsponsors;rest.get().success(function(response){$scope.partners=response;var maxheight=70;var biggestsize=0;var scale=0;angular.forEach($scope.partners,function(value,key){if($scope.partners[key]['imagesize']>biggestsize){biggestsize=$scope.partners[key]['imagesize'];}});scale=maxheight/biggestsize;angular.forEach($scope.partners,function(value,key){if($scope.partners[key]['tier']=='gold'){value['imagesize']=maxheight;} $scope.partners[key]['calcedheight']=value['imagesize']*scale*$scope.event.partnerscale;});});if(window.innerWidth>1224){stop=$interval(function(){if($scope.channelselectstate=='open'){$scope.toggle_channeselectstate();}},1000*45,1);} if($scope.event.gosquaredaccount){_gs($scope.event.gosquaredaccount);}});$scope.openpanel=function(id){$scope.visible_sidepanel=id;};$scope.toggle_channeselectstate=function(){if($scope.channelselectstate=='closed'){$scope.channelselectstate='open';}else{$scope.channelselectstate='closed';} $timeout(function(){jQuery(window).trigger("resize");},100);};$scope.toggle_sidebarstate=function(){if($scope.sidebarstate=='sidebarclosed'){$scope.sidebarstate='sidebaropen';}else{$scope.sidebarstate='sidebarclosed';} $timeout(function(){jQuery(window).trigger("resize");},100);};$scope.getChartData=function(){var hiddenservices='';var hiddengames='';angular.forEach($scope.hideService,function(value,key){if($scope.hideService[key]==1){hiddenservices=hiddenservices+key+',';}});angular.forEach($scope.hideGame,function(value,key){if($scope.hideGame[key]==1){hiddengames=hiddengames+key+',';}});rest.baseurl='https://cdn1.api.esl.tv/v1/channel/eventchannelshistory?pid='+$scope.event.pidchannels+'&hideservice='+hiddenservices+'&hidegame='+hiddengames;rest.get().success(function(response){$scope.history=response['items'];$scope.peak=$scope.history.stats.peak;if($scope.peak!==undefined&&$scope.sumviewers.total>$scope.peak){$scope.peak=$scope.sumviewers.total;} $scope.labels=$scope.history.legend;$scope.data=$scope.history.data.total;$scope.datasetOverride=[{yAxisID:'y-axis-1'}];$scope.options={datasets:{fill:[0]},elements:{line:{borderWidth:0.5},point:{radius:0}},scales:{yAxes:[{id:'y-axis-1',type:'linear',display:true,position:'left'}]}};});};$scope.updateChannels=function(){if(islivestats){$scope.getChartData();rest.baseurl='https://cdn1.api.esl.tv/v1/channel/eventchannels?pid='+$scope.event.pidchannels;rest.get().success(function(response){$scope.channels=response;$scope.calcSumviewers();$scope.lastupdate=new Date();});stop=$interval(function(){rest.baseurl='https://cdn1.api.esl.tv/v1/channel/eventchannels?pid='+$scope.event.pidchannels;rest.get().success(function(response){$scope.channels=response;$scope.calcSumviewers();$scope.getChartData();$scope.lastupdate=new Date();});},1000*20);}else{rest.baseurl='https://cdn1.api.esl.tv/v1/channel/eventchannels?pid='+$scope.event.pidchannels+'&hideservice=web,digitalpass';rest.get().success(function(response){$scope.channels=response;});stop=$interval(function(){rest.baseurl='https://cdn1.api.esl.tv/v1/channel/eventchannels?pid='+$scope.event.pidchannels+'&hideservice=web,digitalpass';rest.get().success(function(response){$scope.channels=response;});},1000*60*5);}};$scope.calcSumviewers=function(){$scope.sumviewers=[];$scope.sumviewers['total']=0;angular.forEach($scope.channels,function(value,key){if($scope.hideService[$scope.channels[key]['service']]!=1&&$scope.hideGame[$scope.channels[key]['game']]!=1){$scope.sumviewers['total']+=$scope.channels[key]['viewers'];}});};$scope.updateStatstotal=function(){rest.baseurl='https://cdn1.api.esl.tv/v1/event/concurrentviewerstotal?pid='+$scope.event.pidchannels;rest.get().success(function(response){$scope.stats.total=response.total;if($scope.peak!==undefined&&$scope.sumviewers.total>$scope.peak){$scope.peak=$scope.sumviewers.total;}});stop=$interval(function(){rest.baseurl='https://cdn1.api.esl.tv/v1/event/concurrentviewerstotal?pid='+$scope.event.pidchannels;rest.get().success(function(response){$scope.stats.total=response.total;if($scope.peak!==undefined&&$scope.sumviewers.total>$scope.peak){$scope.peak=$scope.sumviewers.total;}});},1000*60*2);};$scope.sortbyviewers=function(channel){return-channel.viewers;};$scope.sortchannels=function(channel){return channel.language!='en';};$scope.hideServiceClass=function(service){if($scope.hideService[service]==1){return'hiddenfilter';}};$scope.hideGameClass=function(game){if($scope.hideGame[game]==1){return'hiddenfilter';}};$scope.toggleService=function(service){if($scope.hideService[service]==1){$scope.hideService[service]=0;}else{$scope.hideService[service]=1;} $scope.getChartData();$scope.calcSumviewers();};$scope.toggleGame=function(game){if($scope.hideGame[game]==1){$scope.hideGame[game]=0;}else{$scope.hideGame[game]=1;} $scope.getChartData();$scope.calcSumviewers();};$scope.closeModal=function(){$scope.hideModal=true;var today=new Date();var expiresValue=new Date(today);expiresValue.setMinutes(today.getMinutes()+720);$cookies.put('hideModal','1',{'expires':expiresValue});};if($routeParams.dpm==1){$scope.closeModal();};});;angular.module('EventCtrl',[]).controller('EventController',function($scope,$timeout,EventService,$routeParams,VideoService){var sEvents=EventService;var eventInfo={};var topVideos;$scope.totalevents=0;$scope.videoOptions={};$scope.videoOptions.tags='';$scope.videoOptions.orderby='air_time_ts';$scope.videoOptions.orderdir='asc';$scope.videoOptions.language='en';$scope.videoOptions.dateinterval='alltime';if($routeParams.eventUrl){sEvents.getEventinfoByUrl($routeParams.eventUrl);$scope.$on('currentevent.update',function(event){$scope.currentevent=sEvents.currentevent;$scope.videoOptions.basetags=$scope.currentevent.tags;$scope.videoOptions.event_uid=$scope.currentevent.uid;$scope.videoOptions.title_remove=$scope.currentevent.videotitle_remove;if($scope.currentevent.games){$scope.games=$scope.currentevent.games.split(",");} $scope.$broadcast('videosearch.showdata');});}else{$scope.$on('events.update',function(event){$scope.events=sEvents.events;$scope.totalevents=$scope.events.length;});$scope.events=sEvents.events;sEvents.fetchEvents();}});;angular.module('SidecontentCtrl',[]).controller('SidecontentController',function($scope,$timeout,EventService,GameService,VideoService,ScheduleService){$scope.options={};var Events=EventService;var Games=GameService;var Videos=VideoService;var Shows=ScheduleService;$scope.$on('schedule.update',function(event){$scope.shows=Shows.shows;});$scope.shows=Shows.shows;Shows.fetchShows();$scope.$on('events.update',function(event){$scope.events=Events.events;});$scope.events=Events.events;Events.fetchEvents();$scope.$on('games.update',function(event){$scope.games=Games.games;});$scope.games=Games.games;Games.fetchGames();$scope.$on('videos.update',function(event){$scope.videos=Videos.videos;});$scope.videos=Videos.videos;Videos.fetchVideos();});;var DatepickerDemoCtrl=function($scope){$scope.today=function(){$scope.date_to=new Date();$scope.date_from=new Date();$scope.date_from.setDate($scope.date_from.getDate()-14);};$scope.today();$scope.maxDate=new Date();$scope.disabled=function(date,mode){return(mode==='day'&&(date.getDay()===0||date.getDay()===6));};$scope.open=function($event){$event.preventDefault();$event.stopPropagation();$scope.opened=true;};$scope.dateOptions={formatYear:'yy',startingDay:1,'show-weeks':false,'show-button-bar':false,};$scope.initDate=new Date('2016-15-20');$scope.formats=['dd-MMMM-yyyy','yyyy/MM/dd','dd.MM.yyyy','shortDate'];$scope.format=$scope.formats[2];};;angular.module('HeaderCtrl',[]).controller('HeaderController',function($scope,$location){$scope.isActive=function(viewLocation){return viewLocation===$location.path();};$scope.hoverIn=function($what){eval('$scope.showSidecontent'+$what+' = true ')};$scope.hoverOut=function($what){eval('$scope.showSidecontent'+$what+' = false ')};});;angular.module('VideoplayerCtrl',[]).controller('VideoplayerController',function($scope,$location,$cookies,VideoplayerService){var PlayerService=VideoplayerService;$scope.player={};$scope.isEditor=function(viewLocation){return $cookies['iseditor'];};$scope.isCurrentPlayerMode=function(mode){return mode===PlayerService.currentPlayerMode;} $scope.isCurrentChatMode=function(mode){return mode===PlayerService.currentChatMode;} $scope.$on('videoplayer.update',function(event){$scope.player=PlayerService.currentVideo;$scope.allchannelsbyurl=PlayerService.allchannelsbyurl;$scope.onResize();});$scope.player=PlayerService.currentVideo;$scope.$on('$locationChangeStart',function(){if(PlayerService.currentPlayerMode=='player_theatre'||PlayerService.currentPlayerMode=='player_fullscreen'){PlayerService.setPlayerMode('medium');}});});;angular.module('appRoutes',[]).config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider,$location){var viewVersion=35;if(window.location.hostname=='tv.eslgaming.com'){$routeProvider.when('/',{templateUrl:'views/home.html?v='+viewVersion,controller:'HomeController'}).when('/home',{templateUrl:'views/home.html?v='+viewVersion,controller:'HomeController'}).when('/schedule',{templateUrl:'views/schedule.html?v='+viewVersion,}).when('/channel/:channelUrl',{templateUrl:'views/schedule.html?v='+viewVersion,controller:'ChannelController'}).when('/channel/:channelUrl/:serviceProvider',{templateUrl:'views/schedule.html?v='+viewVersion,controller:'ChannelController'}).when('/channels',{templateUrl:'views/livechannels.html?v='+viewVersion,controller:'ChannelController'}).when('/videos',{templateUrl:'views/videos.html?v='+viewVersion,controller:'VideoArchiveController',reloadOnSearch:false}).when('/video/:videoUrl',{templateUrl:'views/videos.html?v='+viewVersion,controller:'VideoArchiveController',reloadOnSearch:false}).when('/event/:eventUrl',{templateUrl:'views/event.html?v='+viewVersion,controller:'EventController',reloadOnSearch:false}).when('/events',{templateUrl:'views/events.html?v='+viewVersion,controller:'EventController'}).when('/game/:gameUrl',{templateUrl:'views/game.html?v='+viewVersion,controller:'GameController',reloadOnSearch:false}).when('/games',{templateUrl:'views/games.html?v='+viewVersion,controller:'GameController'}).when('/about',{templateUrl:'views/about.html?v='+viewVersion,}).when('/legal',{templateUrl:'views/legal.html?v='+viewVersion,}).when('/teshowroom',{templateUrl:'views/teshowroom.html?v='+viewVersion,}).when('/coffeescreen',{templateUrl:'views/coffeescreen.html?v='+viewVersion,controller:'CoffeescreenController'}).when('/live/:eventUrl',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'}).when('/nerds',{templateUrl:'views/nerd.html?v='+viewVersion,}).when('/geeks',{templateUrl:'views/geek.html?v='+viewVersion,controller:'GeekController'});}else{$routeProvider.when('/:eventUrl/livestats',{templateUrl:'views/livestats.html?v='+viewVersion,controller:'LiveController',livestats:'livestats'}).when('/livestats',{templateUrl:'views/livestats.html?v='+viewVersion,controller:'LiveController',livestats:'livestats'}).when('/:eventUrl/:channelService/:channelUrl',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'}).when('/:eventUrl',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'}).when('/:channelService/:channelUrl',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'}).when('/',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'}).when('/live/:eventUrl/:channelService/:channelUrl',{templateUrl:'views/live.html?v='+viewVersion,controller:'LiveController'});} $locationProvider.html5Mode(true);}]);;angular.module('esltvApp',['ngRoute','appRoutes','ngAnimate','ngCookies','restangular','RestService','elasticsearch','gameFilters','videoFilters','uniqueFilters','maxperGameFilter','timer','ElasticService','ElasticServiceUtil','infinite-scroll','ui.bootstrap','MainCtrl','HomeCtrl','HeaderCtrl','VideoplayerCtrl','VideosearchCtrl','VideosetCtrl','GameService','ScheduleService','EventService','VideoService','VideoplayerService','SidecontentCtrl','ScheduleCtrl','ChangelogCtrl','ChannelCtrl','VideoArchiveCtrl','VideofeaturedCtrl','VideoDirective','VideoCtrl','GameCtrl','CoffeescreenCtrl','LiveCtrl','EventCtrl','UIresize','angularUtils.directives.dirDisqus','chart.js','youtube-embed',]).config(function(RestangularProvider){var isSubDomain=window.location.host.indexOf("dev")==0;if(isSubDomain){RestangularProvider.setBaseUrl('http://dev.api.esl.tv/v1');}else{RestangularProvider.setBaseUrl('https://cdn1.api.esl.tv/v1');} RestangularProvider.addResponseInterceptor(function(data,operation,what,url,response,deferred){var extractedData;if(operation==="getList"){extractedData=data.items;extractedData.meta=data._meta;extractedData.links=data._links;}else{extractedData=data;} return extractedData;});}).config(function($sceDelegateProvider){$sceDelegateProvider.resourceUrlWhitelist(['self','http://www.youtube.com/**','https://www.youtube.com/**','http://www.twitch.tv/**','http://player.twitch.tv/**','http://www.hitbox.tv/**','http://www.azubu.tv/**','http://embed.azubu.tv/**','http://*.znipe.tv/**','http://play.viagame.com/**','https://play.viagame.com/**','http://*.intelextrememasters.com/**','https://*.intelextrememasters.com/**','http://*.esl-one.com/**','https://*.esl-one.com/**','http://*.pro.eslgaming.com/**','https://*.pro.eslgaming.com/**','http://*.dev.pro.eslgaming.com/**','http://*.cloudfront.net/**','http://*.api.esl.tv/**','https://*.api.esl.tv/**','https://www.facebook.com/**','http://gleam.io/**','https://gleam.io/**','https://beta.znipe.tv/**',]);}).config(function($compileProvider){$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|steam|mailto):/);}).run(function($rootScope,Restangular){Restangular.addRequestInterceptor(function(element){return element;});Restangular.addResponseInterceptor(function(data){return data;});Restangular.setResponseExtractor(function(response){var newResponse=response;if(angular.isArray(response)){angular.forEach(newResponse,function(value,key){newResponse[key].originalElement=angular.copy(value);});}else{newResponse.originalElement=angular.copy(response);} return newResponse;});}).run(['$route','$rootScope','$location',function($route,$rootScope,$location){var original=$location.path;$location.path=function(path,reload){if(reload===false){var lastRoute=$route.current;var un=$rootScope.$on('$locationChangeSuccess',function(){$route.current=lastRoute;un();});} return original.apply($location,[path]);};}]);;