preview.34b557058e81b614064a.js 5.71 KB
(window.webpackJsonp=window.webpackJsonp||[]).push([["ef20"],{"+Zj9":function(e,t,a){"use strict";a.r(t);a("la2R"),a("KZ2r"),a("KupW"),a("opNK");var o=function(e){e.lineup=DataStore.preview.lineup,e.preview=DataStore.preview,e.canPlay=function(e){return"Unavailable"!==e.type||"Unavailable"===e.type&&"injured-doubtful"===e.reasonUnavailable},e.H2HDonutData=[{label:e.preview.awayTeam.team_name+" Won",value:e.preview.h2h.awayTeam.wins,color:"#000"},{label:"Draw",value:e.preview.h2h.homeTeam.draws,color:"#ccc"},{label:e.preview.homeTeam.team_name+" Won",value:e.preview.h2h.homeTeam.wins,color:"#09f"}],e.homeSeasonDonutData=[{label:"Wins",value:e.preview.season.home.wins,color:"#6c9"},{label:"Draws",value:e.preview.season.home.draws,color:"#ccc"},{label:"Loses",value:e.preview.season.home.loses,color:"#f66"}],e.awaySeasonDonutData=[{label:"Wins",value:e.preview.season.away.wins,color:"#6c9"},{label:"Draws",value:e.preview.season.away.draws,color:"#ccc"},{label:"Loses",value:e.preview.season.away.loses,color:"#f66"}]};o.$inject=["$scope"];var r=o,n=function(e,t,a){e.selectedPlayers=[],e.votes=_.map((DataStore.scorelinePoll||{}).votes,function(t){return _.find(e.preview.lineup,function(e){if(void 0!==e.participant.enetId&&e.participant.enetId==t.valueRef||void 0===e.participant.enetId&&e.participant.name==t.value)return e.scorelineVotes=t.votes,!0})}),e.togglePlayer=function(t){var a=e.selectedPlayers.indexOf(t);-1==a?e.selectedPlayers.push(t):e.selectedPlayers.splice(a,1),t.scorelinePollSelected=!t.scorelinePollSelected},e.vote=function(){if(!e.voting){e.voting=!0;var a=_.map(e.selectedPlayers,function(e){return{value:e.participant.name,valueType:"participant",valueRef:e.participant.enetId}},[]);if(!a.length)return e.error="If you think no one will score, there is no need to vote then.",e.voting=!1;var o={pollRef:"scoreline-"+e.preview.mysqlMatchId,choices:a};t.post("/vote",o).success(function(){e.voting=!1,e.error=null,angular.element(".scoreline-poll .preview-vote-btn").text("Thanks :)")}).error(function(t){e.voting=!1,e.error=t.errors})}}};n.$inject=["$scope","$http","$q"];var l=n,i=function(e,t){e.poll=DataStore.scorePoll||{},e.poll.homeVotes=0,e.poll.awayVotes=0,e.poll.drawVotes=0,_.each(e.poll.votes,function(t){var a=t.value.split("-");a[0]>a[1]?e.poll.homeVotes+=t.votes:a[0]<a[1]?e.poll.awayVotes+=t.votes:e.poll.drawVotes+=t.votes}),e.poll.homeVotesPercentage=e.poll.homeVotes/e.poll.totalVotes*100,e.poll.awayVotesPercentage=e.poll.awayVotes/e.poll.totalVotes*100,e.poll.drawVotesPercentage=e.poll.drawVotes/e.poll.totalVotes*100,e.barClass=function(e){var t=e.value.split("-");return t[0]>t[1]?"homewin":t[0]<t[1]?"awaywin":"draw"},e.vote=function(){if(!e.voting){if(isNaN(e.homeScoreVote)||isNaN(e.awayScoreVote))return!1;if(e.homeScoreVote.length<1||e.awayScoreVote.length<1)return!1;e.voting=!0;var a={pollRef:"score-"+e.preview.mysqlMatchId,choices:[{value:e.homeScoreVote+"-"+e.awayScoreVote}]};t.post("/vote-score",a).success(function(){e.voting=!1,e.error=null,angular.element(".score-poll .preview-vote-btn").text("Thanks :)")}).error(function(t){e.voting=!1,e.error=t.errors})}}};i.$inject=["$scope","$http"];var s=i;angular.module("fr.preview",["fr.formations"]).controller("PreviewCtrl",r).controller("ScorelinePollController",l).controller("scorePollController",s).directive("donut",function(){return{restrict:"A",scope:{donutData:"=",units:"@donutUnits"},templateUrl:"donut-template",link:function(e,t,a){var o,r=e.donutData;o=0,_.each(r,function(e){o+=e.value}),_.each(r,function(e){var t=100/o*e.value;e.percent=t}),e.total=o,function(e){var t=e.find(".donut-chart"),a=e.find(".donut-chart .donut-svg"),o=e.find(".donut-chart .chart"),n=(e.find(".svg"),e.find(".svg .labels")),l=0;o.width(),_.each(r,function(e){if(0!=e.value){var t=angular.element('<div class="slice-mask"></div>').prependTo(o),a=angular.element('<div class="slice"></div>').appendTo(t);t.css("transform","rotate("+l+"deg)"),a.css("transform","rotate("+3.6*e.percent+"deg)"),a.css("background-color",e.color),e.percent>50&&(t.addClass("big"),100===e.percent&&t.addClass("whole"),angular.element('<div class="slice-extension"></div>').appendTo(t).css("background-color",e.color));var r,i,s=50+45*Math.cos((90-l-3.6*e.percent/2)*Math.PI/180),c=50-45*Math.sin((90-l-3.6*e.percent/2)*Math.PI/180),p=50+55*Math.cos((90-l-3.6*e.percent/2)*Math.PI/180),u=50-65*Math.sin((90-l-3.6*e.percent/2)*Math.PI/180),v="m"+s+","+c+"L"+p+","+u,d=u+4,h=l+3.6*e.percent/2;h<=180?(v+="l20,0",r=p+25,i="start"):(v+="l-20,0",r=p-25,i="end");var f=angular.element("<path/>").appendTo(n);f.attr({d:v}),(f=angular.element("<circle/>").appendTo(n)).attr({cx:s,cy:c,r:2});var w=angular.element("<text>"+e.label+"</text>").appendTo(n);w.attr({x:r,y:d,"text-anchor":i}),l+=3.6*e.percent}}),a.html(a.html()),setTimeout(function(){t.addClass("animate")},0)}(t)}}}).directive("frStatVsStat",function(){return{restrict:"A",templateUrl:"fr-stat-vs-stat-template",scope:{leftStat:"=",rightStat:"=",units:"@",statName:"@",visualize:"=",showHigh:"=",showLow:"="},link:function(e,t,a){var o=e.leftStat+e.rightStat;e.leftStatPercentage=Math.round(e.leftStat/o*100),e.rightStatPercentage=Math.round(e.rightStat/o*100)}}}).directive("frHorzBars",function(){return{restrict:"A",replace:!0,templateUrl:"fr-horz-bars-template",scope:!0,link:function(e,t,a){var o,r=e.$eval(a.bars);e.bars=[],o=0,_.some(r,function(t){var r=_.path(t,a.valueProp),n=_.path(t,a.labelProp);return e.bars.length==a.count||!(a.valueMin>0&&(void 0===r||r<a.valueMin))&&(e.bars.push({label:n,value:r}),void(o=o>=r?o:r))}),_.each(e.bars,function(e){e.percent=e.value/o*100}),e.count=a.count,e.orientation=a.orientation}}}),angular.module("footyroom").requires.push("fr.preview")},xeH2:function(e,t){e.exports=jQuery}},[["+Zj9","d41d","970b","c5ee","1090","91fe","14aa","decc","028d"]]]);