"use strict";var BitcoinModel,Bitcoin,FxModel,FxView,_typeof,TrainModel,TrainView,WeatherModel,Weather,WeatherSlim,popitout,popitoutSmall,EventModel=Backbone.Model.extend({initialize:function(){this.update()},getDays:function(t,e){var i=void 0,n=void 0;return i=t.getTime(),n=e.getTime(),(n-i)/864e5},update:function(){var t,e=new Date,i=36e5-e.getTime()%36e5,n={};n.days=Math.ceil(this.getDays(e,this.get("event"))),n.weeks=Math.ceil(this.getDays(e,this.get("event"))/7),this.set("data",n),t=function(){this.update()},setTimeout(t.bind(this),i+10)}}),EventView=Backbone.View.extend({tagName:"div",initialize:function(){_.bindAll(this,"render"),this.model.bind("change",this.render),this.id="e_"+Math.random().toString(36).substr(2,9),this.$events=$("#events"),this.$myEvent=null,this.$el=this.$events,this.initView(),this.render()},render:function(){var t=this.model.get("label"),e=this.model.get("data"),i=t+" "+e.days+" days / "+e.weeks+" weeks";this.$myEvent.empty().append(i)},initView:function(){var t="
';this.$html=$(t),this.$events.append(this.$html),this.$myEvent=$("#"+this.id)}});BitcoinModel=Backbone.Model.extend({initialize:function(){this.set("url","/btc");var t={lastGBP:0,lastUSD:0,lows:{gbp:0,usd:0},highs:{gbp:0,usd:0},eclass:""};this.set("btcdata",t),this.update()},update:function(){var t,e,i;this.getBTC(),t=new Date,e=6e4-t.getTime()%6e4,i=function(){this.update()},setTimeout(i.bind(this),e+10)},recalc:function(){var t=this.get("btcdata"),e=t.lastGBP,i=void 0,n=t.gbp,s=t.usd,o=t.lows,a=t.highs,r=t.eclass;0!==t.lastGBP?r=n>e?"up":"down":(o.gbp=n,o.usd=s,a.gbp=n,a.usd=s),e=n,i=s,n"+E.locationName+" TO "+E.filterLocationName+'\n \n \n \n \n \n ',"object"===_typeof(E.trainServices)&&null!==E.trainServices){e=!0,i=!1,n=void 0;try{for(s=E.trainServices[Symbol.iterator]();!(e=(o=s.next()).done);e=!0)a=o.value,r=a.destination[0],l=null!==r.via?""+r.via+"":"",d=null!==a.platform?a.platform:"💠",c=null!==a.sta?a.sta:"D "+a.std,h=null!==a.eta?a.eta:a.etd,t=a.isCancelled?t+"\n \n \n \n \n ":t+"\n \n \n \n \n "}catch(t){i=!0,n=t}finally{try{!e&&s.return&&s.return()}finally{if(i)throw n}}}if("object"===_typeof(E.busServices)&&null!==E.busServices){u=!0,m=!1,p=void 0;try{for(f=E.busServices[Symbol.iterator]();!(u=(g=f.next()).done);u=!0)b=g.value,v=b.destination[0],w=null!==v.via?""+v.via+"":"",y=null!==b.platform?b.platform:"",T=null!==b.sta?b.sta:"D "+b.std,$=null!==b.eta?b.eta:b.etd,t=t+"\n \n \n \n \n "}catch(t){m=!0,p=t}finally{try{!u&&f.return&&f.return()}finally{if(m)throw p}}}t+="
DestinationTimeStatusPlatform
"+r.locationName+" "+l+""+c+'❌ '+a.cancelReason+"
"+r.locationName+" "+l+""+c+""+h+""+d+"
🚌 "+v.locationName+" "+w+""+T+""+$+""+y+"
",this.$traintext.empty().html(t),this.$traintext.removeClass("mui--hide").addClass("mui--show")}else this.$traintext.removeClass("mui--show").addClass("mui--hide")},initView:function(){var t,e=this,i=this.model.get("target"),n="
"+i.toUpperCase()+':
';this.$html=$(n),this.$html.on("click",function(){e.model.getRoute()}),this.$trains.append(this.$html),this.$button=$("#"+i),t="click #$(target)",this.events[t]="showTrains"},showTrains:function(){}}),WeatherModel=Backbone.Model.extend({initialize:function(){var t=this.get("geo");this.set("url","https://api.darksky.net/forecast/9ad2a41d420f3cf4960571bb886f710c/"+t.coords.latitude.toString()+","+t.coords.longitude.toString()+"?units=uk2&exclude=minutely,hourly,alerts,flags"),this.update()},update:function(){var t,e,i;this.getWeather(),t=new Date,e=18e5-t.getTime()%18e5,i=function(){this.update()},setTimeout(i.bind(this),e+10)},getWeather:function(){var t=this;$.ajax({type:"GET",url:t.get("url"),data:"",dataType:"jsonp",timeout:1e4,context:$("body"),contentType:"application/json",headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"PUT, GET, POST, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"},success:function(e){var i={temperature:e.currently.temperature,icon:e.currently.icon,summary:e.currently.summary,daily:e.daily.summary};t.set(i)},error:function(t,e){}})}}),Weather=Backbone.View.extend({tagName:"div",initialize:function(){_.bindAll(this,"render"),this.model.bind("change",this.render),this.$weatherText=$("#weatherDescription"),this.$weatherTemp=$("#temp"),this.$weatherIcon=$("#weatherIcon")},render:function(){var t='';this.$weatherTemp.empty().html(parseInt(this.model.get("temperature"))+"°c "),this.$weatherText.empty().html(this.model.get("summary")),this.$weatherIcon.empty().html(t)}}),WeatherSlim=Backbone.View.extend({tagName:"div",initialize:function(){_.bindAll(this,"render"),this.model.bind("change",this.render),this.$weather=$("#weather"),this.render()},render:function(){var t=this.model.get("summary"),e=this.model.get("temperature"),i=this.model.get("daily"),n=t+" "+e+"° "+i+"";this.$weather.empty().html(n)}}),function(){var t=function(t){var e=$("#passwordOut"),i=new EJS({url:"/template/password.ejs"}).render(t);e.empty(),e.append(i),e.show()},e=function(e,i){$.ajax({type:"GET",url:"/generate",data:"",dataType:"json",timeout:1e4,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"PUT, GET, POST, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"},success:function(e){t(e)},error:function(t,e){}})};$("#newPassword").on("click",function(){e()}),document.title="Slack"}(),popitout=function(t){var e=window.open(t,"name","height=600,width=570");return window.focus&&e.focus(),!1},popitoutSmall=function(t){var e=window.open(t,"name","height=400,width=520");return window.focus&&e.focus(),!1};