2017-09-27 23:17:07 +00:00
|
|
|
"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<t;e++)i+=this.alpha.random();return i}function newClick(t){var e=(this.left.random()+" "+this.right.random()+" "+this.numberCluster()).split(" ").join(this.whitespace.random()),i=(this.randomAmount(5)+" "+this.randomAmount(5)).split(" ").join(this.whitespace.random()),n=this.passwordTemplate({long:e,short:i});this.passwordOut.removeClass("mui--hide"),this.passwordOut.empty().append(n)}function numberCluster(){return this.numbers.random()+this.numbers.random()+this.numbers.random()}var SOCKETMANAGER,EventModel,EventView,BitcoinModel,Bitcoin,FxModel,FxView,_typeof,TrainModel,TrainView,WCollection,WView,PasswordView,popitout,popitoutSmall,WEBSOCKET=function(t){var e=["localhost","silvrtree.co.uk"],i="9000";"https:"===document.location.protocol?(e="wss://"+e[1],i=""):(e="ws://"+e[0],i="9000"),this.socket=null,this.timer=0,this.clock=null,this.startWebSocket=function(){var t,n=""===i?e:e+":"+i;t=window.MozWebSocket?MozWebSocket:WebSocket,this.socket=new t(n,"stream"),this.socket.onopen=this.handleWebsocketOnOpen.bind(this),this.socket.onmessage=this.handleWebsocketMessage.bind(this),this.socket.onclose=this.handleWebsocketClose.bind(this),this.socket.onerror=function(t){}},this.send=function(t){this.socket.send(t)},this.handleData=function(e){t.trigger("message",e)},this.handleWebsocketOnOpen=function(){this.retry=0,this.clock=new Date},this.handleWebsocketMessage=function(t){var e=void 0;try{e=JSON.parse(t.data)}catch(t){}e&&this.handleData.call(this,e)},this.handleWebsocketClose=function(){var t;new Date,t=this,this.timer=setTimeout(function(){t.startWebSocket()},15e3)},this.startWebSocket()};SOCKETMANAGER=Backbone.Model.extend({initialize:function(){_.bindAll(this,"turnOn","turnOff"),this.listeningID=null,this.listening=!1,this.webSocket=new WEBSOCKET(this),this.on("message",function(t){this.listening&&this.checkItem(t)})},turnOn:function(){this.listening=!0},turnOff:function(){this.listening=!1},listenFor:function(t){this.listeningID=this.deviceId.indexOf(t)},checkItem:function(t){t.hasOwnProperty("id")&&("btc"===t.id&&void 0!==this.btc&&this.btc.btcFromSocket(t.data),"balance"===t.id&&void 0!==this.btc&&this.btc.balanceFromSocket(t.data))},setBTC:function(t){this.btc=t},setTrain:function(t){this.train=t},getUpdate:function(){this.webSocket.send("update")}}),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="<div class='mui-col-xs-12 mui-col-md-3' id=\""+this.id+'"></div>';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
|