talkroom.f6767b502ef931e2bd3c.js
8.14 KB
(window.webpackJsonp=window.webpackJsonp||[]).push([["b300"],{BUhN:function(e,t){e.exports='<div>\n <header class="ls-match-group-header"><a ng-href="{{ group.url }}">{{ group.name }}</a></header>\n <div ng-repeat="subgroup in group.subgroups" fr-ls-subgroup="subgroup"></div>\n</div>'},GjCU:function(e,t){e.exports='<div class="ls-subgroup">\n <header ng-if="subgroup.name">{{ subgroup.name }}</header>\n <ul class="ls-match-list">\n <li ng-repeat="match in subgroup.matches" fr-ls-match></li>\n </ul>\n</div>'},et45:function(e,t,n){"use strict";n.r(t);n("P+Gd");var o=n("BUhN"),s=n.n(o),r=(n("A+5J"),function(e,t,n){var o=n.find(".chat-screen"),s=n.find(".chat-messages"),r=n.find(".chat-input textarea"),i=n.find(".chat-viewport");function a(e){u('<li class="chat-message">'+(e.userRole>=20?'<span class="icn-whistle badge" title="Moderator"></span>':"")+'<a href="/profile/'+e.username+'" target="_blank" class="username" style="color: '+e.chatColor+'">'+e.username+': </a><span class="message">'+e.msg+"</span></li>")}function c(e){u('<li class="chat-message"><span class="message">'+e.content+"</span></li>")}function u(e){var t=s.prop("scrollHeight");s.append(e),t===s.outerHeight()+s.scrollTop()&&s.scrollTop(s.prop("scrollHeight"))}function l(){o.css("height",$(window).height()-146-1)}i.litelay({message:"Trying to connect to chat server...",spinner:!0}),l(),$(window).on("resize",l),t.connect(),r.keydown(function(t){13===t.which&&(t.preventDefault(),e.chat())}),e.chat=function(){if(""!==e.msg.trim()){if(e.msg.length>200)return c({content:"Your chat message is longer than 200 characters limit. Please revise it before sending again."});t.say(e.msg,"global"),r.controller("ngModel").$setViewValue(""),r.controller("ngModel").$render()}},t.on("connect",function(){i.data("litelay")&&i.litelay({off:!0})}),t.on("disconnect",function(){i.litelay({message:"Connection to chat server is lost.<br>Trying to reconnect you...",spinner:!0})}),t.on("chat",function(e){a(e)}),t.on("recent-chats",function(e){s.html(""),_(e).each(a)}),t.on("user-list",function(t){e.userList=t,e.userListLength=_(t).size(),e.user=e.userList[DataStore.user.username],void 0===e.user&&n.find(".chat-composer").mousedown(function(e){i.litelay({message:'You must sign in before you can chat.<p><a href="/signup/">Please create a FootyRoom account if you don\'t have one.</a>'}),n.one("click",function(){i.litelay({off:!0})})}),e.$apply()}),t.on("system",function(e){c(e)}),e.setUserColor=function(e){t.emit("set-color",e)}});r.$inject=["$scope","chat","$element"];var i=r,a=function(e){var t,n={connect:function(){(t=io(window.SITEURL,{path:"/chat/socket.io",forceNew:!0})).on("connect",function(){t.emit("set-user")}),t.on("set-user-ok",function(){t.emit("join-room","global")}),t.on("set-guest-ok",function(){t.emit("join-room-as-guest","global")}),t.on("join-room-ok",function(){t.emit("recent-chats","global")}),this.on=_.bind(t.on,t),this.emit=_.bind(t.emit,t),this.say=function(e,t){console.log("Sending message"),n.emit("chat",{room:t,msg:e,timestamp:new Date})}}};return n};a.$inject=["cookie"];var c=a,u=n("GjCU"),l=n.n(u);n("mxFJ");function p(e,t,n,o,s,r,i){try{var a=e[r](i),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(o,s)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(o,s){var r=e.apply(t,n);function i(e){p(r,o,s,i,a,"next",e)}function a(e){p(r,o,s,i,a,"throw",e)}i(void 0)})}}var d=function(){var e=m(regeneratorRuntime.mark(function e(t,o,s){var r,i,a,c,u,l;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return l=function(e,t){s.subDay(e,t,u)},u=function(e){console.time("index"),t.competitions=_(e.stages).filter(function(e){return"competition"==e.type}),t.stagesByParent=_(e.stages).groupBy("parent"),t.stagesById=_(e.stages).indexBy("id"),t.matchesById=e.matchesById,t.matchesByStage=_(e.matchesById).groupBy("stageId"),console.timeEnd("index"),$(window).scrollTop()>$(".livescores").offset().top-22&&$("body").scrollTo($(".livescores").offset().top-22,100),$(".ls-match-group-list").litelay({off:!0})},c=function(e){$(".ls-match-group-list").litelay({spinner:!0}),l(e,t.settings.timezone)},a=function(){return(a=m(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=DataStore.tz)&&Intl&&Intl.DateTimeFormat&&Intl.DateTimeFormat().resolvedOptions&&(t=Intl.DateTimeFormat().resolvedOptions().timeZone),t){e.next=6;break}return e.next=5,n.e("3add").then(n.t.bind(null,"cv6H",7));case 5:t=e.sent.determine().name();case 6:return e.abrupt("return",t);case 7:case"end":return e.stop()}},e)}))).apply(this,arguments)},i=function(){return a.apply(this,arguments)},t.datepickerOptions={minDate:new Date("2012-01-01"),maxDate:new Date((new Date).getFullYear()+1+"-12-31"),date:new Date((new Date).setHours(0,0,0,0)),onChange:c},e.next=8,i();case 8:e.t0=e.sent,t.settings={timezone:e.t0},s.connect().on("connect",function(){$(".ls-match-group-list").litelay({spinner:!0}),l(t.datepickerOptions.date,t.settings.timezone)}),t.changeTimezone=function(){l(t.datepickerOptions.date,t.settings.timezone),o.post("/profile/settings/set-timezone",{tz:t.settings.timezone})},t.onClickSettings=function(){t.showLsSettings=!t.showLsSettings,t.showLsSettings&&$(".ls-settings-dropdown").litelay({spinner:!0})},t.timezonesLoaded=function(){$(".ls-settings-dropdown").litelay({off:!0})},t.joinMatch=function(e){r&&(r._subscribed=!1),r=t.matchesById[e],s.subMatch(e,function(e){r.lineup=e.lineup,r._subscribed=!0})};case 16:case"end":return e.stop()}},e)}));return function(t,n,o){return e.apply(this,arguments)}}();d.$inject=["$scope","$http","livescores"];var f=d,g=n("KHs0");angular.module("fr.talk",["fr.datepicker",g.a]).controller("ChatController",i).controller("LiveScoresController",f).directive("sticky",function(){return{restrict:"A",link:function(e,t,n){var o,s=n.stickyOffset||0,r=angular.element(window),i=t.offset().top,a="free";r.on("scroll",function(e){if(o=r.scrollTop(),"free"==a&&o>i-s){if($(document).height()-r.height()<=o)return;t.next(".sticky-dummy")[0]||t.after($("<div>").addClass("sticky-dummy").height(t.outerHeight())),t.addClass("sticky"),a="fixed"}else"fixed"==a&&o<i-s&&(t.removeClass("sticky"),t.next(".sticky-dummy").remove(),a="free")}),e.$watch(function(){return t.outerHeight()},function(e,n){e!=n&&t.next(".sticky-dummy")[0]&&t.next(".sticky-dummy").height(t.outerHeight())})}}}).directive("frLsSubgroup",function(){return{restrict:"A",scope:!0,template:l.a,controller:["$scope",function(e){}]}}).directive("frLsMatchGroup",function(){return{restrict:"A",template:s.a,scope:!0,controller:["$scope","$attrs",function(e,t){var n=e.stagesByParent,o=e.stagesById,s=e.competition,r=e.matchesByStage;console.time("build"),function(){var t=[],i={};function a(e){return n[e]&&n[e].length>0}function c(e){return n[e]&&n[e].length>1}!function e(s){var u;"competition"==s.type&&(i[s.id]={name:"",url:s.meta.url,subgroups:[]},t.push(i[s.id])),"season"==s.type&&(i[s.parent].name=s.name,i[s.id]=i[s.parent]),"stage"!=s.type||!s.parent||"season"!=o[s.parent].type||c(s.parent)||a(s.id)||i[s.parent].subgroups.push({matches:r[s.id]}),"stage"==s.type&&"season"==o[s.parent].type&&!c(s.parent)&&a(s.id)&&(i[s.parent].name+=" - "+s.name,i[s.id]={name:""}),"stage"==s.type&&"season"==o[s.parent].type&&c(s.parent)&&a(s.id)&&(i[s.id]={name:s.name}),"stage"==s.type&&"season"!=o[s.parent].type&&a(s.id)&&(i[s.id]={name:i[s.parent]&&i[s.parent].name?i[s.parent].name+" - "+s.name:s.name}),"stage"!=s.type||"season"==o[s.parent].type||a(s.id)||t[0].subgroups.push({name:i[s.parent].name?i[s.parent].name+" - "+s.name:s.name,matches:r[s.id]}),u=s.id,n[u]&&"group"==n[u][0].type&&t[0].subgroups.push({name:c(s.parent)?i[s.parent].name?i[s.parent].name+" - "+s.name:s.name:"",matches:_(n[s.id]).reduce(function(e,t){return[].push.apply(e,r[t.id]),e},[])}),"group"==s.type&&s.name&&(s.groupName=s.name.replace("Group ","")),_(n[s.id]).each(e)}(s),e.group=_(t).uniq()[0],_(e.group.subgroups).each(function(e){e.matches=_(e.matches).sortBy(function(e){return e.datetime})})}(),console.timeEnd("build")}]}}).service("chat",c),angular.module("footyroom").requires.push("fr.talk")},xeH2:function(e,t){e.exports=jQuery}},[["et45","d41d","970b","c50d","1ae7"]]]);