function Controller(){function e(e){Alloy.Globals.loading.showHide("show"),_.defer(function(){Alloy.createController("matchDetail",{id:e.source.matchId,competition:e.source.competition}).getView().open()})}function t(e){y=e.matches,_.defer(function(){if(y.length>0)for(var e=y.length>g.matchCount?g.matchCount:y.length,t=null,a=0,o=e;o>a;a++){var l=y[a];(void 0===t||t!=l.kickdate)&&(t=l.kickdate,i.homeMatches.add(i.UI.create("Label",{text:"  "+m(l.kickdate,"YYYY-MM-DD").format("dddd Do MMMM"),backgroundGradient:Alloy.CFG.gradients.lightGrey,height:28,width:Ti.UI.FILL})),c=null),(l.competitionId!==c||void 0===c)&&(c=l.competitionId,i.homeMatches.add(i.UI.create("Label",{text:"  "+l.competitionName,backgroundGradient:Alloy.CFG.gradients.lightGrey,height:28,width:Ti.UI.FILL}))),d.i("adding ["+l.teams.home.name+"] vs ["+l.teams.away.name+"] at "+l.kickdate+"/"+m(l.kickoff).format("YYYY-MM-DD")),i.homeMatches.add(Alloy.createController("matchTableRow",{id:l.matchId,competition:l.competitionName,time:l.kickoff,status:l.status,teamHome:l.teams.home.name,teamAway:l.teams.away.name,scoreHome:l.score.home,scoreAway:l.score.away}).getView())}else i.homeMatches.add(i.UI.create("Label",{text:"  "+L("AllMatches_NoData"),backgroundGradient:Alloy.CFG.gradients.lightGrey,height:28,width:Ti.UI.FILL})),Alloy.Globals.loading.showHide("hide")})}function a(){Alloy.Globals.loading.showHide("hide")}function o(){isLoading=!0;var e=Alloy.CFG.feedUrls.matchesHome,o=h.signUrl(e.replace("{{date}}",m().format("YYYY-MM-DD")).replace("{{page}}",1).replace("{{count}}",100));_.defer(function(){u.getData({getUrl:o},t,a)})}function l(){Alloy.Globals.dataValidCompetitions?(s=Alloy.Globals.favourites.leagues.concat(_.difference(Alloy.Globals.competitionSort,Alloy.Globals.favourites.leagues)),o()):setTimeout(l,300)}require("alloy/controllers/BaseController").apply(this,Array.prototype.slice.call(arguments)),this.__controllerPath="homeMatches",arguments[0]?arguments[0].__parentSymbol:null,arguments[0]?arguments[0].$model:null,arguments[0]?arguments[0].__itemTemplate:null;var i=this,r={},n={};i.__views.homeMatches=Ti.UI.createView({layout:"vertical",height:Ti.UI.SIZE,id:"homeMatches"}),i.__views.homeMatches&&i.addTopLevelView(i.__views.homeMatches),e?i.__views.homeMatches.addEventListener("click",e):n["$.__views.homeMatches!click!matchClicked"]=!0,r.destroy=function(){},_.extend(i,i.__views);var c,s,d=require("helpers"),m=require("alloy/moment"),h=require("feedSigner"),u=require("netConnect"),g=arguments[0]||{},y=[];l(),n["$.__views.homeMatches!click!matchClicked"]&&i.__views.homeMatches.addEventListener("click",e),_.extend(i,r)}var Alloy=require("alloy"),Backbone=Alloy.Backbone,_=Alloy._;module.exports=Controller;