"use strict";function reduceOpenWeather(t){var e=moment(1e3*t.dt),i=t.weather[0];return{timestamp:t.dt,icon:"wi-owm-"+i.id,summary:i.description,tempHigh:parseInt(t.temp.max,10),tempLow:parseInt(t.temp.min,10),datelong:e.format(),time:t.dt,date:e.format("D/M"),day:e.format("ddd")}}function reduceDarkSky(t){var e=moment(1e3*t.time);return{timestamp:t.time,icon:weatherIcons.get(t.icon),summary:t.summary,tempHigh:parseInt(t.temperatureHigh,10),tempLow:parseInt(t.temperatureLow,10),datelong:e.format(),time:t.time,date:e.format("D/M"),day:e.format("ddd")}}function randomAmount(t){var e,i="";for(e=0;e';this.$html=$(t),this.$events.append(this.$html),this.$myEvent=$("#"+this.id)}}),BitcoinModel=Backbone.Model.extend({initialize:function(){this.set("url","/btc"),this.set("balanceUrl","/balance");var t={lastGBP:0,lastUSD:0,lows:{gbp:0,usd:0},highs:{gbp:0,usd:0},eclass:"",balance:0,trend:0};this.set("btcdata",t),this.set("balance",0),this.update(),this.updateHourly()},update:function(){this.getBTC(),(new Date).getTime()},updateHourly:function(){this.getBalance(),(new Date).getTime()},recalc:function(){var t=this.get("btcdata"),e=t.lastGBP,i=void 0,n=t.gbp,s=t.usd,a=t.lows,o=t.highs,r=t.eclass,l=t.balance,d=t.trend;void 0!==d&&null!==d||(d=1),void 0!==n&&(0!==t.lastGBP?r=n>e?"up":"down":(a.gbp=n,a.usd=s,o.gbp=n,o.usd=s),e=n,i=s,n1?"trendUp":t.trend<1?"trendDown":"",this.$trend.removeClass(),this.$trend.addClass(s),this.$btc.removeClass(),this.$btc.addClass(t.eclass),this.$btc.html("$"+parseFloat(t.lastUSD.toFixed(2))+" / £"+parseFloat(t.lastGBP.toFixed(2))+"
₿"+e+" £"+parseFloat(i.toFixed(2))+"
"),this.$btc.prop("title",n)}}),FxModel=Backbone.Model.extend({initialize:function(){this.set("url","/fx"),this.set("fxdata",{}),this.update()},update:function(){var t,e;this.getFX(),t=9e5-(new Date).getTime()%9e5,e=function(){this.update()},setTimeout(e.bind(this),t+10)},getFX:function(){var t=this.get("url"),e=this;$.ajax({type:"GET",url:t,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(t){var i,n,s={};void 0!==t.rates&&(n=(i=1/t.rates.GBP)*t.rates.SEK,s={usd:1,gbp:t.rates.GBP,sek:t.rates.SEK,gpbe:i,sekex:n}),e.set("fxdata",s)},error:function(t,e){}})}}),FxView=Backbone.View.extend({tagName:"div",initialize:function(){_.bindAll(this,"render"),this.model.bind("change",this.render),this.$fx=$("#fx")},render:function(){var t=this.model.get("fxdata");this.$fx.html("£1 = $"+parseFloat(t.gpbe.toFixed(2))+" = "+parseFloat(t.sekex.toFixed(2))+" SEK")}}),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},TrainModel=Backbone.Model.extend({initialize:function(){this.get("from"),this.get("to");var t="/getnexttraintimes?from="+this.get("from")+"&to="+this.get("to"),e="/gettrains?from="+this.get("from")+"&to="+this.get("to"),i=this.get("from")+this.get("to");this.set("url",t),this.set("routeUrl",e),this.set("target",i),this.set("visible",!1),this.set("trainData",{eta:"OFF",sta:"OFF"}),this.update()},update:function(){var t,e=new Date,i=e.getHours(),n=i<6?36e5:6e4,s=n-e.getTime()%n;i>=6?this.getTrain():this.set("trainData",{eta:"OFF",sta:"OFF"}),t=function(){this.update()},setTimeout(t.bind(this),s+10)},getTrain:function(){var t=this.get("url"),e=this;$.ajax({type:"GET",url:t,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(t){e.set("trainData",t)},error:function(t,e){}})},getRoute:function(){var t=this.get("routeUrl"),e=this;!0===this.get("visible")?this.set("visible",!1):$.ajax({type:"GET",url:t,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(t){e.set("route",t),e.set("visible",!0)},error:function(t,e){}})}}),TrainView=Backbone.View.extend({tagName:"div",initialize:function(){_.bindAll(this,"render"),this.model.bind("change",this.render),this.$trains=$("#trains"),this.$traininfo=$("#traininfo"),this.$traintext=$("#trainResults"),this.$el=this.$trains,this.initView()},events:{click:"showTrains"},render:function(){var t,e,i,n,s,a,o,r,l,d,c,h,u,m,p,b,f,g,v,w,y,T,C,k,A=this.model.get("trainData"),S=this.model.get("visible"),x=this.model.get("route"),$="on time"===A.eta.toLowerCase()?A.sta:A.eta,E="on time"===A.eta.toLowerCase()?"ontime":"delayed";if(this.$button.html($),this.$button.removeClass("delayed").removeClass("ontime").addClass(E),S){if(t="
"+x.locationName+" TO "+x.filterLocationName+'
\n \n \n \n \n \n ',e=[],"object"===_typeof(x.trainServices)&&null!==x.trainServices){i=!0,n=!1,s=void 0;try{for(a=x.trainServices[Symbol.iterator]();!(i=(o=a.next()).done);i=!0)d=null!==(l=(r=o.value).destination[0]).via?""+l.via+"":"",c=null!==r.platform?r.platform:"💠",h=null!==r.sta?r.sta:"D "+r.std,u=null!==r.eta?r.eta:r.etd,e.push({location:l.locationName,time:h,status:u,platform:c,cancel:r.cancelReason,type:"train"}),t=r.isCancelled?t+"\n ":t+"\n \n \n \n "}catch(t){n=!0,s=t}finally{try{!i&&a.return&&a.return()}finally{if(n)throw s}}}if("object"===_typeof(x.busServices)&&null!==x.busServices){m=!0,p=!1,b=void 0;try{for(f=x.busServices[Symbol.iterator]();!(m=(g=f.next()).done);m=!0)y=null!==(w=(v=g.value).destination[0]).via?""+w.via+"":"",T=null!==v.platform?v.platform:"",C=null!==v.sta?v.sta:"D "+v.std,k=null!==v.eta?v.eta:v.etd,e.push({location:w.locationName,time:C,status:k,platform:T,cancel:v.cancelReason,type:"bus"}),t=t+""}catch(t){p=!0,b=t}finally{try{!m&&f.return&&f.return()}finally{if(p)throw b}}}t+="
DestinationTimeStatusPlatform
"+l.locationName+" "+d+""+h+'❌ '+r.cancelReason+"
"+l.locationName+" "+d+""+h+""+u+""+c+"
🚌 "+w.locationName+" "+y+""+C+""+k+""+T+"
",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,i,n=this,s=this.model.get("target"),a="
"+s.toUpperCase()+':
';this.$html=$(a),this.$html.on("click",function(){n.model.getRoute()}),this.$trains.append(this.$html),this.$button=$("#"+s),e="on time"===(t="OFF")?"ontime":"delayed",this.$button.html(t),this.$button.removeClass("delayed").removeClass("ontime").addClass(e),i="click #$(target)",this.events[i]="showTrains"},showTrains:function(){}}),WCollection=Backbone.Collection.extend({url:"/weather",parse:function(t){return t.list.map(function(t){return reduceOpenWeather(t)})}}),WView=Backbone.View.extend({tagName:"div",template:_.template('\n <% _.each(data, function(item) {%>\n
\n
\n
<%= item.day %>
\n
<%= item.date %>
\n
\n
\n
\n \n <%= item.tempHigh %>° /\n <%= item.tempLow %>°
\n
<%= item.summary %>
\n
\n
\n <% }); \n %>'),initialize:function(){_.bindAll(this,"render"),this.collection=new WCollection,this.listenTo(this.collection,"reset sync",_.debounce(_.bind(this.render),128)),this.collection.fetch()},render:function(){if(0!==this.collection.length){var t={data:this.collection.toJSON()};this.$el.html(this.template(t))}}}),Array.prototype.random=function(){return this[Math.floor(Math.random()*this.length)]},PasswordView=Backbone.View.extend({el:"#passwords",passwordTemplate:_.template("
Long: <%=long%>
Short: <%=short%>
"),initialize:function(){this.alpha=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"],this.whitespace=[".","~","#","!","$","+","-","+"],this.numbers=["0","1","2","3","4","5","6","7","8","9"],this.left=["Alabama","Alaska","Arizona","Maryland","Nevada","Mexico","Texas","Utah","Glasgow","Inverness","Edinburgh","Dumbarton","Balloch","Renton","Cardross","Dundee","Paisley","Hamilton","Greenock","Falkirk","Irvine","Renfrew","Erskine","London","Hammersmith","Islington","Silver","Black","Yellow","Purple","White","Pink","Red","Orange","Brown","Green","Blue","Amber","Aqua","Azure","Bronze","Coral","Copper","Crimson","Cyan","Ginger","Gold","Indigo","Jade"],this.right=["Aganju","Cygni","Akeron","Antares","Aragoth","Ardus","Carpenter","Cooper","Dahin","Capella","Endriago","Gallina","Fenris","Freya","Glenn","Grissom","Jotunheim","Kailaasa","Lagarto","Muspelheim","Nifleheim","Primus","Vega","Ragnarok","Shepard","Slayton","Tarsis","Mercury","Venus","Mars","Earth","Terra","Jupiter","Saturn","Uranus","Neptune","Pluto","Europa","Ganymede","Callisto","Titan","Juno","Eridanus","Scorpius","Crux","Cancer","Taurus","Lyra","Andromeda","Virgo","Aquarius","Cygnus","Corvus","Taurus","Draco","Perseus","Pegasus","Gemini","Columbia","Bootes","Orion","Deneb","Merope","Agate","Amber","Beryl","Calcite","Citrine","Coral","Diamond","Emerald","Garnet","Jade","Lapis","Moonstone","Obsidian","Onyx","Opal","Pearl","Quartz","Ruby","Sapphire","Topaz","Iron","Lead","Nickel","Copper","Zinc","Tin","Manes","Argon","Neon","Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliett","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whisky","Xray","Yankee","Zulu"],this.passwordOut=this.$("#passwordOut"),_.bindAll(this,"newClick")},events:{"click #newPassword":"newClick"},numberCluster:numberCluster,randomAmount:randomAmount,newClick:newClick}),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};