From c392de700ffba62b303eedc689f9badcf6e50f74 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Thu, 28 Sep 2017 00:17:07 +0100 Subject: [PATCH] new weather, fixes for minified version --- app.js | 24 +- app/css/weather.css | 82 ++++ app/js/modules/bitcoin.js | 20 +- app/js/modules/train.js | 66 ++-- app/js/modules/weatherV2.js | 80 ++++ app/live/js/app.js | 735 +----------------------------------- app/live/js/vendor.js | 21 +- bower.json | 5 +- gulpfile.js | 80 ++-- lib/newdata.json | 1 - lib/today.js | 640 +++++++++++++++---------------- lib/today/calHandler.js | 538 +++++++++++++------------- lib/today/history.js | 122 +++--- lib/today/weather.js | 64 ++-- lib/weather.js | 56 +-- package.json | 32 +- views/pages/slackV2-min.ejs | 29 +- views/pages/slackV2.ejs | 45 +-- views/partials/head-min.ejs | 4 +- views/partials/head.ejs | 4 +- web-server.js | 34 +- 21 files changed, 1084 insertions(+), 1598 deletions(-) create mode 100644 app/css/weather.css create mode 100644 app/js/modules/weatherV2.js delete mode 100644 lib/newdata.json diff --git a/app.js b/app.js index 66a6652..890cd6e 100644 --- a/app.js +++ b/app.js @@ -1,38 +1,36 @@ -/*var app = require('express').createServer(); +/* var app = require('express').createServer(); app.get('/', function(req, res) { res.send('Hello from AppFog.com'); }); app.listen(process.env.VCAP_APP_PORT || 3000);*/ - -var express = require('express'), path = require('path'), http = require('http'); +var express = require('express'), path = require('path'), http = require('http'); var app = express(); app.configure(function() { app.set('port', process.env.VCAP_APP_PORT || 3000); app.use(express.logger('dev')); + /* 'default', 'short', 'tiny', 'dev' */ - app.use(express.methodOverride()); + app.use(express.methodOverride()); app.use(express.bodyParser()); - app.use(function(req, res, next) { - res.header("Access-Control-Allow-Origin", "*"); - res.header("Access-Control-Allow-Headers", "X-Requested-With"); - next(); - }); + app.use(function(req, res, next) { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'X-Requested-With'); + next(); + }); app.use(app.router); app.use(express.static(path.join(__dirname, 'www'))); -app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); + app.use(express.errorHandler({ 'dumpExceptions': true, 'showStack': true })); }); - /** * Routing handlers */ - /** * create the server */ http.createServer(app).listen(app.get('port'), function() { - console.log("Express server listening on port " + app.get('port')); + console.log(`Express server listening on port ${ app.get('port')}`); }); diff --git a/app/css/weather.css b/app/css/weather.css new file mode 100644 index 0000000..0705216 --- /dev/null +++ b/app/css/weather.css @@ -0,0 +1,82 @@ +.card { + position: relative; + background-color: #fff; + min-height: 72px; +} + +.mui--text-display3 { + font-family: "Roboto Slab", "Helvetica Neue", Helvetica, Arial; +} + +.temp0, .temp1, .temp2, .temp3, .temp4, .temp5 { + color: rgb(80, 181, 221) +} + +.temp6 { + color: rgb(78, 178, 206) +} + +.temp7 { + color: rgb(76, 176, 190) +} + +.temp8 { + color: rgb(73, 173, 175) +} + +.temp9 { + color: rgb(72, 171, 159) +} + +.temp10 { + color: rgb(70, 168, 142) +} + +.temp11 { + color: rgb(68, 166, 125) +} + +.temp12 { + color: rgb(66, 164, 108) +} + +.temp13 { + color: rgb(102, 173, 94) +} + +.temp14 { + color: rgb(135, 190, 64) +} + +.temp15 { + color: rgb(179, 204, 26) +} + +.temp16 { + color: rgb(214, 213, 28) +} + +.temp17 { + color: rgb(249, 202, 3) +} + +.temp18 { + color: rgb(246, 181, 3) +} + +.temp19 { + color: rgb(244, 150, 26) +} + +.temp20 { + color: rgb(236, 110, 5) +} + +.day { + font-family: "Roboto Slab", "Helvetica Neue", Helvetica, Arial, SansSerif; + text-transform: uppercase; +} + +.summary::first-letter { + text-transform: capitalize +} \ No newline at end of file diff --git a/app/js/modules/bitcoin.js b/app/js/modules/bitcoin.js index 3314788..91e7b64 100644 --- a/app/js/modules/bitcoin.js +++ b/app/js/modules/bitcoin.js @@ -22,7 +22,7 @@ const BitcoinModel = Backbone.Model.extend({ }, 'update': function () { this.getBTC(); - // this.getBalance(); + // this.getBalance(); const now = new Date(); const mod = 300000 - (now.getTime() % 300000); @@ -94,7 +94,7 @@ const BitcoinModel = Backbone.Model.extend({ data.stub = Math.random(Number.MAX_SAFE_INTEGER).toString(32); this.set('btcdata', data); - // total = myBTC * g; + // total = myBTC * g; }, 'getBTC': function () { console.log('>> getBTC'); @@ -106,7 +106,7 @@ const BitcoinModel = Backbone.Model.extend({ 'data': '', 'dataType': 'json', 'timeout': 10000, - // contentType: ('application/json'), + // contentType: ('application/json'), 'headers': { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', @@ -139,7 +139,7 @@ const BitcoinModel = Backbone.Model.extend({ 'data': '', 'dataType': 'json', 'timeout': 10000, - // contentType: ('application/json'), + // contentType: ('application/json'), 'headers': { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', @@ -159,7 +159,7 @@ const BitcoinModel = Backbone.Model.extend({ }); }, 'btcFromSocket': function (data) { - let self = this; + const self = this; console.log('>> btc from the socket', data); const gbp = data.bpi.GBP.rate_float; const usd = data.bpi.USD.rate_float; @@ -172,7 +172,7 @@ const BitcoinModel = Backbone.Model.extend({ self.recalc(); }, 'balanceFromSocket': function (data) { - let self = this; + const self = this; console.log('>> balance from the socket', data); const balance = data.balance; @@ -191,10 +191,10 @@ const Bitcoin = Backbone.View.extend({ 'render': function () { const btcdata = this.model.get('btcdata'); const balance = this.model.get('balance'); - // console.log(`Balance: ${btcdata.balance.toFixed(4)}`); - // console.log(btcdata.lastGBP); + // console.log(`Balance: ${btcdata.balance.toFixed(4)}`); + // console.log(btcdata.lastGBP); const owned = parseFloat(btcdata.lastGBP) * parseFloat(balance); - // console.log(`owned: ${owned}`); + // console.log(`owned: ${owned}`); const title = `High: $${ parseFloat(btcdata.highs.usd.toFixed(2)) } / Low $${ parseFloat(btcdata.lows.usd.toFixed(2))}`; let trendClass = ''; @@ -203,7 +203,7 @@ const Bitcoin = Backbone.View.extend({ else if (btcdata.trend < 1.00) trendClass = 'trendDown'; else - trendClass = ''; + trendClass = ''; this.$trend.removeClass(); this.$trend.addClass(trendClass); diff --git a/app/js/modules/train.js b/app/js/modules/train.js index 37dc340..510698e 100644 --- a/app/js/modules/train.js +++ b/app/js/modules/train.js @@ -10,9 +10,9 @@ const TrainModel = Backbone.Model.extend({ 'initialize': function () { const fromStation = this.get('from'); const toStation = this.get('to'); - const url = `/getnexttraintimes?from=${ fromStation }&to=${ toStation}`; - const routeUrl = `/gettrains?from=${ fromStation }&to=${ toStation}`; - const target = fromStation + toStation; + const url = `/getnexttraintimes?from=${ this.get('from') }&to=${ this.get('to')}`; + const routeUrl = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}`; + const target = this.get('from') + this.get('to'); this.set('url', url); this.set('routeUrl', routeUrl); this.set('target', target); @@ -30,7 +30,7 @@ const TrainModel = Backbone.Model.extend({ if (hours >= 6) this.getTrain(); else - this.set('trainData', { 'eta':'OFF', 'sta': 'OFF' }); + this.set('trainData', { 'eta':'OFF', 'sta': 'OFF' }); const trainUpdateFn = function () { this.update(); @@ -69,32 +69,32 @@ const TrainModel = Backbone.Model.extend({ if (this.get('visible') === true) this.set('visible', false); else - $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', + $.ajax({ + 'type': 'GET', + 'url': url, + 'data': '', + 'dataType': 'json', - 'timeout': 10000, - 'headers': { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' + 'timeout': 10000, + 'headers': { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' - }, - 'success': function (data) { - // getTrainsCB(data); - // console.log('Got', data); + }, + 'success': function (data) { + // getTrainsCB(data); + // console.log('Got', data); - self.set('route', data); - self.set('visible', true); - }, - 'error': function (xhr, type) { - console.error('ajax error'); - console.error(xhr); - console.error(type); - } - }); + self.set('route', data); + self.set('visible', true); + }, + 'error': function (xhr, type) { + console.error('ajax error'); + console.error(xhr); + console.error(type); + } + }); } }); @@ -161,8 +161,8 @@ const TrainView = Backbone.View.extend({ const time = item.sta !== null ? item.sta : `D ${item.std}`; const status = item.eta !== null ? item.eta : item.etd; services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'bus' }); - // ws = ws + `
${dest.locationName} Bus ${via}
`; - // ws = ws + '
' + item.sta + '
'; + // ws = ws + `
${dest.locationName} Bus ${via}
`; + // ws = ws + '
' + item.sta + '
'; ws = `${ws }🚌 ${dest.locationName} ${via}${time}${status}${platform}`; } @@ -171,21 +171,21 @@ const TrainView = Backbone.View.extend({ this.$traintext.removeClass('mui--hide').addClass('mui--show'); } else - this.$traintext.removeClass('mui--show').addClass('mui--hide'); + this.$traintext.removeClass('mui--show').addClass('mui--hide'); }, 'initView': function () { - // el: $('#myView').get(0) + // el: $('#myView').get(0) const self = this; const target = this.model.get('target'); const html = `
${target.toUpperCase()}:
`; this.$html = $(html); this.$html.on('click', function () { -// console.log(self) + // console.log(self) self.model.getRoute(); }); this.$trains.append(this.$html); -// this.el = `#${target}`; + // this.el = `#${target}`; this.$button = $(`#${target}`); diff --git a/app/js/modules/weatherV2.js b/app/js/modules/weatherV2.js new file mode 100644 index 0000000..8280a49 --- /dev/null +++ b/app/js/modules/weatherV2.js @@ -0,0 +1,80 @@ +function reduceOpenWeather(item) { + // Openweather returns timestamps in seconds. Moment requires them in milliseconds. + + const ts = moment(item.dt * 1000); + const weatherBlock = item.weather[0]; + + return { + 'timestamp': item.dt, + 'icon': `wi-owm-${weatherBlock.id}`, + 'summary': weatherBlock.description, + 'tempHigh': parseInt(item.temp.max, 10), + 'tempLow': parseInt(item.temp.min, 10), + 'datelong': ts.format(), + 'time': item.dt, + 'date': ts.format('D/M'), + 'day': ts.format('ddd') + + }; +} + +function reduceDarkSky(item) { + const ts = moment(item.time * 1000); + + return { + 'timestamp': item.time, + 'icon': weatherIcons.get(item.icon), + 'summary': item.summary, + 'tempHigh': parseInt(item.temperatureHigh, 10), + 'tempLow': parseInt(item.temperatureLow, 10), + 'datelong': ts.format(), + 'time': item.time, + 'date': ts.format('D/M'), + 'day': ts.format('ddd') + + }; +} + +const WCollection = Backbone.Collection.extend({ + 'url': '/weather', + 'parse': function(data) { + return data.list.map((item) => { + // Reduce the data + return reduceOpenWeather(item); + }); + } +}); + +const WView = Backbone.View.extend({ + 'tagName': 'div', + 'template': _.template(` + <% _.each(data, function(item) {%> +
+
+
<%= item.day %>
+
<%= item.date %>
+
+
+
+ + <%= item.tempHigh %>° / + <%= item.tempLow %>°
+
<%= item.summary %>
+
+
+ <% }); + %>`), + '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 (this.collection.length !== 0) { + const data = { 'data':this.collection.toJSON() }; + this.$el.html(this.template(data)); + } + } + +}); diff --git a/app/live/js/app.js b/app/live/js/app.js index a86cdcb..4c83c11 100644 --- a/app/live/js/app.js +++ b/app/live/js/app.js @@ -1,734 +1 @@ -'use strict'; - -/** - * Created by mdonnel on 10/04/2017. - */ -var EventModel = Backbone.Model.extend({ - 'initialize': function initialize() { - this.update(); - }, - 'getDays': function getDays(startdate, enddate) { - var r = void 0, - s = void 0, - e = void 0; - s = startdate.getTime(); - e = enddate.getTime(); - r = (e - s) / (24 * 60 * 60 * 1000); - - return r; - }, - 'update': function update() { - var now = new Date(); - var mod = 3600000 - now.getTime() % 3600000; - var data = {}; - data.days = Math.ceil(this.getDays(now, this.get('event'))); - data.weeks = Math.ceil(this.getDays(now, this.get('event')) / 7); - this.set('data', data); - - var clockFn = function clockFn() { - this.update(); - }; - - setTimeout(clockFn.bind(this), mod + 10); - } -}); - -var EventView = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.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 render() { - var label = this.model.get('label'); - var data = this.model.get('data'); - var str = label + ' ' + data.days + ' days / ' + data.weeks + ' weeks'; - this.$myEvent.empty().append(str); - }, - 'initView': function initView() { - var html = '
'; - this.$html = $(html); - this.$events.append(this.$html); - this.$myEvent = $('#' + this.id); - } -}); -'use strict'; - -/** - * Created by mdonnel on 22/03/2017. - */ - -var BitcoinModel = Backbone.Model.extend({ - 'initialize': function initialize() { - this.set('url', '/btc'); - this.set('balanceUrl', '/balance'); - var data = { - 'lastGBP': 0.0, - 'lastUSD': 0.0, - 'lows': { 'gbp': 0, 'usd': 0 }, - 'highs': { 'gbp': 0, 'usd': 0 }, - 'eclass': '', - 'balance': 0.0, - 'trend': 0 - }; - this.set('btcdata', data); - this.set('balance', 0); - this.update(); - this.updateHourly(); - }, - 'update': function update() { - this.getBTC(); - // this.getBalance(); - var now = new Date(); - var mod = 300000 - now.getTime() % 300000; - - var btcupdateFn = function btcupdateFn() { - this.update(); - }; - setTimeout(btcupdateFn.bind(this), mod + 10); - }, - 'updateHourly': function updateHourly() { - this.getBalance(); - var now = new Date(); - var mod = 3600000 - now.getTime() % 3600000; - - var btcupdateFn = function btcupdateFn() { - this.update(); - }; - setTimeout(btcupdateFn.bind(this), mod + 10); - }, - 'recalc': function recalc() { - var data = this.get('btcdata'); - var lastGBP = data.lastGBP; - var lastUSD = void 0; - var g = data.gbp; - var u = data.usd; - var lows = data.lows; - var highs = data.highs; - var eclass = data.eclass; - var balance = data.balance; - var trend = data.trend; - - if (trend === undefined || trend === null) trend = 1; - - if (g !== undefined) { - if (data.lastGBP !== 0) { - if (g > lastGBP) { - eclass = 'up'; - } else { - eclass = 'down'; - } - } else { - lows.gbp = g; - lows.usd = u; - - highs.gbp = g; - highs.usd = u; - } - lastGBP = g; - lastUSD = u; - - if (g < lows.gbp) lows.gbp = g; - if (u < lows.usd) lows.usd = u; - - if (highs.gbp < g) highs.gbp = g; - if (highs.usd < u) highs.usd = u; - - data = { - lastGBP: lastGBP, - lastUSD: lastUSD, - lows: lows, - highs: highs, - eclass: eclass, - balance: balance, - trend: trend - }; - } - data.stub = Math.random(Number.MAX_SAFE_INTEGER).toString(32); - - this.set('btcdata', data); - // total = myBTC * g; - }, - 'getBTC': function getBTC() { - var self = this; - var url = this.get('url'); - $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', - 'timeout': 10000, - // 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 success(data) { - var gbp = data.bpi.GBP.rate_float, - usd = data.bpi.USD.rate_float; - var trend = data.trend; - var btcdata = self.get('btcdata'); - btcdata.gbp = gbp; - btcdata.usd = usd; - btcdata.trend = trend; - self.set('btcdata', btcdata); - self.recalc(); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - }, - 'getBalance': function getBalance() { - var self = this; - var url = this.get('balanceUrl'); - $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', - 'timeout': 10000, - // 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 success(data) { - var balance = data.balance; - - self.set('balance', balance); - self.recalc(); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - } -}); -var Bitcoin = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.bindAll(this, 'render'); - this.model.bind('change', this.render); - this.$btc = $('#btc'); - this.$trend = $('#trend'); - }, - 'render': function render() { - var btcdata = this.model.get('btcdata'); - var balance = this.model.get('balance'); - // console.log(`Balance: ${btcdata.balance.toFixed(4)}`); - // console.log(btcdata.lastGBP); - var owned = parseFloat(btcdata.lastGBP) * parseFloat(balance); - // console.log(`owned: ${owned}`); - var title = 'High: $' + parseFloat(btcdata.highs.usd.toFixed(2)) + ' / Low $' + parseFloat(btcdata.lows.usd.toFixed(2)); - var trendClass = ''; - - if (btcdata.trend > 1.00) trendClass = 'trendUp';else if (btcdata.trend < 1.00) trendClass = 'trendDown';else trendClass = ''; - - this.$trend.removeClass(); - this.$trend.addClass(trendClass); - this.$btc.removeClass(); - this.$btc.addClass(btcdata.eclass); - this.$btc.html('$' + parseFloat(btcdata.lastUSD.toFixed(2)) + ' / £' + parseFloat(btcdata.lastGBP.toFixed(2)) + '
₿' + balance + ' £' + parseFloat(owned.toFixed(2)) + '
'); - this.$btc.prop('title', title); - } -}); -'use strict'; - -/** - * Created by mdonnel on 22/03/2017. - */ - -var FxModel = Backbone.Model.extend({ - 'initialize': function initialize() { - this.set('url', '/fx'); - this.set('fxdata', {}); - this.update(); - }, - 'update': function update() { - this.getFX(); - var now = new Date(); - var mod = 900000 - now.getTime() % 900000; - - var fxUpdateFn = function fxUpdateFn() { - this.update(); - }; - setTimeout(fxUpdateFn.bind(this), mod + 10); - }, - 'getFX': function getFX() { - var url = this.get('url'); - var self = this; - $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', - - 'timeout': 10000, - - // 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 success(data) { - var fxdata = {}; - if (data.rates !== undefined) { - var gpbex = 1 / data.rates.GBP; - var sekex = gpbex * data.rates.SEK; - fxdata = { - 'usd': 1, - 'gbp': data.rates.GBP, - 'sek': data.rates.SEK, - 'gpbe': gpbex, - 'sekex': sekex - }; - } - - self.set('fxdata', fxdata); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - } -}); - -var FxView = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.bindAll(this, 'render'); - this.model.bind('change', this.render); - this.$fx = $('#fx'); - }, - 'render': function render() { - var fxdata = this.model.get('fxdata'); - this.$fx.html('£1 = $' + parseFloat(fxdata.gpbe.toFixed(2)) + ' = ' + parseFloat(fxdata.sekex.toFixed(2)) + ' SEK'); - } -}); -'use strict'; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -/** - * - * User: Martin Donnelly - * Date: 2016-10-03 - * Time: 14:20 - * - */ - -var TrainModel = Backbone.Model.extend({ - 'initialize': function initialize() { - var fromStation = this.get('from'); - var toStation = this.get('to'); - var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation; - var routeUrl = '/gettrains?from=' + fromStation + '&to=' + toStation; - var target = fromStation + toStation; - this.set('url', url); - this.set('routeUrl', routeUrl); - this.set('target', target); - this.set('visible', false); - this.set('trainData', { 'eta': 'OFF', 'sta': 'OFF' }); - this.update(); - }, - 'update': function update() { - var now = new Date(); - var hours = now.getHours(); - var limit = hours < 6 ? 3600000 : 60000; - - var mod = limit - now.getTime() % limit; - - if (hours >= 6) this.getTrain();else this.set('trainData', { 'eta': 'OFF', 'sta': 'OFF' }); - - var trainUpdateFn = function trainUpdateFn() { - this.update(); - }; - - setTimeout(trainUpdateFn.bind(this), mod + 10); - }, - 'getTrain': function getTrain() { - var url = this.get('url'); - var self = this; - $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', - 'timeout': 10000, - 'headers': { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' - }, - 'success': function success(data) { - self.set('trainData', data); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - }, - 'getRoute': function getRoute() { - var url = this.get('routeUrl'); - var self = this; - - if (this.get('visible') === true) this.set('visible', false);else $.ajax({ - 'type': 'GET', - 'url': url, - 'data': '', - 'dataType': 'json', - - 'timeout': 10000, - 'headers': { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' - - }, - 'success': function success(data) { - // getTrainsCB(data); - // console.log('Got', data); - - self.set('route', data); - self.set('visible', true); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - } -}); - -var TrainView = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.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 render() { - var obj = this.model.get('trainData'); - var visible = this.model.get('visible'); - var route = this.model.get('route'); - - var output = obj.eta.toLowerCase() === 'on time' ? obj.sta : obj.eta; - var status = obj.eta.toLowerCase() === 'on time' ? 'ontime' : 'delayed'; - - this.$button.html(output); - this.$button.removeClass('delayed').removeClass('ontime').addClass(status); - - if (visible) { - var ws = '
' + route.locationName + ' TO ' + route.filterLocationName + '
\n \n \n \n \n \n '; - - var services = []; - if (_typeof(route.trainServices) === 'object' && route.trainServices !== null) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = route.trainServices[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _item = _step.value; - - var dest = _item.destination[0]; - var via = dest.via !== null ? '' + dest.via + '' : ''; - var platform = _item.platform !== null ? _item.platform : '💠'; - var time = _item.sta !== null ? _item.sta : 'D ' + _item.std; - var _status = _item.eta !== null ? _item.eta : _item.etd; - - services.push({ 'location': dest.locationName, 'time': time, 'status': _status, 'platform': platform, 'cancel': _item.cancelReason, 'type': 'train' }); - if (!_item.isCancelled) ws = ws + '\n \n \n \n ';else ws = ws + '\n '; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - }if (_typeof(route.busServices) === 'object' && route.busServices !== null) { - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = route.busServices[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var _item2 = _step2.value; - - var _dest = _item2.destination[0]; - var _via = _dest.via !== null ? '' + _dest.via + '' : ''; - var _platform = _item2.platform !== null ? _item2.platform : ''; - var _time = _item2.sta !== null ? _item2.sta : 'D ' + _item2.std; - var _status2 = _item2.eta !== null ? _item2.eta : _item2.etd; - services.push({ 'location': _dest.locationName, 'time': _time, 'status': _status2, 'platform': _platform, 'cancel': _item2.cancelReason, 'type': 'bus' }); - // ws = ws + `
${dest.locationName} Bus ${via}
`; - // ws = ws + '
' + item.sta + '
'; - ws = ws + ''; - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - }ws = ws + '
DestinationTimeStatusPlatform
' + dest.locationName + ' ' + via + '' + time + '' + _status + '' + platform + '
' + dest.locationName + ' ' + via + '' + time + '\u274C ' + _item.cancelReason + '
\uD83D\uDE8C ' + _dest.locationName + ' ' + _via + '' + _time + '' + _status2 + '' + _platform + '
'; - this.$traintext.empty().html(ws); - this.$traintext.removeClass('mui--hide').addClass('mui--show'); - } else this.$traintext.removeClass('mui--show').addClass('mui--hide'); - }, - 'initView': function initView() { - // el: $('#myView').get(0) - var self = this; - var target = this.model.get('target'); - var html = '
' + target.toUpperCase() + ':
'; - this.$html = $(html); - this.$html.on('click', function () { - // console.log(self) - self.model.getRoute(); - }); - this.$trains.append(this.$html); - - // this.el = `#${target}`; - - this.$button = $('#' + target); - - var output = 'OFF'; - var status = output === 'on time' ? 'ontime' : 'delayed'; - - this.$button.html(output); - this.$button.removeClass('delayed').removeClass('ontime').addClass(status); - - var cevent = 'click #$(target)'; - this.events[cevent] = 'showTrains'; - }, - 'showTrains': function showTrains() { - void 0; - } - -}); -'use strict'; - -/** - * - * User: Martin Donnelly - * Date: 2016-10-03 - * Time: 14:20 - * - */ - -var WeatherModel = Backbone.Model.extend({ - 'initialize': function initialize() { - var geo = this.get('geo'); - this.set('url', 'https://api.darksky.net/forecast/9ad2a41d420f3cf4960571bb886f710c/' + geo.coords.latitude.toString() + ',' + geo.coords.longitude.toString() + '?units=uk2&exclude=minutely,hourly,alerts,flags'); - this.update(); - }, - 'update': function update() { - var _this = this; - - this.getWeather(); - var now = new Date(); - var mod = 1800000 - now.getTime() % 1800000; - var weatherTrigger = function weatherTrigger() { - _this.update(); - }; - - setTimeout(weatherTrigger.bind(this), mod + 10); - }, - 'getWeather': function getWeather() { - var self = this; - $.ajax({ - 'type': 'GET', - 'url': self.get('url'), - 'data': '', - 'dataType': 'jsonp', - 'timeout': 10000, - '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 success(data) { - var stored = { - 'temperature': data.currently.temperature, - 'icon': data.currently.icon, - 'summary': data.currently.summary, - 'daily': data.daily.summary - }; - self.set(stored); - }, - 'error': function error(xhr, type) { - void 0; - void 0; - void 0; - } - }); - } -}); - -var Weather = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.bindAll(this, 'render'); - this.model.bind('change', this.render); - this.$weatherText = $('#weatherDescription'); - this.$weatherTemp = $('#temp'); - this.$weatherIcon = $('#weatherIcon'); - }, - 'render': function render() { - void 0; - - var ws = ''; - - this.$weatherTemp.empty().html(parseInt(this.model.get('temperature')) + '°c '); - this.$weatherText.empty().html(this.model.get('summary')); - - this.$weatherIcon.empty().html(ws); - } - -}); - -var WeatherSlim = Backbone.View.extend({ - 'tagName': 'div', - 'initialize': function initialize() { - _.bindAll(this, 'render'); - this.model.bind('change', this.render); - this.$weather = $('#weather'); - this.render(); - }, - 'render': function render() { - var summary = this.model.get('summary'); - var temp = this.model.get('temperature'); - var daily = this.model.get('daily'); - - var ws = summary + ' ' + temp + '° ' + daily + ''; - - this.$weather.empty().html(ws); - } - -}); -'use strict'; - -/** - * Created by mdonnel on 20/04/2017. - */ -/*_.templateSettings = { - 'evaluate': /\{\{(.+?)\}\}/g, - 'interpolate': /\{\{=(.+?)\}\}/g, - 'escape': /\{\{-(.+?)\}\}/g -};*/ - -Array.prototype.random = function () { - return this[Math.floor(Math.random() * this.length)]; -}; - -var PasswordView = Backbone.View.extend({ - 'el': '#passwords', - 'passwordTemplate': _.template('
Long: <%=long%>
Short: <%=short%>
'), - 'initialize': function initialize() { - 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 - -}); - -function randomAmount(i) { - var str = ''; - - for (var t = 0; t < i; t++) { - str = str + this.alpha.random(); - }return str; -} - -function newClick(e) { - var long = (this.left.random() + ' ' + this.right.random() + ' ' + this.numberCluster()).split(' ').join(this.whitespace.random()); - var short = (this.randomAmount(5) + ' ' + this.randomAmount(5)).split(' ').join(this.whitespace.random()); - var html = this.passwordTemplate({ - 'long': long, - 'short': short - }); - this.passwordOut.removeClass('mui--hide'); - this.passwordOut.empty().append(html); -} - -function numberCluster() { - return this.numbers.random() + this.numbers.random() + this.numbers.random(); -} -'use strict'; - -(function () { - document.title = 'Slack'; -})(); - -var popitout = function popitout(url) { - var newwindow = window.open(url, 'name', 'height=600,width=570'); - if (window.focus) { - newwindow.focus(); - } - return false; -}; - -var popitoutSmall = function popitoutSmall(url) { - var newwindow = window.open(url, 'name', 'height=400,width=520'); - if (window.focus) { - newwindow.focus(); - } - return false; -}; \ No newline at end of file +"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}; \ No newline at end of file diff --git a/app/live/js/vendor.js b/app/live/js/vendor.js index 08e7d69..2aaa266 100644 --- a/app/live/js/vendor.js +++ b/app/live/js/vendor.js @@ -1,3 +1,18 @@ -!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):e(t)}(this,function(t){var e=function(){function $(t){return null==t?String(t):S[C.call(t)]||"object"}function F(t){return"function"==$(t)}function k(t){return null!=t&&t==t.window}function M(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function R(t){return"object"==$(t)}function Z(t){return R(t)&&!k(t)&&Object.getPrototypeOf(t)==Object.prototype}function z(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!k(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function q(t){return a.call(t,function(t){return null!=t})}function H(t){return t.length>0?r.fn.concat.apply([],t):t}function I(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function V(t){return t in l?l[t]:l[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function _(t,e){return"number"!=typeof e||h[I(t)]?e:e+"px"}function B(t){var e,n;return c[t]||(e=f.createElement(t),f.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),c[t]=n),c[t]}function U(t){return"children"in t?u.call(t.children):r.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function X(t,e){var n,r=t?t.length:0;for(n=0;r>n;n++)this[n]=t[n];this.length=r,this.selector=e||""}function J(t,r,i){for(n in r)i&&(Z(r[n])||L(r[n]))?(Z(r[n])&&!Z(t[n])&&(t[n]={}),L(r[n])&&!L(t[n])&&(t[n]=[]),J(t[n],r[n],i)):r[n]!==e&&(t[n]=r[n])}function W(t,e){return null==e?r(t):r(t).filter(e)}function Y(t,e,n,r){return F(e)?e.call(t,n,r):e}function G(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function K(t,n){var r=t.className||"",i=r&&r.baseVal!==e;return n===e?i?r.baseVal:r:void(i?r.baseVal=n:t.className=n)}function Q(t){try{return t?"true"==t||"false"!=t&&("null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?r.parseJSON(t):t):t}catch(e){return t}}function tt(t,e){e(t);for(var n=0,r=t.childNodes.length;r>n;n++)tt(t.childNodes[n],e)}var e,n,r,i,O,P,o=[],s=o.concat,a=o.filter,u=o.slice,f=t.document,c={},l={},h={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,d=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,g=/^(?:body|html)$/i,y=["val","css","html","text","data","width","height","offset"],x=["after","prepend","before","append"],b=f.createElement("table"),E=f.createElement("tr"),j={tr:f.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:E,th:E,"*":f.createElement("div")},w=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},C=S.toString,N={},A=f.createElement("div"),D={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},L=Array.isArray||function(t){return t instanceof Array};return N.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=A).appendChild(t),r=~N.qsa(i,e).indexOf(t),o&&A.removeChild(t),r},O=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},P=function(t){return a.call(t,function(e,n){return t.indexOf(e)==n})},N.fragment=function(t,n,i){var o,s,a;return d.test(t)&&(o=r(f.createElement(RegExp.$1))),o||(t.replace&&(t=t.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,"<$1>")),n===e&&(n=p.test(t)&&RegExp.$1),n in j||(n="*"),a=j[n],a.innerHTML=""+t,o=r.each(u.call(a.childNodes),function(){a.removeChild(this)})),Z(i)&&(s=r(o),r.each(i,function(t,e){y.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},N.Z=function(t,e){return new X(t,e)},N.isZ=function(t){return t instanceof N.Z},N.init=function(t,n){var i;if(!t)return N.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&p.test(t))i=N.fragment(t,RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}else{if(F(t))return r(f).ready(t);if(N.isZ(t))return t;if(L(t))i=q(t);else if(R(t))i=[t],t=null;else if(p.test(t))i=N.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}}return N.Z(i,t)},r=function(t,e){return N.init(t,e)},r.extend=function(t){var e,n=u.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){J(t,n,e)}),t},N.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:u.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=f.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=$,r.isFunction=F,r.isWindow=k,r.isArray=L,r.isPlainObject=Z,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return o.indexOf.call(e,t,n)},r.camelCase=O,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,r=[];if(z(t))for(i=0;i=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return o.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return F(t)?this.not(this.not(t)):r(a.call(this,function(e){return N.matches(e,t)}))},add:function(t,e){return r(P(this.concat(r(t,e))))},is:function(t){return this.length>0&&N.matches(this[0],t)},not:function(t){var n=[];if(F(t)&&t.call!==e)this.each(function(e){t.call(this,e)||n.push(this)});else{var i="string"==typeof t?this.filter(t):z(t)&&F(t.item)?u.call(t):r(t);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return R(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!R(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!R(t)?t:r(t)},find:function(t){var n=this;return t?"object"==typeof t?r(t).filter(function(){var t=this;return o.some.call(n,function(e){return r.contains(e,t)})}):1==this.length?r(N.qsa(this[0],t)):this.map(function(){return N.qsa(this,t)}):r()},closest:function(t,e){var n=[],i="object"==typeof t&&r(t);return this.each(function(r,o){for(;o&&!(i?i.indexOf(o)>=0:N.matches(o,t));)o=o!==e&&!M(o)&&o.parentNode;o&&n.indexOf(o)<0&&n.push(o)}),r(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){return(t=t.parentNode)&&!M(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return W(e,t)},parent:function(t){return W(P(this.pluck("parentNode")),t)},children:function(t){return W(this.map(function(){return U(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||u.call(this.childNodes)})},siblings:function(t){return W(this.map(function(t,e){return a.call(U(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=F(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){r(this[0]).before(t=r(t));for(var e;(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=F(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var n=r(this);(t===e?"none"==n.css("display"):t)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(Y(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,r){var i;return"string"!=typeof t||1 in arguments?this.each(function(e){if(1===this.nodeType)if(R(t))for(n in t)G(this,n,t[n]);else G(this,t,Y(this,r,e,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:e},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){G(this,t)},this)})},prop:function(t,e){return t=D[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=D[t]||t,this.each(function(){delete this[t]})},data:function(t,n){var r="data-"+t.replace(/([A-Z])/g,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?Q(i):e},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=Y(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=r(this),i=Y(this,e,t,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(f.documentElement!==this[0]&&!r.contains(f.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+t.pageXOffset,top:n.top+t.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(t,e){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[O(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(L(t)){if(!i)return;var o={},s=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[O(e)]||s.getPropertyValue(e)}),o}}var a="";if("string"==$(t))e||0===e?a=I(t)+":"+_(t,e):this.each(function(){this.style.removeProperty(I(t))});else for(n in t)t[n]||0===t[n]?a+=I(n)+":"+_(n,t[n])+";":this.each(function(){this.style.removeProperty(I(n))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&o.some.call(this,function(t){return this.test(K(t))},V(t))},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var n=K(this);Y(this,t,e,n).split(/\s+/g).forEach(function(t){r(this).hasClass(t)||i.push(t)},this),i.length&&K(this,n+(n?" ":"")+i.join(" "))}}):this},removeClass:function(t){return this.each(function(n){if("className"in this){if(t===e)return K(this,"");i=K(this),Y(this,t,n,i).split(/\s+/g).forEach(function(t){i=i.replace(V(t)," ")}),K(this,i.trim())}})},toggleClass:function(t,n){return t?this.each(function(i){var o=r(this);Y(this,t,i,K(this)).split(/\s+/g).forEach(function(t){(n===e?!o.hasClass(t):n)?o.addClass(t):o.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var n="scrollTop"in this[0];return t===e?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var n="scrollLeft"in this[0];return t===e?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=g.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||f.body;t&&!g.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(t){var n=t.replace(/./,function(t){return t[0].toUpperCase()});r.fn[t]=function(i){var o,s=this[0];return i===e?k(s)?s["inner"+n]:M(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[t]:this.each(function(e){s=r(this),s.css(t,Y(this,i,e,s[t]()))})}}),x.forEach(function(n,i){var o=i%2;r.fn[n]=function(){var n,a,s=r.map(arguments,function(t){var i=[];return n=$(t),"array"==n?(t.forEach(function(t){return t.nodeType!==e?i.push(t):r.zepto.isZ(t)?i=i.concat(t.get()):void(i=i.concat(N.fragment(t)))}),i):"object"==n||null==t?t:N.fragment(t)}),u=this.length>1;return s.length<1?this:this.each(function(e,n){a=o?n:n.parentNode,n=0==i?n.nextSibling:1==i?n.firstChild:2==i?n:null;var c=r.contains(f.documentElement,a);s.forEach(function(e){if(u)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,n),c&&tt(e,function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var n=e.ownerDocument?e.ownerDocument.defaultView:t;n.eval.call(n,e.innerHTML)}})})})},r.fn[o?n+"To":"insert"+(i?"Before":"After")]=function(t){return r(t)[n](this),this}}),N.Z.prototype=X.prototype=r.fn,N.uniq=P,N.deserializeValue=Q,r.zepto=N,r}();return t.Zepto=e,void 0===t.$&&(t.$=e),function(e){function h(t){return t._zid||(t._zid=n++)}function p(t,e,n,r){if(e=d(e),e.ns)var i=m(e.ns);return(a[h(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||h(t.fn)===h(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function g(t,e){return t.del&&!f&&t.e in c||!!e}function v(t){return l[t]||f&&c[t]||t}function y(t,n,i,o,s,u,f){var c=h(t),p=a[c]||(a[c]=[]);n.split(/\s/).forEach(function(n){if("ready"==n)return e(document).ready(i);var a=d(n);a.fn=i,a.sel=s,a.e in l&&(i=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?a.fn.apply(this,arguments):void 0}),a.del=u;var c=u||i;a.proxy=function(e){if(e=T(e),!e.isImmediatePropagationStopped()){e.data=o;var n=c.apply(t,e._args==r?[e]:[e].concat(e._args));return n===!1&&(e.preventDefault(),e.stopPropagation()),n}},a.i=p.length,p.push(a),"addEventListener"in t&&t.addEventListener(v(a.e),a.proxy,g(a,f))})}function x(t,e,n,r,i){var o=h(t);(e||"").split(/\s/).forEach(function(e){p(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(v(e.e),e.proxy,g(e,i))})})}function T(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(w,function(e,r){var i=n[e];t[e]=function(){return this[r]=b,i&&i.apply(n,arguments)},t[r]=E}),t.timeStamp||(t.timeStamp=Date.now()),(n.defaultPrevented!==r?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=b)),t}function S(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===r||(n[e]=t[e]);return T(n,t)}var r,n=1,i=Array.prototype.slice,o=e.isFunction,s=function(t){return"string"==typeof t},a={},u={},f="onfocusin"in t,c={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",e.event={add:y,remove:x},e.proxy=function(t,n){var r=2 in arguments&&i.call(arguments,2);if(o(t)){var a=function(){return t.apply(n,r?r.concat(i.call(arguments)):arguments)};return a._zid=h(t),a}if(s(n))return r?(r.unshift(t[n],t),e.proxy.apply(null,r)):e.proxy(t[n],t);throw new TypeError("expected function")},e.fn.bind=function(t,e,n){return this.on(t,e,n)},e.fn.unbind=function(t,e){return this.off(t,e)},e.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,w={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(t,e,n){return this.on(e,t,n)},e.fn.undelegate=function(t,e,n){return this.off(e,t,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,a,u,f){var c,l,h=this;return t&&!s(t)?(e.each(t,function(t,e){h.on(t,n,a,e,f)}),h):(s(n)||o(u)||u===!1||(u=a,a=n,n=r),(u===r||a===!1)&&(u=a,a=r),u===!1&&(u=E),h.each(function(r,o){f&&(c=function(t){return x(o,t.type,u),u.apply(this,arguments)}),n&&(l=function(t){var r,s=e(t.target).closest(n,o).get(0);return s&&s!==o?(r=e.extend(S(t),{currentTarget:s,liveFired:o}),(c||u).apply(s,[r].concat(i.call(arguments,1)))):void 0}),y(o,t,u,a,n,l||c)}))},e.fn.off=function(t,n,i){var a=this;return t&&!s(t)?(e.each(t,function(t,e){a.off(t,n,e)}),a):(s(n)||o(i)||i===!1||(i=n,n=r),i===!1&&(i=E),a.each(function(){x(this,t,i,n)}))},e.fn.trigger=function(t,n){return t=s(t)||e.isPlainObject(t)?e.Event(t):T(t),t._args=n,this.each(function(){t.type in c&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,n){var r,i;return this.each(function(o,a){r=S(s(t)?e.Event(t):t),r._args=n,r.target=a,e.each(p(a,t.type||t),function(t,e){return i=e.proxy(r),!r.isImmediatePropagationStopped()&&void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(t,e){s(t)||(e=t,t=e.type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),T(n)}}(e),function(e){function p(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function d(t,e,n,i){return t.global?p(e||r,n,i):void 0}function m(t){t.global&&0==e.active++&&d(t,null,"ajaxStart")}function g(t){t.global&&!--e.active&&d(t,null,"ajaxStop")}function v(t,e){var n=e.context;return e.beforeSend.call(n,t,e)!==!1&&d(e,n,"ajaxBeforeSend",[t,e])!==!1&&void d(e,n,"ajaxSend",[t,e])}function y(t,e,n,r){var i=n.context,o="success";n.success.call(i,t,o,e),r&&r.resolveWith(i,[t,o,e]),d(n,i,"ajaxSuccess",[e,n,t]),b(o,e,n)}function x(t,e,n,r,i){var o=r.context;r.error.call(o,n,e,t),i&&i.rejectWith(o,[n,e,t]),d(r,o,"ajaxError",[n,r,t||e]),b(e,n,r)}function b(t,e,n){var r=n.context;n.complete.call(r,e,t),d(n,r,"ajaxComplete",[e,n]),g(n)}function E(t,e,n){if(n.dataFilter==j)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function j(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==f?"json":a.test(t)?"script":u.test(t)&&"xml")||"text"}function T(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function S(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=T(t.url,t.data),t.data=void 0)}function C(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function O(t,n,r,i){var o,s=e.isArray(n),a=e.isPlainObject(n);e.each(n,function(n,u){o=e.type(u),i&&(n=r?i:i+"["+(a||"object"==o||"array"==o?n:"")+"]"),!i&&s?t.add(u.name,u.value):"array"==o||!r&&"object"==o?O(t,u,r,n):t.add(n,u)})}var i,o,n=+new Date,r=t.document,a=/^(?:text|application)\/javascript/i,u=/^(?:text|application)\/xml/i,f="application/json",c="text/html",l=/^\s*$/,h=r.createElement("a");h.href=t.location.href,e.active=0,e.ajaxJSONP=function(i,o){if(!("type"in i))return e.ajax(i);var c,p,s=i.jsonpCallback,a=(e.isFunction(s)?s():s)||"Zepto"+n++,u=r.createElement("script"),f=t[a],l=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:l};return o&&o.promise(h),e(u).on("load error",function(n,r){clearTimeout(p),e(u).off().remove(),"error"!=n.type&&c?y(c[0],h,i,o):x(null,r||"error",h,i,o),t[a]=f,c&&e.isFunction(f)&&f(c[0]),f=c=void 0}),v(h,i)===!1?(l("abort"),h):(t[a]=function(){c=arguments},u.src=i.url.replace(/\?(.+)=\?/,"?$1="+a),r.head.appendChild(u),i.timeout>0&&(p=setTimeout(function(){l("timeout")},i.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:j,success:j,error:j,complete:j,context:null,global:!0,xhr:function(){return new t.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:f,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:j},e.ajax=function(n){var u,f,s=e.extend({},n||{}),a=e.Deferred&&e.Deferred();for(i in e.ajaxSettings)void 0===s[i]&&(s[i]=e.ajaxSettings[i]);m(s),s.crossDomain||(u=r.createElement("a"),u.href=s.url,u.href=u.href,s.crossDomain=h.protocol+"//"+h.host!=u.protocol+"//"+u.host),s.url||(s.url=t.location.toString()),(f=s.url.indexOf("#"))>-1&&(s.url=s.url.slice(0,f)),S(s);var c=s.dataType,p=/\?.+=\?/.test(s.url);if(p&&(c="jsonp"),s.cache!==!1&&(n&&n.cache===!0||"script"!=c&&"jsonp"!=c)||(s.url=T(s.url,"_="+Date.now())),"jsonp"==c)return p||(s.url=T(s.url,s.jsonp?s.jsonp+"=?":s.jsonp===!1?"":"callback=?")),e.ajaxJSONP(s,a);var P,d=s.accepts[c],g={},b=function(t,e){g[t.toLowerCase()]=[t,e]},C=/^([\w-]+:)\/\//.test(s.url)?RegExp.$1:t.location.protocol,N=s.xhr(),O=N.setRequestHeader;if(a&&a.promise(N),s.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",d||"*/*"),(d=s.mimeType||d)&&(d.indexOf(",")>-1&&(d=d.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(d)),(s.contentType||s.contentType!==!1&&s.data&&"GET"!=s.type.toUpperCase())&&b("Content-Type",s.contentType||"application/x-www-form-urlencoded"),s.headers)for(o in s.headers)b(o,s.headers[o]);if(N.setRequestHeader=b,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=j,clearTimeout(P);var t,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==C){if(c=c||w(s.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)t=N.response;else{t=N.responseText;try{t=E(t,c,s),"script"==c?(0,eval)(t):"xml"==c?t=N.responseXML:"json"==c&&(t=l.test(t)?null:e.parseJSON(t))}catch(r){n=r}if(n)return x(n,"parsererror",N,s,a)}y(t,N,s,a)}else x(N.statusText||null,N.status?"error":"abort",N,s,a)}},v(N,s)===!1)return N.abort(),x(null,"abort",N,s,a),N;var A=!("async"in s)||s.async;if(N.open(s.type,s.url,A,s.username,s.password),s.xhrFields)for(o in s.xhrFields)N[o]=s.xhrFields[o];for(o in g)O.apply(N,g[o]);return s.timeout>0&&(P=setTimeout(function(){N.onreadystatechange=j,N.abort(),x(null,"timeout",N,s,a)},s.timeout)),N.send(s.data?s.data:null),N},e.get=function(){return e.ajax(C.apply(null,arguments))},e.post=function(){var t=C.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=C.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,r){if(!this.length)return this;var a,i=this,o=t.split(/\s/),u=C(t,n,r),f=u.success;return o.length>1&&(u.url=o[0],a=o[1]),u.success=function(t){i.html(a?e("
").html(t.replace(/)<[^<]*)*<\/script>/gi,"")).find(a):t),f&&f.apply(i,arguments)},e.ajax(u),this};var N=encodeURIComponent;e.param=function(t,n){var r=[];return r.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(t)+"="+N(n))},O(r,t,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,(e=o.name)&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;t.getComputedStyle=function(t,e){try{return n(t,e)}catch(r){return null}}}}(),e}),ejs=function(){function require(p){if("fs"==p)return{};if("path"==p)return{};var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');return mod.exports||(mod.exports={},mod.call(mod.exports,mod,mod.exports,require.relative(path))),mod.exports}return require.modules={},require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&®||require.modules[index]&&index||orig},require.register=function(path,fn){require.modules[path]=fn},require.relative=function(parent){return function(p){if("."!=p.substr(0,1))return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i> ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"ejs")+":"+lineno+"\n"+context+"\n\n"+err.message,err}function resolveInclude(name,filename){var path=join(dirname(filename),name);return extname(name)||(path+=".ejs"),path}var utils=require("./utils"),path=require("path"),dirname=path.dirname,extname=path.extname,join=path.join,fs=require("fs"),read=fs.readFileSync,filters=exports.filters=require("./filters"),cache={};exports.clearCache=function(){cache={}};var compile=(exports.parse=function(str,options){var options=options||{},open=options.open||exports.open||"<%",close=options.close||exports.close||"%>",filename=options.filename,compileDebug=options.compileDebug!==!1,buf="";buf+="var buf = [];",!1!==options._with&&(buf+="\nwith (locals || {}) { (function(){ "),buf+="\n buf.push('";for(var lineno=1,consumeEOL=!1,i=0,len=str.length;ijs.lastIndexOf("\n")&&(js+="\n"),buf+=prefix,buf+=js,buf+=postfix),i+=end-start+close.length-1}else"\\"==stri?buf+="\\\\":"'"==stri?buf+="\\'":"\r"==stri||("\n"==stri?consumeEOL?consumeEOL=!1:(buf+="\\n",lineno++):buf+=stri)}return buf+=!1!==options._with?"'); })();\n} \nreturn buf.join('');":"');\nreturn buf.join('');"},exports.compile=function(str,options){options=options||{};var escape=options.escape||utils.escape,input=JSON.stringify(str),compileDebug=options.compileDebug!==!1,client=options.client,filename=options.filename?JSON.stringify(options.filename):"undefined";str=compileDebug?["var __stack = { lineno: 1, input: "+input+", filename: "+filename+" };",rethrow.toString(),"try {",exports.parse(str,options),"} catch (err) {"," rethrow(err, __stack.input, __stack.filename, __stack.lineno);","}"].join("\n"):exports.parse(str,options),options.debug&&console.log(str),client&&(str="escape = escape || "+escape.toString()+";\n"+str);try{var fn=new Function("locals, filters, escape, rethrow",str)}catch(err){throw"SyntaxError"==err.name&&(err.message+=options.filename?" in "+filename:" while compiling ejs"),err}return client?fn:function(locals){return fn.call(this,locals,filters,escape,rethrow)}});exports.render=function(str,options){var fn,options=options||{};if(options.cache){if(!options.filename)throw new Error('"cache" option requires "filename".');fn=cache[options.filename]||(cache[options.filename]=compile(str,options))}else fn=compile(str,options);return options.__proto__=options.locals,fn.call(options.scope,options)},exports.renderFile=function(path,options,fn){var key=path+":string";"function"==typeof options&&(fn=options,options={}),options.filename=path;var str;try{str=options.cache?cache[key]||(cache[key]=read(path,"utf8")):read(path,"utf8")}catch(err){return void fn(err)}fn(null,exports.render(str,options))},exports.__express=exports.renderFile,require.extensions?require.extensions[".ejs"]=function(module,filename){filename=filename||module.filename;var options={filename:filename,client:!0},template=fs.readFileSync(filename).toString(),fn=compile(template,options);module._compile("module.exports = "+fn.toString()+";",filename)}:require.registerExtension&&require.registerExtension(".ejs",function(src){return compile(src,{})})}),require.register("filters.js",function(module,exports,require){exports.first=function(obj){return obj[0]},exports.last=function(obj){return obj[obj.length-1]},exports.capitalize=function(str){ -return str=String(str),str[0].toUpperCase()+str.substr(1,str.length)},exports.downcase=function(str){return String(str).toLowerCase()},exports.upcase=function(str){return String(str).toUpperCase()},exports.sort=function(obj){return Object.create(obj).sort()},exports.sort_by=function(obj,prop){return Object.create(obj).sort(function(a,b){return a=a[prop],b=b[prop],a>b?1:alen&&(str=str.slice(0,len),append&&(str+=append)),str},exports.truncate_words=function(str,n){var str=String(str);return str.split(/ +/).slice(0,n).join(" ")},exports.replace=function(str,pattern,substitution){return String(str).replace(pattern,substitution||"")},exports.prepend=function(obj,val){return Array.isArray(obj)?[val].concat(obj):val+obj},exports.append=function(obj,val){return Array.isArray(obj)?obj.concat(val):obj+val},exports.map=function(arr,prop){return arr.map(function(obj){return obj[prop]})},exports.reverse=function(obj){return Array.isArray(obj)?obj.reverse():String(obj).split("").reverse().join("")},exports.get=function(obj,prop){return obj[prop]},exports.json=function(obj){return JSON.stringify(obj)}}),require.register("utils.js",function(module,exports,require){exports.escape=function(html){return String(html).replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}}),require("ejs")}(),function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)(i=I[r])in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(void 0===t)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&void 0!==r[f]||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),void 0!==e&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)(e=n[a])>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){((u=t(n,r,e))>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){n(u,e,r(e,i,t))}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:0==+n?1/+n==1/t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if((c=n.length)!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n||(k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length)},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return void 0===n},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return void 0===e&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(/\\|'|\r|\n|\u2028|\u2029/g,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}.call(this),function(t){var e="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;if("function"==typeof define&&define.amd)define(["underscore","jquery","exports"],function(i,r,n){e.Backbone=t(e,n,i,r)});else if("undefined"!=typeof exports){var r,i=require("underscore");try{r=require("jquery")}catch(n){}t(e,exports,i,r)}else e.Backbone=t(e,{},e._,e.jQuery||e.Zepto||e.ender||e.$)}(function(t,e,i,r){var n=t.Backbone,s=Array.prototype.slice;e.VERSION="1.3.3",e.$=r,e.noConflict=function(){return t.Backbone=n,this},e.emulateHTTP=!1,e.emulateJSON=!1;var a=function(t,e,r){switch(t){case 1:return function(){return i[e](this[r])};case 2:return function(t){return i[e](this[r],t)};case 3:return function(t,n){return i[e](this[r],o(t,this),n)};case 4:return function(t,n,s){return i[e](this[r],o(t,this),n,s)};default:return function(){var t=s.call(arguments);return t.unshift(this[r]),i[e].apply(i,t)}}},h=function(t,e,r){i.each(e,function(e,n){i[n]&&(t.prototype[n]=a(e,n,r))})},o=function(t,e){return i.isFunction(t)?t:i.isObject(t)&&!e._isModel(t)?l(t):i.isString(t)?function(e){return e.get(t)}:t},l=function(t){var e=i.matches(t);return function(t){return e(t.attributes)}},u=e.Events={},c=/\s+/,f=function(t,e,r,n,s){var h,a=0;if(r&&"object"==typeof r){void 0!==n&&"context"in s&&void 0===s.context&&(s.context=n);for(h=i.keys(r);athis.length&&(n=this.length),n<0&&(n+=this.length+1);var p,m,s=[],a=[],h=[],o=[],l={},u=e.add,c=e.merge,f=e.remove,d=!1,v=this.comparator&&null==n&&e.sort!==!1,g=i.isString(this.comparator)?this.comparator:null;for(m=0;m7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(/^\/+|\/+$/g,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var r=document.body,n=r.insertBefore(this.iframe,r.firstChild).contentWindow;n.document.open(),n.document.close(),n.location.hash="#"+this.fragment}var s=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?s("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?s("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),N.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),i.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!N.started)return!1;e&&e!==!0||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root;""!==t&&"?"!==t.charAt(0)||(i=i.slice(0,-1)||"/");var r=i+t;if(t=this.decodeFragment(t.replace(/#.*$/,"")),this.fragment!==t){if(this.fragment=t,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,r);else{if(!this._wantsHashChange)return this.location.assign(r);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var n=this.iframe.contentWindow;e.replace||(n.document.open(),n.document.close()),this._updateHash(n.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else t.hash="#"+e}}),e.history=new N;var q=function(t,e){var n,r=this;return n=t&&i.has(t,"constructor")?t.constructor:function(){return r.apply(this,arguments)},i.extend(n,r,e),n.prototype=i.create(r.prototype,t),n.prototype.constructor=n,n.__super__=r.prototype,n};y.extend=x.extend=$.extend=k.extend=N.extend=q;var F=function(){throw new Error('A "url" property or function must be specified')},B=function(t,e){var i=e.error;e.error=function(r){i&&i.call(e.context,t,r,e),t.trigger("error",t,r,e)}};return e}); \ No newline at end of file +/* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */ +!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):e(t)}(this,function(t){var e=function(){function $(t){return null==t?String(t):S[C.call(t)]||"object"}function F(t){return"function"==$(t)}function k(t){return null!=t&&t==t.window}function M(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function R(t){return"object"==$(t)}function Z(t){return R(t)&&!k(t)&&Object.getPrototypeOf(t)==Object.prototype}function z(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!k(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function q(t){return a.call(t,function(t){return null!=t})}function H(t){return t.length>0?r.fn.concat.apply([],t):t}function I(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function V(t){return t in l?l[t]:l[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function _(t,e){return"number"!=typeof e||h[I(t)]?e:e+"px"}function B(t){var e,n;return c[t]||(e=f.createElement(t),f.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),c[t]=n),c[t]}function U(t){return"children"in t?u.call(t.children):r.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function X(t,e){var n,r=t?t.length:0;for(n=0;r>n;n++)this[n]=t[n];this.length=r,this.selector=e||""}function J(t,r,i){for(n in r)i&&(Z(r[n])||L(r[n]))?(Z(r[n])&&!Z(t[n])&&(t[n]={}),L(r[n])&&!L(t[n])&&(t[n]=[]),J(t[n],r[n],i)):r[n]!==e&&(t[n]=r[n])}function W(t,e){return null==e?r(t):r(t).filter(e)}function Y(t,e,n,r){return F(e)?e.call(t,n,r):e}function G(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function K(t,n){var r=t.className||"",i=r&&r.baseVal!==e;return n===e?i?r.baseVal:r:void(i?r.baseVal=n:t.className=n)}function Q(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?r.parseJSON(t):t):t}catch(e){return t}}function tt(t,e){e(t);for(var n=0,r=t.childNodes.length;r>n;n++)tt(t.childNodes[n],e)}var e,n,r,i,O,P,o=[],s=o.concat,a=o.filter,u=o.slice,f=t.document,c={},l={},h={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,d=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,g=/^(?:body|html)$/i,v=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],x=["after","prepend","before","append"],b=f.createElement("table"),E=f.createElement("tr"),j={tr:f.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:E,th:E,"*":f.createElement("div")},w=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},C=S.toString,N={},A=f.createElement("div"),D={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},L=Array.isArray||function(t){return t instanceof Array};return N.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=A).appendChild(t),r=~N.qsa(i,e).indexOf(t),o&&A.removeChild(t),r},O=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},P=function(t){return a.call(t,function(e,n){return t.indexOf(e)==n})},N.fragment=function(t,n,i){var o,s,a;return d.test(t)&&(o=r(f.createElement(RegExp.$1))),o||(t.replace&&(t=t.replace(m,"<$1>")),n===e&&(n=p.test(t)&&RegExp.$1),n in j||(n="*"),a=j[n],a.innerHTML=""+t,o=r.each(u.call(a.childNodes),function(){a.removeChild(this)})),Z(i)&&(s=r(o),r.each(i,function(t,e){y.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},N.Z=function(t,e){return new X(t,e)},N.isZ=function(t){return t instanceof N.Z},N.init=function(t,n){var i;if(!t)return N.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&p.test(t))i=N.fragment(t,RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}else{if(F(t))return r(f).ready(t);if(N.isZ(t))return t;if(L(t))i=q(t);else if(R(t))i=[t],t=null;else if(p.test(t))i=N.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}}return N.Z(i,t)},r=function(t,e){return N.init(t,e)},r.extend=function(t){var e,n=u.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){J(t,n,e)}),t},N.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:u.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=f.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=$,r.isFunction=F,r.isWindow=k,r.isArray=L,r.isPlainObject=Z,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return o.indexOf.call(e,t,n)},r.camelCase=O,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,r=[];if(z(t))for(i=0;i=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return o.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return F(t)?this.not(this.not(t)):r(a.call(this,function(e){return N.matches(e,t)}))},add:function(t,e){return r(P(this.concat(r(t,e))))},is:function(t){return this.length>0&&N.matches(this[0],t)},not:function(t){var n=[];if(F(t)&&t.call!==e)this.each(function(e){t.call(this,e)||n.push(this)});else{var i="string"==typeof t?this.filter(t):z(t)&&F(t.item)?u.call(t):r(t);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return R(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!R(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!R(t)?t:r(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?r(t).filter(function(){var t=this;return o.some.call(n,function(e){return r.contains(e,t)})}):1==this.length?r(N.qsa(this[0],t)):this.map(function(){return N.qsa(this,t)}):r()},closest:function(t,e){var n=[],i="object"==typeof t&&r(t);return this.each(function(r,o){for(;o&&!(i?i.indexOf(o)>=0:N.matches(o,t));)o=o!==e&&!M(o)&&o.parentNode;o&&n.indexOf(o)<0&&n.push(o)}),r(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){return(t=t.parentNode)&&!M(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return W(e,t)},parent:function(t){return W(P(this.pluck("parentNode")),t)},children:function(t){return W(this.map(function(){return U(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||u.call(this.childNodes)})},siblings:function(t){return W(this.map(function(t,e){return a.call(U(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=F(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){r(this[0]).before(t=r(t));for(var e;(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=F(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var n=r(this);(t===e?"none"==n.css("display"):t)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(Y(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,r){var i;return"string"!=typeof t||1 in arguments?this.each(function(e){if(1===this.nodeType)if(R(t))for(n in t)G(this,n,t[n]);else G(this,t,Y(this,r,e,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:e},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){G(this,t)},this)})},prop:function(t,e){return t=D[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=D[t]||t,this.each(function(){delete this[t]})},data:function(t,n){var r="data-"+t.replace(v,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?Q(i):e},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=Y(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=r(this),i=Y(this,e,t,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(f.documentElement!==this[0]&&!r.contains(f.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+t.pageXOffset,top:n.top+t.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(t,e){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[O(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(L(t)){if(!i)return;var o={},s=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[O(e)]||s.getPropertyValue(e)}),o}}var a="";if("string"==$(t))e||0===e?a=I(t)+":"+_(t,e):this.each(function(){this.style.removeProperty(I(t))});else for(n in t)t[n]||0===t[n]?a+=I(n)+":"+_(n,t[n])+";":this.each(function(){this.style.removeProperty(I(n))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?o.some.call(this,function(t){return this.test(K(t))},V(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var n=K(this),o=Y(this,t,e,n);o.split(/\s+/g).forEach(function(t){r(this).hasClass(t)||i.push(t)},this),i.length&&K(this,n+(n?" ":"")+i.join(" "))}}):this},removeClass:function(t){return this.each(function(n){if("className"in this){if(t===e)return K(this,"");i=K(this),Y(this,t,n,i).split(/\s+/g).forEach(function(t){i=i.replace(V(t)," ")}),K(this,i.trim())}})},toggleClass:function(t,n){return t?this.each(function(i){var o=r(this),s=Y(this,t,i,K(this));s.split(/\s+/g).forEach(function(t){(n===e?!o.hasClass(t):n)?o.addClass(t):o.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var n="scrollTop"in this[0];return t===e?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var n="scrollLeft"in this[0];return t===e?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=g.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||f.body;t&&!g.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(t){var n=t.replace(/./,function(t){return t[0].toUpperCase()});r.fn[t]=function(i){var o,s=this[0];return i===e?k(s)?s["inner"+n]:M(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[t]:this.each(function(e){s=r(this),s.css(t,Y(this,i,e,s[t]()))})}}),x.forEach(function(n,i){var o=i%2;r.fn[n]=function(){var n,a,s=r.map(arguments,function(t){var i=[];return n=$(t),"array"==n?(t.forEach(function(t){return t.nodeType!==e?i.push(t):r.zepto.isZ(t)?i=i.concat(t.get()):void(i=i.concat(N.fragment(t)))}),i):"object"==n||null==t?t:N.fragment(t)}),u=this.length>1;return s.length<1?this:this.each(function(e,n){a=o?n:n.parentNode,n=0==i?n.nextSibling:1==i?n.firstChild:2==i?n:null;var c=r.contains(f.documentElement,a);s.forEach(function(e){if(u)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,n),c&&tt(e,function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var n=e.ownerDocument?e.ownerDocument.defaultView:t;n.eval.call(n,e.innerHTML)}})})})},r.fn[o?n+"To":"insert"+(i?"Before":"After")]=function(t){return r(t)[n](this),this}}),N.Z.prototype=X.prototype=r.fn,N.uniq=P,N.deserializeValue=Q,r.zepto=N,r}();return t.Zepto=e,void 0===t.$&&(t.$=e),function(e){function h(t){return t._zid||(t._zid=n++)}function p(t,e,n,r){if(e=d(e),e.ns)var i=m(e.ns);return(a[h(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||h(t.fn)===h(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function g(t,e){return t.del&&!f&&t.e in c||!!e}function v(t){return l[t]||f&&c[t]||t}function y(t,n,i,o,s,u,f){var c=h(t),p=a[c]||(a[c]=[]);n.split(/\s/).forEach(function(n){if("ready"==n)return e(document).ready(i);var a=d(n);a.fn=i,a.sel=s,a.e in l&&(i=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?a.fn.apply(this,arguments):void 0}),a.del=u;var c=u||i;a.proxy=function(e){if(e=T(e),!e.isImmediatePropagationStopped()){e.data=o;var n=c.apply(t,e._args==r?[e]:[e].concat(e._args));return n===!1&&(e.preventDefault(),e.stopPropagation()),n}},a.i=p.length,p.push(a),"addEventListener"in t&&t.addEventListener(v(a.e),a.proxy,g(a,f))})}function x(t,e,n,r,i){var o=h(t);(e||"").split(/\s/).forEach(function(e){p(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(v(e.e),e.proxy,g(e,i))})})}function T(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(w,function(e,r){var i=n[e];t[e]=function(){return this[r]=b,i&&i.apply(n,arguments)},t[r]=E}),t.timeStamp||(t.timeStamp=Date.now()),(n.defaultPrevented!==r?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=b)),t}function S(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===r||(n[e]=t[e]);return T(n,t)}var r,n=1,i=Array.prototype.slice,o=e.isFunction,s=function(t){return"string"==typeof t},a={},u={},f="onfocusin"in t,c={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",e.event={add:y,remove:x},e.proxy=function(t,n){var r=2 in arguments&&i.call(arguments,2);if(o(t)){var a=function(){return t.apply(n,r?r.concat(i.call(arguments)):arguments)};return a._zid=h(t),a}if(s(n))return r?(r.unshift(t[n],t),e.proxy.apply(null,r)):e.proxy(t[n],t);throw new TypeError("expected function")},e.fn.bind=function(t,e,n){return this.on(t,e,n)},e.fn.unbind=function(t,e){return this.off(t,e)},e.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,w={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(t,e,n){return this.on(e,t,n)},e.fn.undelegate=function(t,e,n){return this.off(e,t,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,a,u,f){var c,l,h=this;return t&&!s(t)?(e.each(t,function(t,e){h.on(t,n,a,e,f)}),h):(s(n)||o(u)||u===!1||(u=a,a=n,n=r),(u===r||a===!1)&&(u=a,a=r),u===!1&&(u=E),h.each(function(r,o){f&&(c=function(t){return x(o,t.type,u),u.apply(this,arguments)}),n&&(l=function(t){var r,s=e(t.target).closest(n,o).get(0);return s&&s!==o?(r=e.extend(S(t),{currentTarget:s,liveFired:o}),(c||u).apply(s,[r].concat(i.call(arguments,1)))):void 0}),y(o,t,u,a,n,l||c)}))},e.fn.off=function(t,n,i){var a=this;return t&&!s(t)?(e.each(t,function(t,e){a.off(t,n,e)}),a):(s(n)||o(i)||i===!1||(i=n,n=r),i===!1&&(i=E),a.each(function(){x(this,t,i,n)}))},e.fn.trigger=function(t,n){return t=s(t)||e.isPlainObject(t)?e.Event(t):T(t),t._args=n,this.each(function(){t.type in c&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,n){var r,i;return this.each(function(o,a){r=S(s(t)?e.Event(t):t),r._args=n,r.target=a,e.each(p(a,t.type||t),function(t,e){return i=e.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(t,e){s(t)||(e=t,t=e.type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),T(n)}}(e),function(e){function p(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function d(t,e,n,i){return t.global?p(e||r,n,i):void 0}function m(t){t.global&&0===e.active++&&d(t,null,"ajaxStart")}function g(t){t.global&&!--e.active&&d(t,null,"ajaxStop")}function v(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||d(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void d(e,n,"ajaxSend",[t,e])}function y(t,e,n,r){var i=n.context,o="success";n.success.call(i,t,o,e),r&&r.resolveWith(i,[t,o,e]),d(n,i,"ajaxSuccess",[e,n,t]),b(o,e,n)}function x(t,e,n,r,i){var o=r.context;r.error.call(o,n,e,t),i&&i.rejectWith(o,[n,e,t]),d(r,o,"ajaxError",[n,r,t||e]),b(e,n,r)}function b(t,e,n){var r=n.context;n.complete.call(r,e,t),d(n,r,"ajaxComplete",[e,n]),g(n)}function E(t,e,n){if(n.dataFilter==j)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function j(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==f?"json":a.test(t)?"script":u.test(t)&&"xml")||"text"}function T(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function S(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=T(t.url,t.data),t.data=void 0)}function C(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function O(t,n,r,i){var o,s=e.isArray(n),a=e.isPlainObject(n);e.each(n,function(n,u){o=e.type(u),i&&(n=r?i:i+"["+(a||"object"==o||"array"==o?n:"")+"]"),!i&&s?t.add(u.name,u.value):"array"==o||!r&&"object"==o?O(t,u,r,n):t.add(n,u)})}var i,o,n=+new Date,r=t.document,s=/)<[^<]*)*<\/script>/gi,a=/^(?:text|application)\/javascript/i,u=/^(?:text|application)\/xml/i,f="application/json",c="text/html",l=/^\s*$/,h=r.createElement("a");h.href=t.location.href,e.active=0,e.ajaxJSONP=function(i,o){if(!("type"in i))return e.ajax(i);var c,p,s=i.jsonpCallback,a=(e.isFunction(s)?s():s)||"Zepto"+n++,u=r.createElement("script"),f=t[a],l=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:l};return o&&o.promise(h),e(u).on("load error",function(n,r){clearTimeout(p),e(u).off().remove(),"error"!=n.type&&c?y(c[0],h,i,o):x(null,r||"error",h,i,o),t[a]=f,c&&e.isFunction(f)&&f(c[0]),f=c=void 0}),v(h,i)===!1?(l("abort"),h):(t[a]=function(){c=arguments},u.src=i.url.replace(/\?(.+)=\?/,"?$1="+a),r.head.appendChild(u),i.timeout>0&&(p=setTimeout(function(){l("timeout")},i.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:j,success:j,error:j,complete:j,context:null,global:!0,xhr:function(){return new t.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:f,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:j},e.ajax=function(n){var u,f,s=e.extend({},n||{}),a=e.Deferred&&e.Deferred();for(i in e.ajaxSettings)void 0===s[i]&&(s[i]=e.ajaxSettings[i]);m(s),s.crossDomain||(u=r.createElement("a"),u.href=s.url,u.href=u.href,s.crossDomain=h.protocol+"//"+h.host!=u.protocol+"//"+u.host),s.url||(s.url=t.location.toString()),(f=s.url.indexOf("#"))>-1&&(s.url=s.url.slice(0,f)),S(s);var c=s.dataType,p=/\?.+=\?/.test(s.url);if(p&&(c="jsonp"),s.cache!==!1&&(n&&n.cache===!0||"script"!=c&&"jsonp"!=c)||(s.url=T(s.url,"_="+Date.now())),"jsonp"==c)return p||(s.url=T(s.url,s.jsonp?s.jsonp+"=?":s.jsonp===!1?"":"callback=?")),e.ajaxJSONP(s,a);var P,d=s.accepts[c],g={},b=function(t,e){g[t.toLowerCase()]=[t,e]},C=/^([\w-]+:)\/\//.test(s.url)?RegExp.$1:t.location.protocol,N=s.xhr(),O=N.setRequestHeader;if(a&&a.promise(N),s.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",d||"*/*"),(d=s.mimeType||d)&&(d.indexOf(",")>-1&&(d=d.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(d)),(s.contentType||s.contentType!==!1&&s.data&&"GET"!=s.type.toUpperCase())&&b("Content-Type",s.contentType||"application/x-www-form-urlencoded"),s.headers)for(o in s.headers)b(o,s.headers[o]);if(N.setRequestHeader=b,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=j,clearTimeout(P);var t,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==C){if(c=c||w(s.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)t=N.response;else{t=N.responseText;try{t=E(t,c,s),"script"==c?(1,eval)(t):"xml"==c?t=N.responseXML:"json"==c&&(t=l.test(t)?null:e.parseJSON(t))}catch(r){n=r}if(n)return x(n,"parsererror",N,s,a)}y(t,N,s,a)}else x(N.statusText||null,N.status?"error":"abort",N,s,a)}},v(N,s)===!1)return N.abort(),x(null,"abort",N,s,a),N;var A="async"in s?s.async:!0;if(N.open(s.type,s.url,A,s.username,s.password),s.xhrFields)for(o in s.xhrFields)N[o]=s.xhrFields[o];for(o in g)O.apply(N,g[o]);return s.timeout>0&&(P=setTimeout(function(){N.onreadystatechange=j,N.abort(),x(null,"timeout",N,s,a)},s.timeout)),N.send(s.data?s.data:null),N},e.get=function(){return e.ajax(C.apply(null,arguments))},e.post=function(){var t=C.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=C.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,r){if(!this.length)return this;var a,i=this,o=t.split(/\s/),u=C(t,n,r),f=u.success;return o.length>1&&(u.url=o[0],a=o[1]),u.success=function(t){i.html(a?e("
").html(t.replace(s,"")).find(a):t),f&&f.apply(i,arguments)},e.ajax(u),this};var N=encodeURIComponent;e.param=function(t,n){var r=[];return r.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(t)+"="+N(n))},O(r,t,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;t.getComputedStyle=function(t,e){try{return n(t,e)}catch(r){return null}}}}(),e}); +ejs=function(){function require(p){if("fs"==p)return{};if("path"==p)return{};var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');if(!mod.exports){mod.exports={};mod.call(mod.exports,mod,mod.exports,require.relative(path))}return mod.exports}require.modules={};require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&®||require.modules[index]&&index||orig};require.register=function(path,fn){require.modules[path]=fn};require.relative=function(parent){return function(p){if("."!=p.substr(0,1))return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i> ":" ")+curr+"| "+line}).join("\n");err.path=filename;err.message=(filename||"ejs")+":"+lineno+"\n"+context+"\n\n"+err.message;throw err}var parse=exports.parse=function(str,options){var options=options||{},open=options.open||exports.open||"<%",close=options.close||exports.close||"%>",filename=options.filename,compileDebug=options.compileDebug!==false,buf="";buf+="var buf = [];";if(false!==options._with)buf+="\nwith (locals || {}) { (function(){ ";buf+="\n buf.push('";var lineno=1;var consumeEOL=false;for(var i=0,len=str.length;ijs.lastIndexOf("\n"))js+="\n";buf+=prefix;buf+=js;buf+=postfix}i+=end-start+close.length-1}else if(stri=="\\"){buf+="\\\\"}else if(stri=="'"){buf+="\\'"}else if(stri=="\r"){}else if(stri=="\n"){if(consumeEOL){consumeEOL=false}else{buf+="\\n";lineno++}}else{buf+=stri}}if(false!==options._with)buf+="'); })();\n} \nreturn buf.join('');";else buf+="');\nreturn buf.join('');";return buf};var compile=exports.compile=function(str,options){options=options||{};var escape=options.escape||utils.escape;var input=JSON.stringify(str),compileDebug=options.compileDebug!==false,client=options.client,filename=options.filename?JSON.stringify(options.filename):"undefined";if(compileDebug){str=["var __stack = { lineno: 1, input: "+input+", filename: "+filename+" };",rethrow.toString(),"try {",exports.parse(str,options),"} catch (err) {"," rethrow(err, __stack.input, __stack.filename, __stack.lineno);","}"].join("\n")}else{str=exports.parse(str,options)}if(options.debug)console.log(str);if(client)str="escape = escape || "+escape.toString()+";\n"+str;try{var fn=new Function("locals, filters, escape, rethrow",str)}catch(err){if("SyntaxError"==err.name){err.message+=options.filename?" in "+filename:" while compiling ejs"}throw err}if(client)return fn;return function(locals){return fn.call(this,locals,filters,escape,rethrow)}};exports.render=function(str,options){var fn,options=options||{};if(options.cache){if(options.filename){fn=cache[options.filename]||(cache[options.filename]=compile(str,options))}else{throw new Error('"cache" option requires "filename".')}}else{fn=compile(str,options)}options.__proto__=options.locals;return fn.call(options.scope,options)};exports.renderFile=function(path,options,fn){var key=path+":string";if("function"==typeof options){fn=options,options={}}options.filename=path;var str;try{str=options.cache?cache[key]||(cache[key]=read(path,"utf8")):read(path,"utf8")}catch(err){fn(err);return}fn(null,exports.render(str,options))};function resolveInclude(name,filename){var path=join(dirname(filename),name);var ext=extname(name);if(!ext)path+=".ejs";return path}exports.__express=exports.renderFile;if(require.extensions){require.extensions[".ejs"]=function(module,filename){filename=filename||module.filename;var options={filename:filename,client:true},template=fs.readFileSync(filename).toString(),fn=compile(template,options);module._compile("module.exports = "+fn.toString()+";",filename)}}else if(require.registerExtension){require.registerExtension(".ejs",function(src){return compile(src,{})})}});require.register("filters.js",function(module,exports,require){exports.first=function(obj){return obj[0]};exports.last=function(obj){return obj[obj.length-1]};exports.capitalize=function(str){str=String(str);return str[0].toUpperCase()+str.substr(1,str.length)};exports.downcase=function(str){return String(str).toLowerCase()};exports.upcase=function(str){return String(str).toUpperCase()};exports.sort=function(obj){return Object.create(obj).sort()};exports.sort_by=function(obj,prop){return Object.create(obj).sort(function(a,b){a=a[prop],b=b[prop];if(a>b)return 1;if(alen){str=str.slice(0,len);if(append)str+=append}return str};exports.truncate_words=function(str,n){var str=String(str),words=str.split(/ +/);return words.slice(0,n).join(" ")};exports.replace=function(str,pattern,substitution){return String(str).replace(pattern,substitution||"")};exports.prepend=function(obj,val){return Array.isArray(obj)?[val].concat(obj):val+obj};exports.append=function(obj,val){return Array.isArray(obj)?obj.concat(val):obj+val};exports.map=function(arr,prop){return arr.map(function(obj){return obj[prop]})};exports.reverse=function(obj){return Array.isArray(obj)?obj.reverse():String(obj).split("").reverse().join("")};exports.get=function(obj,prop){return obj[prop]};exports.json=function(obj){return JSON.stringify(obj)}});require.register("utils.js",function(module,exports,require){exports.escape=function(html){return String(html).replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}});return require("ejs")}(); +// Underscore.js 1.8.3 +// http://underscorejs.org +// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); +//# sourceMappingURL=underscore-min.map +(function(t){var e=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global;if(typeof define==="function"&&define.amd){define(["underscore","jquery","exports"],function(i,r,n){e.Backbone=t(e,n,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore"),r;try{r=require("jquery")}catch(n){}t(e,exports,i,r)}else{e.Backbone=t(e,{},e._,e.jQuery||e.Zepto||e.ender||e.$)}})(function(t,e,i,r){var n=t.Backbone;var s=Array.prototype.slice;e.VERSION="1.3.3";e.$=r;e.noConflict=function(){t.Backbone=n;return this};e.emulateHTTP=false;e.emulateJSON=false;var a=function(t,e,r){switch(t){case 1:return function(){return i[e](this[r])};case 2:return function(t){return i[e](this[r],t)};case 3:return function(t,n){return i[e](this[r],o(t,this),n)};case 4:return function(t,n,s){return i[e](this[r],o(t,this),n,s)};default:return function(){var t=s.call(arguments);t.unshift(this[r]);return i[e].apply(i,t)}}};var h=function(t,e,r){i.each(e,function(e,n){if(i[n])t.prototype[n]=a(e,n,r)})};var o=function(t,e){if(i.isFunction(t))return t;if(i.isObject(t)&&!e._isModel(t))return l(t);if(i.isString(t))return function(e){return e.get(t)};return t};var l=function(t){var e=i.matches(t);return function(t){return e(t.attributes)}};var u=e.Events={};var c=/\s+/;var f=function(t,e,r,n,s){var a=0,h;if(r&&typeof r==="object"){if(n!==void 0&&"context"in s&&s.context===void 0)s.context=n;for(h=i.keys(r);athis.length)n=this.length;if(n<0)n+=this.length+1;var s=[];var a=[];var h=[];var o=[];var l={};var u=e.add;var c=e.merge;var f=e.remove;var d=false;var v=this.comparator&&n==null&&e.sort!==false;var g=i.isString(this.comparator)?this.comparator:null;var p,m;for(m=0;m7);this._useHashChange=this._wantsHashChange&&this._hasHashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.history&&this.history.pushState);this._usePushState=this._wantsPushState&&this._hasPushState;this.fragment=this.getFragment();this.root=("/"+this.root+"/").replace(O,"/");if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";this.location.replace(e+"#"+this.getPath());return true}else if(this._hasPushState&&this.atRoot()){this.navigate(this.getHash(),{replace:true})}}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe");this.iframe.src="javascript:0";this.iframe.style.display="none";this.iframe.tabIndex=-1;var r=document.body;var n=r.insertBefore(this.iframe,r.firstChild).contentWindow;n.document.open();n.document.close();n.location.hash="#"+this.fragment}var s=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState){s("popstate",this.checkUrl,false)}else if(this._useHashChange&&!this.iframe){s("hashchange",this.checkUrl,false)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}if(!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};if(this._usePushState){t("popstate",this.checkUrl,false)}else if(this._useHashChange&&!this.iframe){t("hashchange",this.checkUrl,false)}if(this.iframe){document.body.removeChild(this.iframe);this.iframe=null}if(this._checkUrlInterval)clearInterval(this._checkUrlInterval);N.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getHash(this.iframe.contentWindow)}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()},loadUrl:function(t){if(!this.matchRoot())return false;t=this.fragment=this.getFragment(t);return i.some(this.handlers,function(e){if(e.route.test(t)){e.callback(t);return true}})},navigate:function(t,e){if(!N.started)return false;if(!e||e===true)e={trigger:!!e};t=this.getFragment(t||"");var i=this.root;if(t===""||t.charAt(0)==="?"){i=i.slice(0,-1)||"/"}var r=i+t;t=this.decodeFragment(t.replace(U,""));if(this.fragment===t)return;this.fragment=t;if(this._usePushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,r)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var n=this.iframe.contentWindow;if(!e.replace){n.document.open();n.document.close()}this._updateHash(n.location,t,e.replace)}}else{return this.location.assign(r)}if(e.trigger)return this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});e.history=new N;var q=function(t,e){var r=this;var n;if(t&&i.has(t,"constructor")){n=t.constructor}else{n=function(){return r.apply(this,arguments)}}i.extend(n,r,e);n.prototype=i.create(r.prototype,t);n.prototype.constructor=n;n.__super__=r.prototype;return n};y.extend=x.extend=$.extend=k.extend=N.extend=q;var F=function(){throw new Error('A "url" property or function must be specified')};var B=function(t,e){var i=e.error;e.error=function(r){if(i)i.call(e.context,t,r,e);t.trigger("error",t,r,e)}};return e}); +//# sourceMappingURL=backbone-min.map +//! moment.js +//! version : 2.18.1 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com +!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return sd.apply(null,arguments)}function b(a){sd=a}function c(a){return a instanceof Array||"[object Array]"===Object.prototype.toString.call(a)}function d(a){return null!=a&&"[object Object]"===Object.prototype.toString.call(a)}function e(a){var b;for(b in a)return!1;return!0}function f(a){return void 0===a}function g(a){return"number"==typeof a||"[object Number]"===Object.prototype.toString.call(a)}function h(a){return a instanceof Date||"[object Date]"===Object.prototype.toString.call(a)}function i(a,b){var c,d=[];for(c=0;c0)for(c=0;c0?"future":"past"];return z(c)?c(b):c.replace(/%s/i,b)}function J(a,b){var c=a.toLowerCase();Hd[c]=Hd[c+"s"]=Hd[b]=a}function K(a){return"string"==typeof a?Hd[a]||Hd[a.toLowerCase()]:void 0}function L(a){var b,c,d={};for(c in a)j(a,c)&&(b=K(c),b&&(d[b]=a[c]));return d}function M(a,b){Id[a]=b}function N(a){var b=[];for(var c in a)b.push({unit:c,priority:Id[c]});return b.sort(function(a,b){return a.priority-b.priority}),b}function O(b,c){return function(d){return null!=d?(Q(this,b,d),a.updateOffset(this,c),this):P(this,b)}}function P(a,b){return a.isValid()?a._d["get"+(a._isUTC?"UTC":"")+b]():NaN}function Q(a,b,c){a.isValid()&&a._d["set"+(a._isUTC?"UTC":"")+b](c)}function R(a){return a=K(a),z(this[a])?this[a]():this}function S(a,b){if("object"==typeof a){a=L(a);for(var c=N(a),d=0;d=0;return(f?c?"+":"":"-")+Math.pow(10,Math.max(0,e)).toString().substr(1)+d}function U(a,b,c,d){var e=d;"string"==typeof d&&(e=function(){return this[d]()}),a&&(Md[a]=e),b&&(Md[b[0]]=function(){return T(e.apply(this,arguments),b[1],b[2])}),c&&(Md[c]=function(){return this.localeData().ordinal(e.apply(this,arguments),a)})}function V(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function W(a){var b,c,d=a.match(Jd);for(b=0,c=d.length;b=0&&Kd.test(a);)a=a.replace(Kd,c),Kd.lastIndex=0,d-=1;return a}function Z(a,b,c){ce[a]=z(b)?b:function(a,d){return a&&c?c:b}}function $(a,b){return j(ce,a)?ce[a](b._strict,b._locale):new RegExp(_(a))}function _(a){return aa(a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}))}function aa(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function ba(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),g(b)&&(d=function(a,c){c[b]=u(a)}),c=0;c=0&&isFinite(h.getFullYear())&&h.setFullYear(a),h}function ta(a){var b=new Date(Date.UTC.apply(null,arguments));return a<100&&a>=0&&isFinite(b.getUTCFullYear())&&b.setUTCFullYear(a),b}function ua(a,b,c){var d=7+b-c,e=(7+ta(a,0,d).getUTCDay()-b)%7;return-e+d-1}function va(a,b,c,d,e){var f,g,h=(7+c-d)%7,i=ua(a,d,e),j=1+7*(b-1)+h+i;return j<=0?(f=a-1,g=pa(f)+j):j>pa(a)?(f=a+1,g=j-pa(a)):(f=a,g=j),{year:f,dayOfYear:g}}function wa(a,b,c){var d,e,f=ua(a.year(),b,c),g=Math.floor((a.dayOfYear()-f-1)/7)+1;return g<1?(e=a.year()-1,d=g+xa(e,b,c)):g>xa(a.year(),b,c)?(d=g-xa(a.year(),b,c),e=a.year()+1):(e=a.year(),d=g),{week:d,year:e}}function xa(a,b,c){var d=ua(a,b,c),e=ua(a+1,b,c);return(pa(a)-d+e)/7}function ya(a){return wa(a,this._week.dow,this._week.doy).week}function za(){return this._week.dow}function Aa(){return this._week.doy}function Ba(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function Ca(a){var b=wa(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}function Da(a,b){return"string"!=typeof a?a:isNaN(a)?(a=b.weekdaysParse(a),"number"==typeof a?a:null):parseInt(a,10)}function Ea(a,b){return"string"==typeof a?b.weekdaysParse(a)%7||7:isNaN(a)?null:a}function Fa(a,b){return a?c(this._weekdays)?this._weekdays[a.day()]:this._weekdays[this._weekdays.isFormat.test(b)?"format":"standalone"][a.day()]:c(this._weekdays)?this._weekdays:this._weekdays.standalone}function Ga(a){return a?this._weekdaysShort[a.day()]:this._weekdaysShort}function Ha(a){return a?this._weekdaysMin[a.day()]:this._weekdaysMin}function Ia(a,b,c){var d,e,f,g=a.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],d=0;d<7;++d)f=l([2e3,1]).day(d),this._minWeekdaysParse[d]=this.weekdaysMin(f,"").toLocaleLowerCase(),this._shortWeekdaysParse[d]=this.weekdaysShort(f,"").toLocaleLowerCase(),this._weekdaysParse[d]=this.weekdays(f,"").toLocaleLowerCase();return c?"dddd"===b?(e=ne.call(this._weekdaysParse,g),e!==-1?e:null):"ddd"===b?(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:null):(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null):"dddd"===b?(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null))):"ddd"===b?(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null))):(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:null)))}function Ja(a,b,c){var d,e,f;if(this._weekdaysParseExact)return Ia.call(this,a,b,c);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),d=0;d<7;d++){if(e=l([2e3,1]).day(d),c&&!this._fullWeekdaysParse[d]&&(this._fullWeekdaysParse[d]=new RegExp("^"+this.weekdays(e,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[d]=new RegExp("^"+this.weekdaysShort(e,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[d]=new RegExp("^"+this.weekdaysMin(e,"").replace(".",".?")+"$","i")),this._weekdaysParse[d]||(f="^"+this.weekdays(e,"")+"|^"+this.weekdaysShort(e,"")+"|^"+this.weekdaysMin(e,""),this._weekdaysParse[d]=new RegExp(f.replace(".",""),"i")),c&&"dddd"===b&&this._fullWeekdaysParse[d].test(a))return d;if(c&&"ddd"===b&&this._shortWeekdaysParse[d].test(a))return d;if(c&&"dd"===b&&this._minWeekdaysParse[d].test(a))return d;if(!c&&this._weekdaysParse[d].test(a))return d}}function Ka(a){if(!this.isValid())return null!=a?this:NaN;var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Da(a,this.localeData()),this.add(a-b,"d")):b}function La(a){if(!this.isValid())return null!=a?this:NaN;var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function Ma(a){if(!this.isValid())return null!=a?this:NaN;if(null!=a){var b=Ea(a,this.localeData());return this.day(this.day()%7?b:b-7)}return this.day()||7}function Na(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysStrictRegex:this._weekdaysRegex):(j(this,"_weekdaysRegex")||(this._weekdaysRegex=ye),this._weekdaysStrictRegex&&a?this._weekdaysStrictRegex:this._weekdaysRegex)}function Oa(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(j(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=ze),this._weekdaysShortStrictRegex&&a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Pa(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(j(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Ae),this._weekdaysMinStrictRegex&&a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Qa(){function a(a,b){return b.length-a.length}var b,c,d,e,f,g=[],h=[],i=[],j=[];for(b=0;b<7;b++)c=l([2e3,1]).day(b),d=this.weekdaysMin(c,""),e=this.weekdaysShort(c,""),f=this.weekdays(c,""),g.push(d),h.push(e),i.push(f),j.push(d),j.push(e),j.push(f);for(g.sort(a),h.sort(a),i.sort(a),j.sort(a),b=0;b<7;b++)h[b]=aa(h[b]),i[b]=aa(i[b]),j[b]=aa(j[b]);this._weekdaysRegex=new RegExp("^("+j.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+g.join("|")+")","i")}function Ra(){return this.hours()%12||12}function Sa(){return this.hours()||24}function Ta(a,b){U(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}function Ua(a,b){return b._meridiemParse}function Va(a){return"p"===(a+"").toLowerCase().charAt(0)}function Wa(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function Xa(a){return a?a.toLowerCase().replace("_","-"):a}function Ya(a){for(var b,c,d,e,f=0;f0;){if(d=Za(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&v(e,c,!0)>=b-1)break;b--}f++}return null}function Za(a){var b=null;if(!Fe[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=Be._abbr,require("./locale/"+a),$a(b)}catch(a){}return Fe[a]}function $a(a,b){var c;return a&&(c=f(b)?bb(a):_a(a,b),c&&(Be=c)),Be._abbr}function _a(a,b){if(null!==b){var c=Ee;if(b.abbr=a,null!=Fe[a])y("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),c=Fe[a]._config;else if(null!=b.parentLocale){if(null==Fe[b.parentLocale])return Ge[b.parentLocale]||(Ge[b.parentLocale]=[]),Ge[b.parentLocale].push({name:a,config:b}),null;c=Fe[b.parentLocale]._config}return Fe[a]=new C(B(c,b)),Ge[a]&&Ge[a].forEach(function(a){_a(a.name,a.config)}),$a(a),Fe[a]}return delete Fe[a],null}function ab(a,b){if(null!=b){var c,d=Ee;null!=Fe[a]&&(d=Fe[a]._config),b=B(d,b),c=new C(b),c.parentLocale=Fe[a],Fe[a]=c,$a(a)}else null!=Fe[a]&&(null!=Fe[a].parentLocale?Fe[a]=Fe[a].parentLocale:null!=Fe[a]&&delete Fe[a]);return Fe[a]}function bb(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return Be;if(!c(a)){if(b=Za(a))return b;a=[a]}return Ya(a)}function cb(){return Ad(Fe)}function db(a){var b,c=a._a;return c&&n(a).overflow===-2&&(b=c[fe]<0||c[fe]>11?fe:c[ge]<1||c[ge]>ea(c[ee],c[fe])?ge:c[he]<0||c[he]>24||24===c[he]&&(0!==c[ie]||0!==c[je]||0!==c[ke])?he:c[ie]<0||c[ie]>59?ie:c[je]<0||c[je]>59?je:c[ke]<0||c[ke]>999?ke:-1,n(a)._overflowDayOfYear&&(bge)&&(b=ge),n(a)._overflowWeeks&&b===-1&&(b=le),n(a)._overflowWeekday&&b===-1&&(b=me),n(a).overflow=b),a}function eb(a){var b,c,d,e,f,g,h=a._i,i=He.exec(h)||Ie.exec(h);if(i){for(n(a).iso=!0,b=0,c=Ke.length;b10?"YYYY ":"YY "),f="HH:mm"+(c[4]?":ss":""),c[1]){var l=new Date(c[2]),m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][l.getDay()];if(c[1].substr(0,3)!==m)return n(a).weekdayMismatch=!0,void(a._isValid=!1)}switch(c[5].length){case 2:0===i?h=" +0000":(i=k.indexOf(c[5][1].toUpperCase())-12,h=(i<0?" -":" +")+(""+i).replace(/^-?/,"0").match(/..$/)[0]+"00");break;case 4:h=j[c[5]];break;default:h=j[" GMT"]}c[5]=h,a._i=c.splice(1).join(""),g=" ZZ",a._f=d+e+f+g,lb(a),n(a).rfc2822=!0}else a._isValid=!1}function gb(b){var c=Me.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(eb(b),void(b._isValid===!1&&(delete b._isValid,fb(b),b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b)))))}function hb(a,b,c){return null!=a?a:null!=b?b:c}function ib(b){var c=new Date(a.now());return b._useUTC?[c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()]:[c.getFullYear(),c.getMonth(),c.getDate()]}function jb(a){var b,c,d,e,f=[];if(!a._d){for(d=ib(a),a._w&&null==a._a[ge]&&null==a._a[fe]&&kb(a),null!=a._dayOfYear&&(e=hb(a._a[ee],d[ee]),(a._dayOfYear>pa(e)||0===a._dayOfYear)&&(n(a)._overflowDayOfYear=!0),c=ta(e,0,a._dayOfYear),a._a[fe]=c.getUTCMonth(),a._a[ge]=c.getUTCDate()),b=0;b<3&&null==a._a[b];++b)a._a[b]=f[b]=d[b];for(;b<7;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];24===a._a[he]&&0===a._a[ie]&&0===a._a[je]&&0===a._a[ke]&&(a._nextDay=!0,a._a[he]=0),a._d=(a._useUTC?ta:sa).apply(null,f),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[he]=24)}}function kb(a){var b,c,d,e,f,g,h,i;if(b=a._w,null!=b.GG||null!=b.W||null!=b.E)f=1,g=4,c=hb(b.GG,a._a[ee],wa(tb(),1,4).year),d=hb(b.W,1),e=hb(b.E,1),(e<1||e>7)&&(i=!0);else{f=a._locale._week.dow,g=a._locale._week.doy;var j=wa(tb(),f,g);c=hb(b.gg,a._a[ee],j.year),d=hb(b.w,j.week),null!=b.d?(e=b.d,(e<0||e>6)&&(i=!0)):null!=b.e?(e=b.e+f,(b.e<0||b.e>6)&&(i=!0)):e=f}d<1||d>xa(c,f,g)?n(a)._overflowWeeks=!0:null!=i?n(a)._overflowWeekday=!0:(h=va(c,d,e,f,g),a._a[ee]=h.year,a._dayOfYear=h.dayOfYear)}function lb(b){if(b._f===a.ISO_8601)return void eb(b);if(b._f===a.RFC_2822)return void fb(b);b._a=[],n(b).empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,j=0;for(e=Y(b._f,b._locale).match(Jd)||[],c=0;c0&&n(b).unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),j+=d.length),Md[f]?(d?n(b).empty=!1:n(b).unusedTokens.push(f),da(f,d,b)):b._strict&&!d&&n(b).unusedTokens.push(f);n(b).charsLeftOver=i-j,h.length>0&&n(b).unusedInput.push(h),b._a[he]<=12&&n(b).bigHour===!0&&b._a[he]>0&&(n(b).bigHour=void 0),n(b).parsedDateParts=b._a.slice(0),n(b).meridiem=b._meridiem,b._a[he]=mb(b._locale,b._a[he],b._meridiem),jb(b),db(b)}function mb(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&b<12&&(b+=12),d||12!==b||(b=0),b):b}function nb(a){var b,c,d,e,f;if(0===a._f.length)return n(a).invalidFormat=!0,void(a._d=new Date(NaN));for(e=0;ethis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ob(){if(!f(this._isDSTShifted))return this._isDSTShifted;var a={};if(q(a,this),a=qb(a),a._a){var b=a._isUTC?l(a._a):tb(a._a);this._isDSTShifted=this.isValid()&&v(a._a,b.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Pb(){return!!this.isValid()&&!this._isUTC}function Qb(){return!!this.isValid()&&this._isUTC}function Rb(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Sb(a,b){var c,d,e,f=a,h=null;return Bb(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:g(a)?(f={},b?f[b]=a:f.milliseconds=a):(h=Te.exec(a))?(c="-"===h[1]?-1:1,f={y:0,d:u(h[ge])*c,h:u(h[he])*c,m:u(h[ie])*c,s:u(h[je])*c,ms:u(Cb(1e3*h[ke]))*c}):(h=Ue.exec(a))?(c="-"===h[1]?-1:1,f={y:Tb(h[2],c),M:Tb(h[3],c),w:Tb(h[4],c),d:Tb(h[5],c),h:Tb(h[6],c),m:Tb(h[7],c),s:Tb(h[8],c)}):null==f?f={}:"object"==typeof f&&("from"in f||"to"in f)&&(e=Vb(tb(f.from),tb(f.to)),f={},f.ms=e.milliseconds,f.M=e.months),d=new Ab(f),Bb(a)&&j(a,"_locale")&&(d._locale=a._locale),d}function Tb(a,b){var c=a&&parseFloat(a.replace(",","."));return(isNaN(c)?0:c)*b}function Ub(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function Vb(a,b){var c;return a.isValid()&&b.isValid()?(b=Fb(b,a),a.isBefore(b)?c=Ub(a,b):(c=Ub(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c):{milliseconds:0,months:0}}function Wb(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(y(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Sb(c,d),Xb(this,e,a),this}}function Xb(b,c,d,e){var f=c._milliseconds,g=Cb(c._days),h=Cb(c._months);b.isValid()&&(e=null==e||e,f&&b._d.setTime(b._d.valueOf()+f*d),g&&Q(b,"Date",P(b,"Date")+g*d),h&&ja(b,P(b,"Month")+h*d),e&&a.updateOffset(b,g||h))}function Yb(a,b){var c=a.diff(b,"days",!0);return c<-6?"sameElse":c<-1?"lastWeek":c<0?"lastDay":c<1?"sameDay":c<2?"nextDay":c<7?"nextWeek":"sameElse"}function Zb(b,c){var d=b||tb(),e=Fb(d,this).startOf("day"),f=a.calendarFormat(this,e)||"sameElse",g=c&&(z(c[f])?c[f].call(this,d):c[f]);return this.format(g||this.localeData().calendar(f,this,tb(d)))}function $b(){return new r(this)}function _b(a,b){var c=s(a)?a:tb(a);return!(!this.isValid()||!c.isValid())&&(b=K(f(b)?"millisecond":b),"millisecond"===b?this.valueOf()>c.valueOf():c.valueOf()9999?X(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):z(Date.prototype.toISOString)?this.toDate().toISOString():X(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function jc(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var a="moment",b="";this.isLocal()||(a=0===this.utcOffset()?"moment.utc":"moment.parseZone",b="Z");var c="["+a+'("]',d=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",e="-MM-DD[T]HH:mm:ss.SSS",f=b+'[")]';return this.format(c+d+e+f)}function kc(b){b||(b=this.isUtc()?a.defaultFormatUtc:a.defaultFormat);var c=X(this,b);return this.localeData().postformat(c)}function lc(a,b){return this.isValid()&&(s(a)&&a.isValid()||tb(a).isValid())?Sb({to:this,from:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function mc(a){return this.from(tb(),a)}function nc(a,b){return this.isValid()&&(s(a)&&a.isValid()||tb(a).isValid())?Sb({from:this,to:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function oc(a){return this.to(tb(),a)}function pc(a){var b;return void 0===a?this._locale._abbr:(b=bb(a),null!=b&&(this._locale=b),this)}function qc(){return this._locale}function rc(a){switch(a=K(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":case"date":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a&&this.weekday(0),"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this}function sc(a){return a=K(a),void 0===a||"millisecond"===a?this:("date"===a&&(a="day"),this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms"))}function tc(){return this._d.valueOf()-6e4*(this._offset||0)}function uc(){return Math.floor(this.valueOf()/1e3)}function vc(){return new Date(this.valueOf())}function wc(){var a=this;return[a.year(),a.month(),a.date(),a.hour(),a.minute(),a.second(),a.millisecond()]}function xc(){var a=this;return{years:a.year(),months:a.month(),date:a.date(),hours:a.hours(),minutes:a.minutes(),seconds:a.seconds(),milliseconds:a.milliseconds()}}function yc(){return this.isValid()?this.toISOString():null}function zc(){return o(this)}function Ac(){ +return k({},n(this))}function Bc(){return n(this).overflow}function Cc(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Dc(a,b){U(0,[a,a.length],0,b)}function Ec(a){return Ic.call(this,a,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Fc(a){return Ic.call(this,a,this.isoWeek(),this.isoWeekday(),1,4)}function Gc(){return xa(this.year(),1,4)}function Hc(){var a=this.localeData()._week;return xa(this.year(),a.dow,a.doy)}function Ic(a,b,c,d,e){var f;return null==a?wa(this,d,e).year:(f=xa(a,d,e),b>f&&(b=f),Jc.call(this,a,b,c,d,e))}function Jc(a,b,c,d,e){var f=va(a,b,c,d,e),g=ta(f.year,0,f.dayOfYear);return this.year(g.getUTCFullYear()),this.month(g.getUTCMonth()),this.date(g.getUTCDate()),this}function Kc(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)}function Lc(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function Mc(a,b){b[ke]=u(1e3*("0."+a))}function Nc(){return this._isUTC?"UTC":""}function Oc(){return this._isUTC?"Coordinated Universal Time":""}function Pc(a){return tb(1e3*a)}function Qc(){return tb.apply(null,arguments).parseZone()}function Rc(a){return a}function Sc(a,b,c,d){var e=bb(),f=l().set(d,b);return e[c](f,a)}function Tc(a,b,c){if(g(a)&&(b=a,a=void 0),a=a||"",null!=b)return Sc(a,b,c,"month");var d,e=[];for(d=0;d<12;d++)e[d]=Sc(a,d,c,"month");return e}function Uc(a,b,c,d){"boolean"==typeof a?(g(b)&&(c=b,b=void 0),b=b||""):(b=a,c=b,a=!1,g(b)&&(c=b,b=void 0),b=b||"");var e=bb(),f=a?e._week.dow:0;if(null!=c)return Sc(b,(c+f)%7,d,"day");var h,i=[];for(h=0;h<7;h++)i[h]=Sc(b,(h+f)%7,d,"day");return i}function Vc(a,b){return Tc(a,b,"months")}function Wc(a,b){return Tc(a,b,"monthsShort")}function Xc(a,b,c){return Uc(a,b,c,"weekdays")}function Yc(a,b,c){return Uc(a,b,c,"weekdaysShort")}function Zc(a,b,c){return Uc(a,b,c,"weekdaysMin")}function $c(){var a=this._data;return this._milliseconds=df(this._milliseconds),this._days=df(this._days),this._months=df(this._months),a.milliseconds=df(a.milliseconds),a.seconds=df(a.seconds),a.minutes=df(a.minutes),a.hours=df(a.hours),a.months=df(a.months),a.years=df(a.years),this}function _c(a,b,c,d){var e=Sb(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}function ad(a,b){return _c(this,a,b,1)}function bd(a,b){return _c(this,a,b,-1)}function cd(a){return a<0?Math.floor(a):Math.ceil(a)}function dd(){var a,b,c,d,e,f=this._milliseconds,g=this._days,h=this._months,i=this._data;return f>=0&&g>=0&&h>=0||f<=0&&g<=0&&h<=0||(f+=864e5*cd(fd(h)+g),g=0,h=0),i.milliseconds=f%1e3,a=t(f/1e3),i.seconds=a%60,b=t(a/60),i.minutes=b%60,c=t(b/60),i.hours=c%24,g+=t(c/24),e=t(ed(g)),h+=e,g-=cd(fd(e)),d=t(h/12),h%=12,i.days=g,i.months=h,i.years=d,this}function ed(a){return 4800*a/146097}function fd(a){return 146097*a/4800}function gd(a){if(!this.isValid())return NaN;var b,c,d=this._milliseconds;if(a=K(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+ed(b),"month"===a?c:c/12;switch(b=this._days+Math.round(fd(this._months)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 1440*b+d/6e4;case"second":return 86400*b+d/1e3;case"millisecond":return Math.floor(864e5*b)+d;default:throw new Error("Unknown unit "+a)}}function hd(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*u(this._months/12):NaN}function id(a){return function(){return this.as(a)}}function jd(a){return a=K(a),this.isValid()?this[a+"s"]():NaN}function kd(a){return function(){return this.isValid()?this._data[a]:NaN}}function ld(){return t(this.days()/7)}function md(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function nd(a,b,c){var d=Sb(a).abs(),e=uf(d.as("s")),f=uf(d.as("m")),g=uf(d.as("h")),h=uf(d.as("d")),i=uf(d.as("M")),j=uf(d.as("y")),k=e<=vf.ss&&["s",e]||e0,k[4]=c,md.apply(null,k)}function od(a){return void 0===a?uf:"function"==typeof a&&(uf=a,!0)}function pd(a,b){return void 0!==vf[a]&&(void 0===b?vf[a]:(vf[a]=b,"s"===a&&(vf.ss=b-1),!0))}function qd(a){if(!this.isValid())return this.localeData().invalidDate();var b=this.localeData(),c=nd(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function rd(){if(!this.isValid())return this.localeData().invalidDate();var a,b,c,d=wf(this._milliseconds)/1e3,e=wf(this._days),f=wf(this._months);a=t(d/60),b=t(a/60),d%=60,a%=60,c=t(f/12),f%=12;var g=c,h=f,i=e,j=b,k=a,l=d,m=this.asSeconds();return m?(m<0?"-":"")+"P"+(g?g+"Y":"")+(h?h+"M":"")+(i?i+"D":"")+(j||k||l?"T":"")+(j?j+"H":"")+(k?k+"M":"")+(l?l+"S":""):"P0D"}var sd,td;td=Array.prototype.some?Array.prototype.some:function(a){for(var b=Object(this),c=b.length>>>0,d=0;d68?1900:2e3)};var te=O("FullYear",!0);U("w",["ww",2],"wo","week"),U("W",["WW",2],"Wo","isoWeek"),J("week","w"),J("isoWeek","W"),M("week",5),M("isoWeek",5),Z("w",Sd),Z("ww",Sd,Od),Z("W",Sd),Z("WW",Sd,Od),ca(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=u(a)});var ue={dow:0,doy:6};U("d",0,"do","day"),U("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),U("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),U("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),U("e",0,0,"weekday"),U("E",0,0,"isoWeekday"),J("day","d"),J("weekday","e"),J("isoWeekday","E"),M("day",11),M("weekday",11),M("isoWeekday",11),Z("d",Sd),Z("e",Sd),Z("E",Sd),Z("dd",function(a,b){return b.weekdaysMinRegex(a)}),Z("ddd",function(a,b){return b.weekdaysShortRegex(a)}),Z("dddd",function(a,b){return b.weekdaysRegex(a)}),ca(["dd","ddd","dddd"],function(a,b,c,d){var e=c._locale.weekdaysParse(a,d,c._strict);null!=e?b.d=e:n(c).invalidWeekday=a}),ca(["d","e","E"],function(a,b,c,d){b[d]=u(a)});var ve="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),we="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),xe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ye=be,ze=be,Ae=be;U("H",["HH",2],0,"hour"),U("h",["hh",2],0,Ra),U("k",["kk",2],0,Sa),U("hmm",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)}),U("hmmss",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)+T(this.seconds(),2)}),U("Hmm",0,0,function(){return""+this.hours()+T(this.minutes(),2)}),U("Hmmss",0,0,function(){return""+this.hours()+T(this.minutes(),2)+T(this.seconds(),2)}),Ta("a",!0),Ta("A",!1),J("hour","h"),M("hour",13),Z("a",Ua),Z("A",Ua),Z("H",Sd),Z("h",Sd),Z("k",Sd),Z("HH",Sd,Od),Z("hh",Sd,Od),Z("kk",Sd,Od),Z("hmm",Td),Z("hmmss",Ud),Z("Hmm",Td),Z("Hmmss",Ud),ba(["H","HH"],he),ba(["k","kk"],function(a,b,c){var d=u(a);b[he]=24===d?0:d}),ba(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),ba(["h","hh"],function(a,b,c){b[he]=u(a),n(c).bigHour=!0}),ba("hmm",function(a,b,c){var d=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d)),n(c).bigHour=!0}),ba("hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d,2)),b[je]=u(a.substr(e)),n(c).bigHour=!0}),ba("Hmm",function(a,b,c){var d=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d))}),ba("Hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d,2)),b[je]=u(a.substr(e))});var Be,Ce=/[ap]\.?m?\.?/i,De=O("Hours",!0),Ee={calendar:Bd,longDateFormat:Cd,invalidDate:Dd,ordinal:Ed,dayOfMonthOrdinalParse:Fd,relativeTime:Gd,months:pe,monthsShort:qe,week:ue,weekdays:ve,weekdaysMin:xe,weekdaysShort:we,meridiemParse:Ce},Fe={},Ge={},He=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ie=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Je=/Z|[+-]\d\d(?::?\d\d)?/,Ke=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Le=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Me=/^\/?Date\((\-?\d+)/i,Ne=/^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;a.createFromInputFallback=x("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),a.ISO_8601=function(){},a.RFC_2822=function(){};var Oe=x("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var a=tb.apply(null,arguments);return this.isValid()&&a.isValid()?athis?this:a:p()}),Qe=function(){return Date.now?Date.now():+new Date},Re=["year","quarter","month","week","day","hour","minute","second","millisecond"];Db("Z",":"),Db("ZZ",""),Z("Z",_d),Z("ZZ",_d),ba(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=Eb(_d,a)});var Se=/([\+\-]|\d\d)/gi;a.updateOffset=function(){};var Te=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,Ue=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Sb.fn=Ab.prototype,Sb.invalid=zb;var Ve=Wb(1,"add"),We=Wb(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",a.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Xe=x("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});U(0,["gg",2],0,function(){return this.weekYear()%100}),U(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Dc("gggg","weekYear"),Dc("ggggg","weekYear"),Dc("GGGG","isoWeekYear"),Dc("GGGGG","isoWeekYear"),J("weekYear","gg"),J("isoWeekYear","GG"),M("weekYear",1),M("isoWeekYear",1),Z("G",Zd),Z("g",Zd),Z("GG",Sd,Od),Z("gg",Sd,Od),Z("GGGG",Wd,Qd),Z("gggg",Wd,Qd),Z("GGGGG",Xd,Rd),Z("ggggg",Xd,Rd),ca(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=u(a)}),ca(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),U("Q",0,"Qo","quarter"),J("quarter","Q"),M("quarter",7),Z("Q",Nd),ba("Q",function(a,b){b[fe]=3*(u(a)-1)}),U("D",["DD",2],"Do","date"),J("date","D"),M("date",9),Z("D",Sd),Z("DD",Sd,Od),Z("Do",function(a,b){return a?b._dayOfMonthOrdinalParse||b._ordinalParse:b._dayOfMonthOrdinalParseLenient}),ba(["D","DD"],ge),ba("Do",function(a,b){b[ge]=u(a.match(Sd)[0],10)});var Ye=O("Date",!0);U("DDD",["DDDD",3],"DDDo","dayOfYear"),J("dayOfYear","DDD"),M("dayOfYear",4),Z("DDD",Vd),Z("DDDD",Pd),ba(["DDD","DDDD"],function(a,b,c){c._dayOfYear=u(a)}),U("m",["mm",2],0,"minute"),J("minute","m"),M("minute",14),Z("m",Sd),Z("mm",Sd,Od),ba(["m","mm"],ie);var Ze=O("Minutes",!1);U("s",["ss",2],0,"second"),J("second","s"),M("second",15),Z("s",Sd),Z("ss",Sd,Od),ba(["s","ss"],je);var $e=O("Seconds",!1);U("S",0,0,function(){return~~(this.millisecond()/100)}),U(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),U(0,["SSS",3],0,"millisecond"),U(0,["SSSS",4],0,function(){return 10*this.millisecond()}),U(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),U(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),U(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),U(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),U(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),J("millisecond","ms"),M("millisecond",16),Z("S",Vd,Nd),Z("SS",Vd,Od),Z("SSS",Vd,Pd);var _e;for(_e="SSSS";_e.length<=9;_e+="S")Z(_e,Yd);for(_e="S";_e.length<=9;_e+="S")ba(_e,Mc);var af=O("Milliseconds",!1);U("z",0,0,"zoneAbbr"),U("zz",0,0,"zoneName");var bf=r.prototype;bf.add=Ve,bf.calendar=Zb,bf.clone=$b,bf.diff=fc,bf.endOf=sc,bf.format=kc,bf.from=lc,bf.fromNow=mc,bf.to=nc,bf.toNow=oc,bf.get=R,bf.invalidAt=Bc,bf.isAfter=_b,bf.isBefore=ac,bf.isBetween=bc,bf.isSame=cc,bf.isSameOrAfter=dc,bf.isSameOrBefore=ec,bf.isValid=zc,bf.lang=Xe,bf.locale=pc,bf.localeData=qc,bf.max=Pe,bf.min=Oe,bf.parsingFlags=Ac,bf.set=S,bf.startOf=rc,bf.subtract=We,bf.toArray=wc,bf.toObject=xc,bf.toDate=vc,bf.toISOString=ic,bf.inspect=jc,bf.toJSON=yc,bf.toString=hc,bf.unix=uc,bf.valueOf=tc,bf.creationData=Cc,bf.year=te,bf.isLeapYear=ra,bf.weekYear=Ec,bf.isoWeekYear=Fc,bf.quarter=bf.quarters=Kc,bf.month=ka,bf.daysInMonth=la,bf.week=bf.weeks=Ba,bf.isoWeek=bf.isoWeeks=Ca,bf.weeksInYear=Hc,bf.isoWeeksInYear=Gc,bf.date=Ye,bf.day=bf.days=Ka,bf.weekday=La,bf.isoWeekday=Ma,bf.dayOfYear=Lc,bf.hour=bf.hours=De,bf.minute=bf.minutes=Ze,bf.second=bf.seconds=$e,bf.millisecond=bf.milliseconds=af,bf.utcOffset=Hb,bf.utc=Jb,bf.local=Kb,bf.parseZone=Lb,bf.hasAlignedHourOffset=Mb,bf.isDST=Nb,bf.isLocal=Pb,bf.isUtcOffset=Qb,bf.isUtc=Rb,bf.isUTC=Rb,bf.zoneAbbr=Nc,bf.zoneName=Oc,bf.dates=x("dates accessor is deprecated. Use date instead.",Ye),bf.months=x("months accessor is deprecated. Use month instead",ka),bf.years=x("years accessor is deprecated. Use year instead",te),bf.zone=x("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Ib),bf.isDSTShifted=x("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Ob);var cf=C.prototype;cf.calendar=D,cf.longDateFormat=E,cf.invalidDate=F,cf.ordinal=G,cf.preparse=Rc,cf.postformat=Rc,cf.relativeTime=H,cf.pastFuture=I,cf.set=A,cf.months=fa,cf.monthsShort=ga,cf.monthsParse=ia,cf.monthsRegex=na,cf.monthsShortRegex=ma,cf.week=ya,cf.firstDayOfYear=Aa,cf.firstDayOfWeek=za,cf.weekdays=Fa,cf.weekdaysMin=Ha,cf.weekdaysShort=Ga,cf.weekdaysParse=Ja,cf.weekdaysRegex=Na,cf.weekdaysShortRegex=Oa,cf.weekdaysMinRegex=Pa,cf.isPM=Va,cf.meridiem=Wa,$a("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===u(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),a.lang=x("moment.lang is deprecated. Use moment.locale instead.",$a),a.langData=x("moment.langData is deprecated. Use moment.localeData instead.",bb);var df=Math.abs,ef=id("ms"),ff=id("s"),gf=id("m"),hf=id("h"),jf=id("d"),kf=id("w"),lf=id("M"),mf=id("y"),nf=kd("milliseconds"),of=kd("seconds"),pf=kd("minutes"),qf=kd("hours"),rf=kd("days"),sf=kd("months"),tf=kd("years"),uf=Math.round,vf={ss:44,s:45,m:45,h:22,d:26,M:11},wf=Math.abs,xf=Ab.prototype;return xf.isValid=yb,xf.abs=$c,xf.add=ad,xf.subtract=bd,xf.as=gd,xf.asMilliseconds=ef,xf.asSeconds=ff,xf.asMinutes=gf,xf.asHours=hf,xf.asDays=jf,xf.asWeeks=kf,xf.asMonths=lf,xf.asYears=mf,xf.valueOf=hd,xf._bubble=dd,xf.get=jd,xf.milliseconds=nf,xf.seconds=of,xf.minutes=pf,xf.hours=qf,xf.days=rf,xf.weeks=ld,xf.months=sf,xf.years=tf,xf.humanize=qd,xf.toISOString=rd,xf.toString=rd,xf.toJSON=rd,xf.locale=pc,xf.localeData=qc,xf.toIsoString=x("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",rd),xf.lang=Xe,U("X",0,0,"unix"),U("x",0,0,"valueOf"),Z("x",Zd),Z("X",ae),ba("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),ba("x",function(a,b,c){c._d=new Date(u(a))}),a.version="2.18.1",b(tb),a.fn=bf,a.min=vb,a.max=wb,a.now=Qe,a.utc=l,a.unix=Pc,a.months=Vc,a.isDate=h,a.locale=$a,a.invalid=p,a.duration=Sb,a.isMoment=s,a.weekdays=Xc,a.parseZone=Qc,a.localeData=bb,a.isDuration=Bb,a.monthsShort=Wc,a.weekdaysMin=Zc,a.defineLocale=_a,a.updateLocale=ab,a.locales=cb,a.weekdaysShort=Yc,a.normalizeUnits=K,a.relativeTimeRounding=od,a.relativeTimeThreshold=pd,a.calendarFormat=Yb,a.prototype=bf,a}); \ No newline at end of file diff --git a/bower.json b/bower.json index fe8181f..8ecb2cd 100644 --- a/bower.json +++ b/bower.json @@ -18,6 +18,9 @@ "dependencies": { "moment": "^2.18.1", "mui": "^0.9.21", - "float": "^1.0.2" + "float": "^1.0.2", + "zepto": "^1.2.0", + "backbone": "^1.3.3", + "ejs": "^1.0.0" } } diff --git a/gulpfile.js b/gulpfile.js index 976fb54..475fb35 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,33 +23,33 @@ const dest = 'app/live'; const fontOptions = { }; gulp.task('appJS', function() { - return gulp.src(['app/js/modules/events.js', 'app/js/modules/bitcoin.js', 'app/js/modules/fx.js', 'app/js/modules/train.js', 'app/js/modules/weather.js', 'app/js/modules/password.js', 'app/app.js']) - .pipe(stripDebug()) - .pipe(jshint('.jshintrc')) - .pipe(jshint.reporter('default')) - .pipe(babel({ 'presets': ['es2015'] })) - .pipe(concat('app.js')) - .pipe(uglify({ 'mangle': true, 'compress': { 'sequences': true, // Join consecutive statemets with the “comma operator” - 'properties': true, // Optimize property access: a["foo"] → a.foo - 'dead_code': true, // Discard unreachable code - 'drop_debugger': true, // Discard “debugger” statements - 'unsafe': false, // Some unsafe optimizations (see below) - 'conditionals': true, // Optimize if-s and conditional expressions - 'comparisons': true, // Optimize comparisons - 'evaluate': true, // Evaluate constant expressions - 'booleans': true, // Optimize boolean expressions - 'loops': true, // Optimize loops - 'unused': true, // Drop unused variables/functions - 'hoist_funs': true, // Hoist function declarations - 'hoist_vars': true, // Hoist variable declarations - 'if_return': true, // Optimize if-s followed by return/continue - 'join_vars': true, // Join var declarations - 'cascade': true, // Try to cascade `right` into `left` in sequences - 'side_effects': true, // Drop side-effect-free statements - 'warnings': true, // Warn about potentially dangerous optimizations/code - 'global_defs': {} // global definitions - } })) - .pipe(gulp.dest(`${dest }/js`)); + return gulp.src(['app/js/websocket.js', 'app/js/slackSocket.js', 'app/js/modules/events.js', 'app/js/modules/bitcoin.js', 'app/js/modules/fx.js', 'app/js/modules/train.js', 'app/js/modules/weatherV2.js', 'app/js/modules/password.js', 'app/app.js']) + .pipe(stripDebug()) + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('default')) + .pipe(babel({ 'presets': ['es2015'] })) + .pipe(concat('app.js')) + .pipe(uglify({ 'mangle': true, 'compress': { 'sequences': true, // Join consecutive statemets with the “comma operator” + 'properties': true, // Optimize property access: a["foo"] → a.foo + 'dead_code': true, // Discard unreachable code + 'drop_debugger': true, // Discard “debugger” statements + 'unsafe': false, // Some unsafe optimizations (see below) + 'conditionals': true, // Optimize if-s and conditional expressions + 'comparisons': true, // Optimize comparisons + 'evaluate': true, // Evaluate constant expressions + 'booleans': true, // Optimize boolean expressions + 'loops': true, // Optimize loops + 'unused': true, // Drop unused variables/functions + 'hoist_funs': true, // Hoist function declarations + 'hoist_vars': true, // Hoist variable declarations + 'if_return': true, // Optimize if-s followed by return/continue + 'join_vars': true, // Join var declarations + 'cascade': true, // Try to cascade `right` into `left` in sequences + 'side_effects': true, // Drop side-effect-free statements + 'warnings': true, // Warn about potentially dangerous optimizations/code + 'global_defs': {} // global definitions + } })) + .pipe(gulp.dest(`${dest }/js`)); }); gulp.task('customMUI', function() { @@ -57,7 +57,7 @@ gulp.task('customMUI', function() { .pipe(sass({ 'outputStyle': 'compressed' }).on('error', sass.logError)) // .pipe(cssnano()) .pipe(rename('mui.custom.css')) - .pipe(gulp.dest(`${dest }/css`)); + .pipe(gulp.dest(`${dest}/css`)); }); gulp.task('vendor', function() { @@ -65,18 +65,26 @@ gulp.task('vendor', function() { 'bower_components/zepto/zepto.min.js', 'bower_components/ejs/ejs.min.js', 'bower_components/underscore/underscore-min.js', - 'bower_components/backbone/backbone-min.js' + 'bower_components/backbone/backbone-min.js', + 'bower_components/moment/min/moment.min.js' ]) - .pipe(concat('vendor.js')) - .pipe(uglify({ 'mangle': false })) - .pipe(gulp.dest(`${dest }/js`)); + .pipe(concat('vendor.js')) + /*.pipe(uglify({ 'mangle': false }))*/ + .pipe(gulp.dest(`${dest }/js`)); }); gulp.task('fonts', function() { return gulp.src('./fonts.list') - .pipe(googleWebFonts(fontOptions)) - .pipe(gulp.dest(`${dest }/fonts`)) - ; + .pipe(googleWebFonts(fontOptions)) + .pipe(gulp.dest(`${dest }/fonts`)) + ; }); -gulp.task('default', ['appJS', 'vendor', 'customMUI', 'fonts']); +gulp.task('migrate', function() { + return gulp.src(['./app/css/weather.css']) + .pipe(gulp.dest(`${dest}/css`)); +}); + + + +gulp.task('default', ['appJS', 'vendor', 'customMUI', 'fonts', 'migrate']); diff --git a/lib/newdata.json b/lib/newdata.json deleted file mode 100644 index c0ab61d..0000000 --- a/lib/newdata.json +++ /dev/null @@ -1 +0,0 @@ -{"last":1503061135132,"data":{"trains":{"last":"2017-08-18T12:53:39.051Z","data":[]},"weather":{"currently":"Mostly Cloudy. Around 11 to 15 degrees.","today":"Light rain throughout the day.","later":"Light rain throughout the week, with temperatures rising to 20°C on Tuesday.","alerts":{},"data":{"latitude":55.95,"longitude":-4.566667,"timezone":"Europe/London","offset":1,"currently":{"time":1503060818,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","nearestStormDistance":0,"precipIntensity":0.0914,"precipIntensityError":0.0508,"precipProbability":0.04,"precipType":"rain","temperature":13.99,"apparentTemperature":13.99,"dewPoint":10.13,"humidity":0.78,"windSpeed":13.21,"windGust":20.83,"windBearing":242,"visibility":10,"cloudCover":0.93,"pressure":1001.61,"ozone":356.49,"uvIndex":2},"minutely":{"summary":"Light rain starting in 30 min.","icon":"rain","data":[{"time":1503060780,"precipIntensity":0.0762,"precipIntensityError":0.0508,"precipProbability":0.02,"precipType":"rain"},{"time":1503060840,"precipIntensity":0.1016,"precipIntensityError":0.0508,"precipProbability":0.05,"precipType":"rain"},{"time":1503060900,"precipIntensity":0.127,"precipIntensityError":0.0762,"precipProbability":0.1,"precipType":"rain"},{"time":1503060960,"precipIntensity":0.127,"precipIntensityError":0.0762,"precipProbability":0.13,"precipType":"rain"},{"time":1503061020,"precipIntensity":0.1524,"precipIntensityError":0.1016,"precipProbability":0.19,"precipType":"rain"},{"time":1503061080,"precipIntensity":0.1778,"precipIntensityError":0.1016,"precipProbability":0.27,"precipType":"rain"},{"time":1503061140,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.36,"precipType":"rain"},{"time":1503061200,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.41,"precipType":"rain"},{"time":1503061260,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.41,"precipType":"rain"},{"time":1503061320,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.41,"precipType":"rain"},{"time":1503061380,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.4,"precipType":"rain"},{"time":1503061440,"precipIntensity":0.2032,"precipIntensityError":0.127,"precipProbability":0.36,"precipType":"rain"},{"time":1503061500,"precipIntensity":0.2286,"precipIntensityError":0.127,"precipProbability":0.39,"precipType":"rain"},{"time":1503061560,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.4,"precipType":"rain"},{"time":1503061620,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.38,"precipType":"rain"},{"time":1503061680,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.38,"precipType":"rain"},{"time":1503061740,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.39,"precipType":"rain"},{"time":1503061800,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.38,"precipType":"rain"},{"time":1503061860,"precipIntensity":0.2286,"precipIntensityError":0.1524,"precipProbability":0.38,"precipType":"rain"},{"time":1503061920,"precipIntensity":0.2032,"precipIntensityError":0.1524,"precipProbability":0.32,"precipType":"rain"},{"time":1503061980,"precipIntensity":0.2032,"precipIntensityError":0.1778,"precipProbability":0.3,"precipType":"rain"},{"time":1503062040,"precipIntensity":0.2032,"precipIntensityError":0.1524,"precipProbability":0.28,"precipType":"rain"},{"time":1503062100,"precipIntensity":0.1778,"precipIntensityError":0.1524,"precipProbability":0.24,"precipType":"rain"},{"time":1503062160,"precipIntensity":0.1778,"precipIntensityError":0.1778,"precipProbability":0.22,"precipType":"rain"},{"time":1503062220,"precipIntensity":0.2032,"precipIntensityError":0.3048,"precipProbability":0.23,"precipType":"rain"},{"time":1503062280,"precipIntensity":0.2032,"precipIntensityError":0.254,"precipProbability":0.22,"precipType":"rain"},{"time":1503062340,"precipIntensity":0.2286,"precipIntensityError":0.3556,"precipProbability":0.24,"precipType":"rain"},{"time":1503062400,"precipIntensity":0.2794,"precipIntensityError":0.4572,"precipProbability":0.24,"precipType":"rain"},{"time":1503062460,"precipIntensity":0.3556,"precipIntensityError":0.508,"precipProbability":0.25,"precipType":"rain"},{"time":1503062520,"precipIntensity":0.4318,"precipIntensityError":0.635,"precipProbability":0.26,"precipType":"rain"},{"time":1503062580,"precipIntensity":0.5588,"precipIntensityError":0.7366,"precipProbability":0.27,"precipType":"rain"},{"time":1503062640,"precipIntensity":0.6096,"precipIntensityError":0.8128,"precipProbability":0.3,"precipType":"rain"},{"time":1503062700,"precipIntensity":0.7366,"precipIntensityError":0.889,"precipProbability":0.32,"precipType":"rain"},{"time":1503062760,"precipIntensity":0.8382,"precipIntensityError":0.9398,"precipProbability":0.35,"precipType":"rain"},{"time":1503062820,"precipIntensity":0.9144,"precipIntensityError":0.9652,"precipProbability":0.38,"precipType":"rain"},{"time":1503062880,"precipIntensity":0.9906,"precipIntensityError":1.0414,"precipProbability":0.43,"precipType":"rain"},{"time":1503062940,"precipIntensity":1.0414,"precipIntensityError":1.0668,"precipProbability":0.45,"precipType":"rain"},{"time":1503063000,"precipIntensity":1.0668,"precipIntensityError":1.0668,"precipProbability":0.49,"precipType":"rain"},{"time":1503063060,"precipIntensity":1.1176,"precipIntensityError":1.1176,"precipProbability":0.53,"precipType":"rain"},{"time":1503063120,"precipIntensity":1.143,"precipIntensityError":1.0922,"precipProbability":0.56,"precipType":"rain"},{"time":1503063180,"precipIntensity":1.1176,"precipIntensityError":1.0668,"precipProbability":0.58,"precipType":"rain"},{"time":1503063240,"precipIntensity":1.1176,"precipIntensityError":1.0668,"precipProbability":0.61,"precipType":"rain"},{"time":1503063300,"precipIntensity":1.1176,"precipIntensityError":1.0922,"precipProbability":0.63,"precipType":"rain"},{"time":1503063360,"precipIntensity":1.1176,"precipIntensityError":1.0668,"precipProbability":0.66,"precipType":"rain"},{"time":1503063420,"precipIntensity":1.0922,"precipIntensityError":1.0414,"precipProbability":0.67,"precipType":"rain"},{"time":1503063480,"precipIntensity":1.0922,"precipIntensityError":1.0414,"precipProbability":0.67,"precipType":"rain"},{"time":1503063540,"precipIntensity":1.0668,"precipIntensityError":1.016,"precipProbability":0.67,"precipType":"rain"},{"time":1503063600,"precipIntensity":1.0414,"precipIntensityError":0.9906,"precipProbability":0.69,"precipType":"rain"},{"time":1503063660,"precipIntensity":0.9906,"precipIntensityError":0.9652,"precipProbability":0.69,"precipType":"rain"},{"time":1503063720,"precipIntensity":1.016,"precipIntensityError":0.9652,"precipProbability":0.68,"precipType":"rain"},{"time":1503063780,"precipIntensity":0.9906,"precipIntensityError":0.9398,"precipProbability":0.67,"precipType":"rain"},{"time":1503063840,"precipIntensity":0.9398,"precipIntensityError":0.9144,"precipProbability":0.66,"precipType":"rain"},{"time":1503063900,"precipIntensity":0.9398,"precipIntensityError":0.9144,"precipProbability":0.65,"precipType":"rain"},{"time":1503063960,"precipIntensity":0.9398,"precipIntensityError":0.9144,"precipProbability":0.63,"precipType":"rain"},{"time":1503064020,"precipIntensity":0.9398,"precipIntensityError":0.9144,"precipProbability":0.61,"precipType":"rain"},{"time":1503064080,"precipIntensity":0.9398,"precipIntensityError":0.9144,"precipProbability":0.59,"precipType":"rain"},{"time":1503064140,"precipIntensity":0.9652,"precipIntensityError":0.9144,"precipProbability":0.58,"precipType":"rain"},{"time":1503064200,"precipIntensity":0.9652,"precipIntensityError":0.9144,"precipProbability":0.56,"precipType":"rain"},{"time":1503064260,"precipIntensity":0.9906,"precipIntensityError":0.9144,"precipProbability":0.55,"precipType":"rain"},{"time":1503064320,"precipIntensity":1.016,"precipIntensityError":0.9398,"precipProbability":0.52,"precipType":"rain"},{"time":1503064380,"precipIntensity":1.016,"precipIntensityError":0.9652,"precipProbability":0.5,"precipType":"rain"}]},"hourly":{"summary":"Light rain until tonight, starting again tomorrow morning.","icon":"rain","data":[{"time":1503057600,"summary":"Light Rain","icon":"rain","precipIntensity":0.2591,"precipProbability":0.26,"precipType":"rain","temperature":13.83,"apparentTemperature":13.83,"dewPoint":10.84,"humidity":0.82,"windSpeed":13.15,"windGust":20.99,"windBearing":243,"visibility":10,"cloudCover":0.32,"pressure":1001.69,"ozone":358.5,"uvIndex":3},{"time":1503061200,"summary":"Light Rain","icon":"rain","precipIntensity":0.3251,"precipProbability":0.31,"precipType":"rain","temperature":13.99,"apparentTemperature":13.99,"dewPoint":10.03,"humidity":0.77,"windSpeed":13.21,"windGust":20.81,"windBearing":242,"visibility":10,"cloudCover":1,"pressure":1001.61,"ozone":356.25,"uvIndex":2},{"time":1503064800,"summary":"Light Rain","icon":"rain","precipIntensity":0.635,"precipProbability":0.34,"precipType":"rain","temperature":14.31,"apparentTemperature":14.31,"dewPoint":10.07,"humidity":0.76,"windSpeed":12.35,"windGust":19.79,"windBearing":239,"visibility":10,"cloudCover":1,"pressure":1001.42,"ozone":353.52,"uvIndex":2},{"time":1503068400,"summary":"Light Rain","icon":"rain","precipIntensity":0.3861,"precipProbability":0.35,"precipType":"rain","temperature":15.02,"apparentTemperature":15.02,"dewPoint":10.17,"humidity":0.73,"windSpeed":11.42,"windGust":19,"windBearing":238,"visibility":10,"cloudCover":1,"pressure":1001.29,"ozone":351.44,"uvIndex":1},{"time":1503072000,"summary":"Light Rain","icon":"rain","precipIntensity":0.3429,"precipProbability":0.33,"precipType":"rain","temperature":15.69,"apparentTemperature":15.69,"dewPoint":10.42,"humidity":0.71,"windSpeed":10.24,"windGust":18.38,"windBearing":244,"visibility":10,"cloudCover":1,"pressure":1001.19,"ozone":350.76,"uvIndex":1},{"time":1503075600,"summary":"Light Rain","icon":"rain","precipIntensity":0.2819,"precipProbability":0.29,"precipType":"rain","temperature":15.81,"apparentTemperature":15.81,"dewPoint":10.74,"humidity":0.72,"windSpeed":8.93,"windGust":17.98,"windBearing":252,"visibility":10,"cloudCover":1,"pressure":1001.13,"ozone":350.79,"uvIndex":0},{"time":1503079200,"summary":"Light Rain","icon":"rain","precipIntensity":0.2388,"precipProbability":0.26,"precipType":"rain","temperature":15.37,"apparentTemperature":15.37,"dewPoint":10.93,"humidity":0.75,"windSpeed":8.36,"windGust":18.46,"windBearing":238,"visibility":10,"cloudCover":1,"pressure":1001.3,"ozone":350.68,"uvIndex":0},{"time":1503082800,"summary":"Drizzle","icon":"rain","precipIntensity":0.2159,"precipProbability":0.23,"precipType":"rain","temperature":14.64,"apparentTemperature":14.64,"dewPoint":10.93,"humidity":0.78,"windSpeed":7.7,"windGust":20.49,"windBearing":179,"visibility":10,"cloudCover":0.9,"pressure":1001.82,"ozone":350.2,"uvIndex":0},{"time":1503086400,"summary":"Drizzle","icon":"rain","precipIntensity":0.2007,"precipProbability":0.2,"precipType":"rain","temperature":13.98,"apparentTemperature":13.98,"dewPoint":10.83,"humidity":0.81,"windSpeed":8.41,"windGust":23.41,"windBearing":343,"visibility":10,"cloudCover":0.77,"pressure":1002.56,"ozone":349.68,"uvIndex":0},{"time":1503090000,"summary":"Drizzle","icon":"rain","precipIntensity":0.1854,"precipProbability":0.18,"precipType":"rain","temperature":13.6,"apparentTemperature":13.6,"dewPoint":10.65,"humidity":0.82,"windSpeed":10.57,"windGust":25.67,"windBearing":274,"visibility":10,"cloudCover":0.68,"pressure":1003.26,"ozone":348.87,"uvIndex":0},{"time":1503093600,"summary":"Drizzle","icon":"rain","precipIntensity":0.1422,"precipProbability":0.11,"precipType":"rain","temperature":13.39,"apparentTemperature":13.39,"dewPoint":10.31,"humidity":0.82,"windSpeed":8.75,"windGust":26.63,"windBearing":223,"visibility":10,"cloudCover":0.66,"pressure":1003.86,"ozone":347.63,"uvIndex":0},{"time":1503097200,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.094,"precipProbability":0.05,"precipType":"rain","temperature":13.16,"apparentTemperature":13.16,"dewPoint":9.81,"humidity":0.8,"windSpeed":11.25,"windGust":26.98,"windBearing":301,"visibility":10,"cloudCover":0.67,"pressure":1004.42,"ozone":346.12,"uvIndex":0},{"time":1503100800,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.0686,"precipProbability":0.03,"precipType":"rain","temperature":12.77,"apparentTemperature":12.77,"dewPoint":9.39,"humidity":0.8,"windSpeed":13.21,"windGust":27.07,"windBearing":277,"visibility":10,"cloudCover":0.71,"pressure":1004.91,"ozone":345.09,"uvIndex":0},{"time":1503104400,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.061,"precipProbability":0.02,"precipType":"rain","temperature":12.39,"apparentTemperature":12.39,"dewPoint":9.15,"humidity":0.81,"windSpeed":12.66,"windGust":26.95,"windBearing":356,"visibility":10,"cloudCover":0.78,"pressure":1005.37,"ozone":344.85,"uvIndex":0},{"time":1503108000,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.061,"precipProbability":0.02,"precipType":"rain","temperature":12.07,"apparentTemperature":12.07,"dewPoint":8.99,"humidity":0.81,"windSpeed":11.32,"windGust":26.61,"windBearing":173,"visibility":10,"cloudCover":0.87,"pressure":1005.74,"ozone":344.99,"uvIndex":0},{"time":1503111600,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.061,"precipProbability":0.02,"precipType":"rain","temperature":11.91,"apparentTemperature":11.91,"dewPoint":8.86,"humidity":0.82,"windSpeed":12.76,"windGust":26.38,"windBearing":266,"visibility":10,"cloudCover":0.91,"pressure":1006.05,"ozone":345.1,"uvIndex":0},{"time":1503115200,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.0457,"precipProbability":0.01,"precipType":"rain","temperature":11.72,"apparentTemperature":11.72,"dewPoint":8.67,"humidity":0.82,"windSpeed":12.59,"windGust":26.39,"windBearing":270,"visibility":10,"cloudCover":0.86,"pressure":1006.25,"ozone":344.89,"uvIndex":0},{"time":1503118800,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":11.56,"apparentTemperature":11.56,"dewPoint":8.51,"humidity":0.82,"windSpeed":12.43,"windGust":26.51,"windBearing":270,"visibility":10,"cloudCover":0.75,"pressure":1006.38,"ozone":344.54,"uvIndex":0},{"time":1503122400,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":11.62,"apparentTemperature":11.62,"dewPoint":8.52,"humidity":0.81,"windSpeed":12.66,"windGust":26.78,"windBearing":266,"visibility":10,"cloudCover":0.67,"pressure":1006.57,"ozone":344.55,"uvIndex":0},{"time":1503126000,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0.0483,"precipProbability":0.01,"precipType":"rain","temperature":12.32,"apparentTemperature":12.32,"dewPoint":8.87,"humidity":0.79,"windSpeed":9.53,"windGust":27.16,"windBearing":173,"visibility":10,"cloudCover":0.64,"pressure":1006.79,"ozone":345.07,"uvIndex":0},{"time":1503129600,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0.1041,"precipProbability":0.05,"precipType":"rain","temperature":13.29,"apparentTemperature":13.29,"dewPoint":9.38,"humidity":0.77,"windSpeed":12.76,"windGust":27.7,"windBearing":330,"visibility":10,"cloudCover":0.63,"pressure":1007.07,"ozone":345.86,"uvIndex":1},{"time":1503133200,"summary":"Drizzle","icon":"rain","precipIntensity":0.1702,"precipProbability":0.12,"precipType":"rain","temperature":14.13,"apparentTemperature":14.13,"dewPoint":9.82,"humidity":0.75,"windSpeed":15.75,"windGust":28.51,"windBearing":271,"visibility":10,"cloudCover":0.63,"pressure":1007.38,"ozone":346.6,"uvIndex":1},{"time":1503136800,"summary":"Drizzle","icon":"rain","precipIntensity":0.2007,"precipProbability":0.15,"precipType":"rain","temperature":14.53,"apparentTemperature":14.53,"dewPoint":10.02,"humidity":0.74,"windSpeed":13.91,"windGust":30.01,"windBearing":343,"visibility":10,"cloudCover":0.65,"pressure":1007.7,"ozone":347,"uvIndex":2},{"time":1503140400,"summary":"Drizzle","icon":"rain","precipIntensity":0.2083,"precipProbability":0.16,"precipType":"rain","temperature":14.49,"apparentTemperature":14.49,"dewPoint":10.15,"humidity":0.75,"windSpeed":13.76,"windGust":31.78,"windBearing":196,"visibility":10,"cloudCover":0.69,"pressure":1008.05,"ozone":347.28,"uvIndex":2},{"time":1503144000,"summary":"Drizzle","icon":"rain","precipIntensity":0.221,"precipProbability":0.17,"precipType":"rain","temperature":14.26,"apparentTemperature":14.26,"dewPoint":10.32,"humidity":0.77,"windSpeed":16.89,"windGust":32.61,"windBearing":265,"visibility":10,"cloudCover":0.73,"pressure":1008.51,"ozone":347.82,"uvIndex":2},{"time":1503147600,"summary":"Light Rain","icon":"rain","precipIntensity":0.2565,"precipProbability":0.19,"precipType":"rain","temperature":14.22,"apparentTemperature":14.22,"dewPoint":10.62,"humidity":0.79,"windSpeed":13.46,"windGust":31.8,"windBearing":185,"visibility":10,"cloudCover":0.8,"pressure":1009.13,"ozone":349.08,"uvIndex":2},{"time":1503151200,"summary":"Light Rain","icon":"rain","precipIntensity":0.2972,"precipProbability":0.19,"precipType":"rain","temperature":14.59,"apparentTemperature":14.59,"dewPoint":10.97,"humidity":0.79,"windSpeed":14.95,"windGust":30.02,"windBearing":14,"visibility":10,"cloudCover":0.87,"pressure":1009.84,"ozone":350.53,"uvIndex":2},{"time":1503154800,"summary":"Light Rain","icon":"rain","precipIntensity":0.3023,"precipProbability":0.19,"precipType":"rain","temperature":15.31,"apparentTemperature":15.31,"dewPoint":11.23,"humidity":0.77,"windSpeed":15.71,"windGust":28.27,"windBearing":274,"visibility":10,"cloudCover":0.92,"pressure":1010.51,"ozone":351.34,"uvIndex":1},{"time":1503158400,"summary":"Light Rain","icon":"rain","precipIntensity":0.2464,"precipProbability":0.17,"precipType":"rain","temperature":15.84,"apparentTemperature":15.84,"dewPoint":11.29,"humidity":0.74,"windSpeed":13.61,"windGust":26.64,"windBearing":280,"visibility":10,"cloudCover":0.94,"pressure":1011.05,"ozone":350.87,"uvIndex":1},{"time":1503162000,"summary":"Drizzle","icon":"rain","precipIntensity":0.1651,"precipProbability":0.1,"precipType":"rain","temperature":15.85,"apparentTemperature":15.85,"dewPoint":11.25,"humidity":0.74,"windSpeed":9.74,"windGust":25.02,"windBearing":264,"visibility":10,"cloudCover":0.93,"pressure":1011.58,"ozone":349.71,"uvIndex":0},{"time":1503165600,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0.1092,"precipProbability":0.05,"precipType":"rain","temperature":15.37,"apparentTemperature":15.37,"dewPoint":11.14,"humidity":0.76,"windSpeed":13.15,"windGust":23.91,"windBearing":274,"visibility":10,"cloudCover":0.88,"pressure":1012.14,"ozone":348.33,"uvIndex":0},{"time":1503169200,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0.0737,"precipProbability":0.02,"precipType":"rain","temperature":14.67,"apparentTemperature":14.67,"dewPoint":10.97,"humidity":0.79,"windSpeed":10.53,"windGust":23.77,"windBearing":312,"visibility":10,"cloudCover":0.79,"pressure":1012.81,"ozone":347.01,"uvIndex":0},{"time":1503172800,"summary":"Mostly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.0508,"precipProbability":0.01,"precipType":"rain","temperature":14.04,"apparentTemperature":14.04,"dewPoint":10.73,"humidity":0.8,"windSpeed":9.6,"windGust":24.17,"windBearing":238,"visibility":10,"cloudCover":0.66,"pressure":1013.55,"ozone":345.48,"uvIndex":0},{"time":1503176400,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0.0381,"precipProbability":0.01,"precipType":"rain","temperature":13.71,"apparentTemperature":13.71,"dewPoint":10.52,"humidity":0.81,"windSpeed":10.4,"windGust":24.03,"windBearing":277,"visibility":10,"cloudCover":0.57,"pressure":1014.18,"ozone":343.43,"uvIndex":0},{"time":1503180000,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":13.68,"apparentTemperature":13.68,"dewPoint":10.39,"humidity":0.81,"windSpeed":9.59,"windGust":22.9,"windBearing":279,"visibility":10,"cloudCover":0.52,"pressure":1014.66,"ozone":340.81,"uvIndex":0},{"time":1503183600,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":13.61,"apparentTemperature":13.61,"dewPoint":10.32,"humidity":0.81,"windSpeed":8.83,"windGust":21.29,"windBearing":278,"visibility":10,"cloudCover":0.51,"pressure":1015.01,"ozone":337.75,"uvIndex":0},{"time":1503187200,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":13.39,"apparentTemperature":13.39,"dewPoint":10.21,"humidity":0.81,"windSpeed":8.16,"windGust":19.36,"windBearing":274,"visibility":10,"cloudCover":0.48,"pressure":1015.39,"ozone":334.54,"uvIndex":0},{"time":1503190800,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":13.06,"apparentTemperature":13.06,"dewPoint":10.07,"humidity":0.82,"windSpeed":7.69,"windGust":17.08,"windBearing":271,"visibility":10,"cloudCover":0.4,"pressure":1015.78,"ozone":330.85,"uvIndex":0},{"time":1503194400,"summary":"Partly Cloudy","icon":"partly-cloudy-night","precipIntensity":0,"precipProbability":0,"temperature":12.79,"apparentTemperature":12.79,"dewPoint":9.91,"humidity":0.83,"windSpeed":7.38,"windGust":14.48,"windBearing":270,"visibility":10,"cloudCover":0.3,"pressure":1016.16,"ozone":327.15,"uvIndex":0},{"time":1503198000,"summary":"Clear","icon":"clear-night","precipIntensity":0,"precipProbability":0,"temperature":12.77,"apparentTemperature":12.77,"dewPoint":9.78,"humidity":0.82,"windSpeed":7.02,"windGust":12.24,"windBearing":272,"visibility":10,"cloudCover":0.23,"pressure":1016.52,"ozone":324.16,"uvIndex":0},{"time":1503201600,"summary":"Clear","icon":"clear-night","precipIntensity":0,"precipProbability":0,"temperature":12.71,"apparentTemperature":12.71,"dewPoint":9.68,"humidity":0.82,"windSpeed":6.02,"windGust":10.54,"windBearing":314,"visibility":10,"cloudCover":0.21,"pressure":1016.91,"ozone":322.53,"uvIndex":0},{"time":1503205200,"summary":"Clear","icon":"clear-night","precipIntensity":0,"precipProbability":0,"temperature":12.48,"apparentTemperature":12.48,"dewPoint":9.58,"humidity":0.82,"windSpeed":5.6,"windGust":9.2,"windBearing":229,"visibility":10,"cloudCover":0.23,"pressure":1017.33,"ozone":321.73,"uvIndex":0},{"time":1503208800,"summary":"Partly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":12.52,"apparentTemperature":12.52,"dewPoint":9.65,"humidity":0.83,"windSpeed":5.45,"windGust":8.25,"windBearing":264,"visibility":10,"cloudCover":0.3,"pressure":1017.75,"ozone":321.32,"uvIndex":0},{"time":1503212400,"summary":"Partly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":13.24,"apparentTemperature":13.24,"dewPoint":10.02,"humidity":0.81,"windSpeed":4.73,"windGust":7.86,"windBearing":240,"visibility":10,"cloudCover":0.49,"pressure":1018.2,"ozone":321.36,"uvIndex":0},{"time":1503216000,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":14.43,"apparentTemperature":14.43,"dewPoint":10.56,"humidity":0.78,"windSpeed":4.82,"windGust":7.83,"windBearing":298,"visibility":10,"cloudCover":0.73,"pressure":1018.67,"ozone":321.88,"uvIndex":1},{"time":1503219600,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":15.62,"apparentTemperature":15.62,"dewPoint":10.93,"humidity":0.74,"windSpeed":5.21,"windGust":7.71,"windBearing":274,"visibility":10,"cloudCover":0.92,"pressure":1019.05,"ozone":322.35,"uvIndex":1},{"time":1503223200,"summary":"Overcast","icon":"cloudy","precipIntensity":0,"precipProbability":0,"temperature":16.52,"apparentTemperature":16.52,"dewPoint":10.98,"humidity":0.7,"windSpeed":5.04,"windGust":7.17,"windBearing":307,"visibility":10,"cloudCover":0.96,"pressure":1019.29,"ozone":322.95,"uvIndex":1},{"time":1503226800,"summary":"Overcast","icon":"cloudy","precipIntensity":0,"precipProbability":0,"temperature":17.15,"apparentTemperature":17.15,"dewPoint":10.87,"humidity":0.67,"windSpeed":4.98,"windGust":6.54,"windBearing":215,"visibility":10,"cloudCover":0.95,"pressure":1019.43,"ozone":323.52,"uvIndex":2},{"time":1503230400,"summary":"Mostly Cloudy","icon":"partly-cloudy-day","precipIntensity":0,"precipProbability":0,"temperature":17.43,"apparentTemperature":17.43,"dewPoint":10.81,"humidity":0.65,"windSpeed":5.38,"windGust":6.08,"windBearing":260,"visibility":10,"cloudCover":0.93,"pressure":1019.55,"ozone":323.6,"uvIndex":2}]},"daily":{"summary":"Light rain throughout the week, with temperatures rising to 20°C on Tuesday.","icon":"rain","data":[{"time":1503010800,"summary":"Light rain throughout the day.","icon":"rain","sunriseTime":1503032212,"sunsetTime":1503085814,"moonPhase":0.88,"precipIntensity":0.4115,"precipIntensityMax":1.11,"precipIntensityMaxTime":1503021600,"precipProbability":0.57,"precipType":"rain","temperatureMin":11.45,"temperatureMinTime":1503036000,"temperatureMax":15.81,"temperatureMaxTime":1503075600,"apparentTemperatureMin":11.45,"apparentTemperatureMinTime":1503036000,"apparentTemperatureMax":15.81,"apparentTemperatureMaxTime":1503075600,"dewPoint":10.95,"humidity":0.84,"windSpeed":7.4,"windGust":26.63,"windGustTime":1503093600,"windBearing":241,"visibility":10,"cloudCover":0.64,"pressure":1001.21,"ozone":354.84,"uvIndex":3,"uvIndexTime":1503054000},{"time":1503097200,"summary":"Light rain until evening.","icon":"rain","sunriseTime":1503118730,"sunsetTime":1503172070,"moonPhase":0.92,"precipIntensity":0.1245,"precipIntensityMax":0.3023,"precipIntensityMaxTime":1503154800,"precipProbability":0.19,"precipType":"rain","temperatureMin":11.56,"temperatureMinTime":1503118800,"temperatureMax":15.85,"temperatureMaxTime":1503162000,"apparentTemperatureMin":11.56,"apparentTemperatureMinTime":1503118800,"apparentTemperatureMax":15.85,"apparentTemperatureMaxTime":1503162000,"dewPoint":9.98,"humidity":0.79,"windSpeed":8.5,"windGust":32.61,"windGustTime":1503144000,"windBearing":275,"visibility":10,"cloudCover":0.75,"pressure":1008.78,"ozone":346.51,"uvIndex":2,"uvIndexTime":1503136800},{"time":1503183600,"summary":"Mostly cloudy throughout the day.","icon":"partly-cloudy-day","sunriseTime":1503205248,"sunsetTime":1503258325,"moonPhase":0.96,"precipIntensity":0,"precipIntensityMax":0,"precipProbability":0,"temperatureMin":12.48,"temperatureMinTime":1503205200,"temperatureMax":18.75,"temperatureMaxTime":1503244800,"apparentTemperatureMin":12.48,"apparentTemperatureMinTime":1503205200,"apparentTemperatureMax":18.75,"apparentTemperatureMaxTime":1503244800,"dewPoint":10.38,"humidity":0.74,"windSpeed":4.62,"windGust":21.29,"windGustTime":1503183600,"windBearing":257,"visibility":10,"cloudCover":0.62,"pressure":1018.47,"ozone":323.02,"uvIndex":2,"uvIndexTime":1503226800},{"time":1503270000,"summary":"Rain starting in the afternoon.","icon":"rain","sunriseTime":1503291766,"sunsetTime":1503344579,"moonPhase":0.99,"precipIntensity":0.5994,"precipIntensityMax":2.4028,"precipIntensityMaxTime":1503327600,"precipProbability":0.37,"precipType":"rain","temperatureMin":12.1,"temperatureMinTime":1503295200,"temperatureMax":18.09,"temperatureMaxTime":1503334800,"apparentTemperatureMin":12.1,"apparentTemperatureMinTime":1503295200,"apparentTemperatureMax":18.09,"apparentTemperatureMaxTime":1503334800,"dewPoint":11.42,"humidity":0.79,"windSpeed":4.06,"windGust":13.21,"windGustTime":1503316800,"windBearing":91,"visibility":10,"cloudCover":0.94,"pressure":1018.14,"ozone":306.33,"uvIndex":2,"uvIndexTime":1503309600},{"time":1503356400,"summary":"Light rain throughout the day.","icon":"rain","sunriseTime":1503378284,"sunsetTime":1503430832,"moonPhase":0.03,"precipIntensity":0.7772,"precipIntensityMax":1.4249,"precipIntensityMaxTime":1503360000,"precipProbability":0.36,"precipType":"rain","temperatureMin":15.86,"temperatureMinTime":1503381600,"temperatureMax":19.56,"temperatureMaxTime":1503417600,"apparentTemperatureMin":15.86,"apparentTemperatureMinTime":1503381600,"apparentTemperatureMax":19.61,"apparentTemperatureMaxTime":1503417600,"dewPoint":14.93,"humidity":0.85,"windSpeed":6.16,"windGust":24.53,"windGustTime":1503374400,"windBearing":136,"visibility":9.36,"cloudCover":0.99,"pressure":1014.28,"ozone":310.73,"uvIndex":2,"uvIndexTime":1503399600},{"time":1503442800,"summary":"Rain until afternoon, starting again overnight.","icon":"rain","sunriseTime":1503464801,"sunsetTime":1503517084,"moonPhase":0.06,"precipIntensity":0.3226,"precipIntensityMax":1.3945,"precipIntensityMaxTime":1503457200,"precipProbability":0.22,"precipType":"rain","temperatureMin":14.76,"temperatureMinTime":1503522000,"temperatureMax":18.52,"temperatureMaxTime":1503504000,"apparentTemperatureMin":14.76,"apparentTemperatureMinTime":1503522000,"apparentTemperatureMax":18.52,"apparentTemperatureMaxTime":1503504000,"dewPoint":13.23,"humidity":0.79,"windSpeed":6.77,"windGust":15.71,"windGustTime":1503507600,"windBearing":179,"cloudCover":0.34,"pressure":1010.93,"ozone":320.4,"uvIndex":4,"uvIndexTime":1503489600},{"time":1503529200,"summary":"Drizzle starting in the afternoon, continuing until evening.","icon":"rain","sunriseTime":1503551319,"sunsetTime":1503603335,"moonPhase":0.1,"precipIntensity":0.1041,"precipIntensityMax":0.2159,"precipIntensityMaxTime":1503532800,"precipProbability":0.35,"precipType":"rain","temperatureMin":13.95,"temperatureMinTime":1503550800,"temperatureMax":18.83,"temperatureMaxTime":1503590400,"apparentTemperatureMin":13.95,"apparentTemperatureMinTime":1503550800,"apparentTemperatureMax":18.83,"apparentTemperatureMaxTime":1503590400,"dewPoint":12.09,"humidity":0.79,"windSpeed":5.59,"windGust":18.45,"windGustTime":1503579600,"windBearing":204,"cloudCover":0.56,"pressure":1010.72,"ozone":314.45,"uvIndex":2,"uvIndexTime":1503568800},{"time":1503615600,"summary":"Light rain until afternoon, starting again in the evening.","icon":"rain","sunriseTime":1503637837,"sunsetTime":1503689585,"moonPhase":0.13,"precipIntensity":0.3581,"precipIntensityMax":1.0058,"precipIntensityMaxTime":1503651600,"precipProbability":0.44,"precipType":"rain","temperatureMin":13.84,"temperatureMinTime":1503637200,"temperatureMax":18.67,"temperatureMaxTime":1503676800,"apparentTemperatureMin":13.84,"apparentTemperatureMinTime":1503637200,"apparentTemperatureMax":18.67,"apparentTemperatureMaxTime":1503676800,"dewPoint":11.84,"humidity":0.78,"windSpeed":5.88,"windGust":14.94,"windGustTime":1503615600,"windBearing":175,"cloudCover":0.73,"pressure":1010.52,"ozone":312.65,"uvIndex":2,"uvIndexTime":1503658800}]},"flags":{"sources":["datapoint","isd","nearest-precip","cmc","gfs","madis","darksky"],"datapoint-stations":["uk-301777","uk-3134","uk-322052","uk-322595","uk-322659","uk-350056","uk-351269","uk-351289","uk-351397","uk-351465","uk-352102","uk-352379","uk-352954","uk-354999","uk-371524","uk-371606"],"isd-stations":["031070-99999","031160-99999","031200-99999","031290-99999","031330-99999","031340-99999","031350-99999","031360-99999","031380-99999","031390-99999","031400-99999","031430-99999","031450-99999","031480-99999","031490-99999","031520-99999"],"units":"uk2"}}},"history":["On 18 August 1864 Scottish suffragette, Elsie Inglis, was born at Naini Tal hill station in India. Inglis was a rare female medical graduate battling prejudice all the way, and founded a maternity hospital in Edinburgh, affectionately known as \"Elsie's\".","However, she was not only a reformer in the field of medecine, as, in 1906, she founded the Scottish Women's Suffrage Federation. During the First World War this Suffragette Federation organised medical teams to go to France, Serbia and Salonica as well as Russia. Inglis went to Serbia herself, where her efforts to improve hygiene reduced the typhus and other epidemics which had been raging there. In 1915 she was captured and then repatriated, but returned to work in Russia.","The climate and long hours she imposed on herself led to a break down in her health and she was forced to return home to recuperate, unfortunately she was to die the day after landing at Newcastle. However \"Elsie's\" stayed open as a hospital until 1988.","On 18 August 1746 Arthur Elphinstone, Lord Balmerino, the Jacobite noble, was executed. Balmerino was captured along with Lord Kilmarnock after the Battle of Culloden and the pair were tried for treason in London and beheaded in the Tower of London.","Earl Kilmarnock was especially unfortunate as he was executed due to the mistaken belief by the Duke of Cumberland that Kilmarnock had issued the order that no quarter be given to the English at Culloden. Kilmarnock had only sided with the Jacobites as he was facing bankruptcy and had been promised French gold for his support, he admitted this at his trial, pleading that, for the two kings and their rights, I cared not a farthing which prevailed; but I was starving....."],"today":"Friday August 18, 2017 - The 229th day of 2017, and there are 135 days until the end of the year","tv":{"entries":[]},"cal":{"today":[{"summary":"Update Timesheet","dtstart":"2017-08-18T14:30:00.064Z","dtend":"2017-08-18T15:30:00.064Z","description":"Update the timesheet using https://outsauce.backofficeportal.co","timeStart":"15:30:00","timeEnd":"16:30:00","duration":"1 hour","combined":"15:30:00 - 'Update Timesheet, 1 hour","recur":"FREQ=WEEKLY;COUNT=15;BYDAY=FR","long":"Friday, 15:30:00 - ","longcombined":"Friday, 15:30:00 - Update Timesheet, 1 hour"}],"tomorrow":[{"summary":"Film & Comic Con GLASGOW 2017","dtstart":"2017-08-19T08:00:00.000Z","dtend":"2017-08-20T17:00:00.000Z","description":"To see detailed information for automatically created events li","timeStart":"9:00:00","timeEnd":"18:00:00","duration":"1 day","combined":"9:00:00 - 'Film & Comic Con GLASGOW 2017, 1 day","recur":null,"long":"Saturday, 9:00:00 - ","longcombined":"Saturday, 9:00:00 - Film & Comic Con GLASGOW 2017, 1 day"}],"week":[{"summary":"Tony reily birthday","dtstart":"2017-08-20T23:00:00.875Z","dtend":"2017-08-21T23:00:00.875Z","description":"##@@D@@@@@@@@@@@@@@\\n\\n\\n\\n\\n","timeStart":"0:00:00","timeEnd":"0:00:00","duration":"1 day","combined":"0:00:00 - 'Tony reily birthday, 1 day","recur":"FREQ=YEARLY;BYMONTH=8;BYMONTHDAY=21","long":"Monday, 0:00:00 - ","longcombined":"Monday, 0:00:00 - Tony reily birthday, 1 day"}]},"swedish":{"xml":{"$":{"xmlns:wotd":"http://www.transparent.com/word-of-the-day/"},"words":{"date":"08-18-2017","langname":"Swedish","wordtype":"noun","word":"(ett) lik","wordsound":"http://wotd.transparent.com/swedish/level-1/sound/00058_WOTD_Swedish_Words.mp3","translation":"corpse","fnphrase":"Polisen hittade två lik på brottsplatsen.","phrasesound":"http://wotd.transparent.com/swedish/level-1/sound/00058_WOTD_Swedish_Sentences.mp3","enphrase":"The police found two corpses at the scene of the crime.","wotd:transliteratedWord":"","wotd:transliteratedSentence":"","notes":""}}},"fitbit":{},"ftse":[{"name":"Rentokil Initial Plc","price":"295.50","change_amount":"+3.40","change_percent":"+1.16%"},{"name":"Randgold Resources","price":"7,472.50","change_amount":"+65.00","change_percent":"+0.88%"},{"name":"Mondi Plc","price":"2,079.50","change_amount":"+18.00","change_percent":"+0.87%"},{"name":"RSA Insurance Group","price":"652.25","change_amount":"+2.50","change_percent":"+0.38%"},{"name":"SSE Plc","price":"1,439.50","change_amount":"+3.00","change_percent":"+0.21%"},{"name":"Intertek Group Plc","price":"4,849.00","change_amount":"+2.00","change_percent":"+0.04%"}],"quotes":{"quote":"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' the pig was 'committed'.","author":"unknown","category":"Famous"}},"expire":3600000,"date":{"year":2017,"month":8,"day":18}} diff --git a/lib/today.js b/lib/today.js index a9fd5ff..dc56c8b 100644 --- a/lib/today.js +++ b/lib/today.js @@ -8,8 +8,8 @@ const util = require('util'); const cron = require('node-cron'); const dateFormat = require('dateformat'); const jsonfile = require('jsonfile'); -let fs = require('fs'); -//var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984'); +const fs = require('fs'); +// var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984'); const logger = require('log4js').getLogger(); const calHandler = require('./today/calHandler'); const swedishWord = require('./today/swedishword'); @@ -20,8 +20,10 @@ const mdMailer = require('./today/mailer'); const mdFitbit = require('./today/fitbit'); const todayFTSE = require('./today/todayftse'); const quotes = require('./today/quotes'); -//var db_name = 'silvrgit'; -//var dbCloudant = nano.use(db_name); + +// const Sugar = require('sugar-date'); +// var db_name = 'silvrgit'; +// var dbCloudant = nano.use(db_name); /* @@ -29,153 +31,155 @@ const quotes = require('./today/quotes'); https://25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com/dashboard.html#usage - */ +logger.level = 'debug'; const credentials = { - "username": "25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix", - "password": "8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c", - "host": "25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com", - "port": 443, - "url": "https://25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix:8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c@25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com", - "database": "today" + 'username': '25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix', + 'password': '8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c', + 'host': '25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com', + 'port': 443, + 'url': 'https://25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix:8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c@25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com', + 'database': 'today' }; const Cloudant = require('cloudant'); -const cloudant = Cloudant({account: credentials.username, password: credentials.password}); +const cloudant = Cloudant({ 'account': credentials.username, 'password': credentials.password }); const dbCloudant = cloudant.db.use(credentials.database); - -require('sugar-date'); +let Sugar = require('sugar'); String.prototype.hashCode = function () { - - if (Array.prototype.reduce) { - return this.split('').reduce(function (a, b) { - a = ((a << 5) - a) + b.charCodeAt(0); - return a & a - }, 0); - } else { - - let hash = 0, i, chr, len; - if (this.length === 0) return hash; - for (i = 0, len = this.length; i < len; i++) { - chr = this.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; + if (Array.prototype.reduce) + return this.split('').reduce(function (a, b) { + a = ((a << 5) - a) + b.charCodeAt(0); + + return a & a; + }, 0); + else { + let hash = 0, i, chr, len; + if (this.length === 0) return hash; + for (i = 0, len = this.length; i < len; i++) { + chr = this.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash |= 0; // Convert to 32bit integer } + + return hash; + } }; let todayCache = { - last: 0, data: { - trains: {last: 0, data: []}, - weather: {}, - history: [], - today: '', - tv: {entries: []}, - cal: {today: [], tomorrow: [], week: []}, - swedish: {}, - fitbit: {}, - ftse: {} - }, expire: ((60 * 1000) * 60) + 'last': 0, 'data': { + 'trains': { 'last': 0, 'data': [] }, + 'weather': {}, + 'history': [], + 'today': '', + 'tv': { 'entries': [] }, + 'cal': { 'today': [], 'tomorrow': [], 'week': [] }, + 'swedish': {}, + 'fitbit': {}, + 'ftse': {} + }, 'expire': ((60 * 1000) * 60) }; -const file = __dirname + '/' + 'newdata.json'; -let htmlfile = __dirname + '/' + 'today.html'; +const file = `${__dirname }/` + 'newdata.json'; +const htmlfile = `${__dirname }/` + 'today.html'; let eventEmitter; function runable() { - try { - const now = new Date().getTime(); + try { + const now = new Date().getTime(); - console.log('last updated', ((now - todayCache.last) / 60000)); - if (now - todayCache.last < 3600000) { - return false; - } else { - todayCache.last = now; - return true; - } + console.log('last updated', ((now - todayCache.last) / 60000)); + if (now - todayCache.last < 3600000) + return false; + else { + todayCache.last = now; + + return true; } - catch (e) { - todayCache.last = new Date().getTime(); - return true; - - } - + } + catch (e) { + todayCache.last = new Date().getTime(); + + return true; + } } function broadcastWeather() { - const wData = { - temperature: todayCache.data.weather.data.currently.temperature, - icon: todayCache.data.weather.data.currently.icon, - summary: todayCache.data.weather.data.currently.summary - }; + const wData = { + 'temperature': todayCache.data.weather.data.currently.temperature, + 'icon': todayCache.data.weather.data.currently.icon, + 'summary': todayCache.data.weather.data.currently.summary + }; - if (todayCache.data.weather.data.hasOwnProperty('alerts')) { - wData.alerts = todayCache.data.weather.data.alerts; - } - eventEmitter.emit('sendSocket', {id: 'weather', data: wData}); + if (todayCache.data.weather.data.hasOwnProperty('alerts')) + wData.alerts = todayCache.data.weather.data.alerts; + + eventEmitter.emit('sendSocket', { 'id': 'weather', 'data': wData }); } function loadData() { - console.log('Loading old data'); - try { - todayCache = jsonfile.readFileSync(file); - } - catch (e) { - console.error('Could not load previous data'); - } + console.log('Loading old data'); + try { + todayCache = jsonfile.readFileSync(file); + } + catch (e) { + console.error('Could not load previous data'); + } } function saveData() { - todayCache.last = new Date().getTime(); - logger.info('Saving...'); - jsonfile.writeFileSync(file, todayCache); + todayCache.last = new Date().getTime(); + logger.info('Saving...'); + jsonfile.writeFileSync(file, todayCache); } function saveToDB(data) { - saveData(); + saveData(); - logger.debug('Inserting into couch...'); - // Logger.info(util.inspect(obj)); - dbCloudant.insert(data, function (err, body, header) { - if (err) { - logger.error('Error inserting into couch'); - logger.error(err); - return; - } - }); + logger.debug('Inserting into couch...'); + // Logger.info(util.inspect(obj)); + dbCloudant.insert(data, function (err, body, header) { + if (err) { + logger.error('Error inserting into couch'); + logger.error(err); + + return; + } + }); } function nth(d) { - // If (d > 3 && d < 21) {return 'th';} // Thanks kennebec - // if (d % 10 === 1) {return 'st';} else if (d % 10 === 2) {return 'nd';} else if (d % 10 === 3) {return 'rd';} else {return 'th';} - const n = d; - return Math.floor(n / 10) === 1 ? 'th' : (n % 10 === 1 ? 'st' : (n % 10 === 2 ? 'nd' : (n % 10 === 3 ? 'rd' : 'th'))); + // If (d > 3 && d < 21) {return 'th';} // Thanks kennebec + // if (d % 10 === 1) {return 'st';} else if (d % 10 === 2) {return 'nd';} else if (d % 10 === 3) {return 'rd';} else {return 'th';} + const n = d; + + return Math.floor(n / 10) === 1 ? 'th' : (n % 10 === 1 ? 'st' : (n % 10 === 2 ? 'nd' : (n % 10 === 3 ? 'rd' : 'th'))); } function dayNumber() { - const now = new Date(); - const start = new Date(now.getFullYear(), 0, 0); - const diff = now - start; - const oneDay = 1000 * 60 * 60 * 24; - return Math.floor(diff / oneDay); + const now = new Date(); + const start = new Date(now.getFullYear(), 0, 0); + const diff = now - start; + const oneDay = 1000 * 60 * 60 * 24; + + return Math.floor(diff / oneDay); } function breakDay() { - const now = new Date(); - return { - year: now.getFullYear(), - month: parseInt(now.getMonth()) + 1, - day: now.getDate() - }; + const now = new Date(); + + return { + 'year': now.getFullYear(), + 'month': parseInt(now.getMonth()) + 1, + 'day': now.getDate() + }; } function reduceTrains(d) { - - const titles = [], ta = []; - // console.log('reducetrains',d); - /*for (let items in d) { + const titles = [], ta = []; + // console.log('reducetrains',d); + /* for (let items in d) { if (typeof d[items].title !== 'undefined') { const hash = d[items].title.hashCode(); if (titles.indexOf(hash) === -1) { @@ -187,280 +191,276 @@ function reduceTrains(d) { }*/ - for (let item in d) { - if (typeof item.title !== 'undefined') { - const hash = item.title.hashCode(); - if (titles.indexOf(hash) === -1) { - titles.push(hash); - ta.push(item); - } - } + for (const item in d) + if (typeof item.title !== 'undefined') { + const hash = item.title.hashCode(); + if (titles.indexOf(hash) === -1) { + titles.push(hash); + ta.push(item); + } } - return ta; + + return ta; } /** * @return {number} */ function DayDiff(CurrentDate) { - const TYear = CurrentDate.getFullYear(); - const TDay = new Date('January, 01, ' + (parseInt(TYear) + 1)); - TDay.getFullYear(TYear); - let DayCount = (TDay - CurrentDate) / (1000 * 60 * 60 * 24); - DayCount = Math.round(DayCount); + const TYear = CurrentDate.getFullYear(); + const TDay = new Date(`January, 01, ${ parseInt(TYear) + 1}`); + TDay.getFullYear(TYear); + let DayCount = (TDay - CurrentDate) / (1000 * 60 * 60 * 24); + DayCount = Math.round(DayCount); - const d = new Date(); - DayCount = d.daysSince('beginning of this year'); - return (DayCount); + const d = new Date(); + DayCount = d.daysSince('beginning of this year'); + + return (DayCount); } Array.prototype.indexOfOld = Array.prototype.indexOf; Array.prototype.indexOf = function (e, fn) { - if (!fn) { - return this.indexOfOld(e); - } else { - if (typeof fn === 'string') { - const att = fn; - fn = function (e) { - return e[att]; - }; - } - return this.map(fn).indexOfOld(e); + if (!fn) + return this.indexOfOld(e); + else { + if (typeof fn === 'string') { + const att = fn; + fn = function (e) { + return e[att]; + }; } + + return this.map(fn).indexOfOld(e); + } }; module.exports = { - setEmitter: function (newEmitter) { - console.log('Setting events', newEmitter); - eventEmitter = newEmitter; - }, - getClock: function (req, res) { - // Console.log(todayCache); - res.render('pages/clock', todayCache); - }, - getToday: function (req, res) { - logger.info(todayCache); - res.render('pages/today', todayCache); - }, - getData: function (req, res) { - res.setHeader('Content-Type', 'application/json'); - res.end(JSON.stringify(todayCache)); - }, - getTodayDate: function () { - let s; - const d = new Date(); - let nextYear = (parseInt(d.getFullYear()) + 1).toString() + '-01-01'; + 'setEmitter': function (newEmitter) { + console.log('Setting events', newEmitter); + eventEmitter = newEmitter; + }, + 'getClock': function (req, res) { + // Console.log(todayCache); + res.render('pages/clock', todayCache); + }, + 'getToday': function (req, res) { + logger.info(todayCache); + res.render('pages/today', todayCache); + }, + 'getData': function (req, res) { + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(todayCache)); + }, + 'getTodayDate': function () { + let s; + // let d = new Date(); - console.log(d.daysUntil('beginning of next year')); - const daysSinceStart = d.daysSince('beginning of this year'); - const daysRemaining = d.daysUntil('beginning of next year'); + let d = new Sugar.Date(); + console.log('>> D', d); + const nextYear = `${(parseInt(d.getFullYear()) + 1).toString() }-01-01`; - todayCache.data.history = []; - s = '' + d.format('{Weekday} {Month} {dd}, {yyyy}') + ' - '; + console.log(d.daysUntil('beginning of next year')); + const daysSinceStart = d.daysSince('beginning of this year'); + const daysRemaining = d.daysUntil('beginning of next year'); - /* + todayCache.data.history = []; + s = `${ d.format('{Weekday} {Month} {dd}, {yyyy}') } - `; + + /* s = s + 'The ' + daysSinceStart + nth(daysSinceStart) + ' day of ' + dateFormat( d, 'yyyy') + ', and there are ' + daysRemaining + ' days left until the end of the year.'; */ - s = s + `The ${daysSinceStart + nth(daysSinceStart)} day of ${dateFormat(d, 'yyyy')}, and there are ${daysRemaining} days until the end of the year` + s = `${s }The ${daysSinceStart + nth(daysSinceStart)} day of ${d.format('{yyyy}')}, and there are ${daysRemaining} days until the end of the year`; - logger.debug(s); - todayCache.data.today = s; - }, - refreshTrain: function () { + logger.debug(s); + todayCache.data.today = s; + }, + 'refreshTrain': function () { + trains.updateTrains() + .then((d) => { + 'use strict'; - trains.updateTrains() - .then((d) => { - 'use strict'; + d = reduceTrains(d); - d = reduceTrains(d); + eventEmitter.emit('sendSocket', { 'id': 'trains', 'data': d }); + todayCache.data.trains.data = d; + todayCache.data.trains.last = new Date(); + }) + .catch((e) => { + 'use strict'; + logger.error(e); + }); + }, + 'refreshWeather': function () { + weather.newDoGetWeather() + .then((d) => { + todayCache.data.weather = d; + logger.info('Updating weather'); + broadcastWeather(); + }).catch((e) => { + logger.error(e); + }); + }, - eventEmitter.emit('sendSocket', {id: 'trains', data: d}); - todayCache.data.trains.data = d; - todayCache.data.trains.last = new Date(); - }) - .catch((e) => { - 'use strict'; - logger.error(e); - }); + 'refreshTrainAndWeather': function () { + this.refreshTrain(); + this.refreshWeather(); + }, + 'preLoadToday': function () { + module.exports.getTodayDate(); + todayCache.data.cal = { 'today': [], 'tomorrow': [], 'week': [] }; + weather.newDoGetWeather() + .then((d) => { + todayCache.data.weather = d; + }) + .catch((e) => { + logger.error(e); + }); + trains.updateTrains() + .then((d) => { + 'use strict'; + console.log('Trains: ', d); + todayCache.data.trains.data = d; + todayCache.data.trains.last = new Date(); + }) + .catch((e) => { + 'use strict'; + console.error(e); + }); + history.updateHistory() + .then((d) => { + 'use strict'; + console.log('History result: ', d); + todayCache.data.history = d; + }) + .catch((e) => { + 'use strict'; + console.error(e); + }); + calHandler.getSimpleCalV3( + 'http://www.pogdesign.co.uk/cat/download_ics/60cfdff469d0490545d33d7e3b5c0bcc') + .then((d) => { + 'use strict'; + todayCache.data.tv = d; + }) + .catch((e) => { + 'use strict'; + logger.error(e); + }); - }, - refreshWeather: function () { - weather.newDoGetWeather() - .then((d) => { - todayCache.data.weather = d; - logger.info('Updating weather'); - broadcastWeather(); - }).catch((e) => { - logger.error(e); + todayFTSE.getFTSE() + .then((d) => { + todayCache.data.ftse = d; + }) + .catch((e) => { + logger.error(e); + }); + + quotes.GetQuotes() + .then((d) => { + todayCache.data.quotes = d; + }) + .catch((e) => { + logger.error(e); + }); + + for (let t = 0; t < calHandler.calendars.length; t++) + calHandler.getAdvancedCalV3(calHandler.calendars[t]) + .then((d) => { + 'use strict'; + todayCache.data.cal.today = todayCache.data.cal.today.concat(d.today); + todayCache.data.cal.tomorrow = todayCache.data.cal.tomorrow.concat(d.tomorrow); + todayCache.data.cal.week = todayCache.data.cal.week.concat(d.week); + // logger.debug('>> today', todayCache.data.cal.today); + }) + .catch((e) => { + 'use strict'; + logger.error(e); }); - }, + swedishWord.getSwedishWord() + .then((d) => { + 'use strict'; + console.log('Swedish result: ', d); + todayCache.data.swedish = d; + }) + .catch((e) => { + 'use strict'; + console.error(e); + }); - refreshTrainAndWeather: function () { - this.refreshTrain(); - this.refreshWeather(); - }, - preLoadToday: function () { - module.exports.getTodayDate(); - todayCache.data.cal = {today: [], tomorrow: [], week: []}; - weather.newDoGetWeather() - .then((d) => { - todayCache.data.weather = d; - }) - .catch((e) => { - logger.error(e); - }); - trains.updateTrains() - .then((d) => { - 'use strict'; - console.log('Trains: ', d); - todayCache.data.trains.data = d; - todayCache.data.trains.last = new Date(); - }) - .catch((e) => { - 'use strict'; - console.error(e); - }); - history.updateHistory() - .then((d) => { - 'use strict'; - console.log('History result: ', d); - todayCache.data.history = d; - }) - .catch((e) => { - 'use strict'; - console.error(e); - }); + /*mdFitbit.getYesterdayFitbit() + .then((d) => { + todayCache.data.fitbit = d; + }) + .catch((e) => { + 'use strict'; + console.error(e); + });*/ - calHandler.getSimpleCalV3( - 'http://www.pogdesign.co.uk/cat/download_ics/60cfdff469d0490545d33d7e3b5c0bcc') - .then((d) => { - 'use strict'; - todayCache.data.tv = d; - }) - .catch((e) => { - 'use strict'; - logger.error(e); - }); - - todayFTSE.getFTSE() - .then((d) => { - todayCache.data.ftse = d; - }) - .catch((e) => { - logger.error(e); - }); - - quotes.GetQuotes() - .then((d) => { - todayCache.data.quotes = d; - }) - .catch((e) => { - logger.error(e); - }); - - - for (let t = 0; t < calHandler.calendars.length; t++) { - calHandler.getAdvancedCalV3(calHandler.calendars[t]) - .then((d) => { - 'use strict'; - todayCache.data.cal.today = todayCache.data.cal.today.concat(d.today); - todayCache.data.cal.tomorrow = todayCache.data.cal.tomorrow.concat(d.tomorrow); - todayCache.data.cal.week = todayCache.data.cal.week.concat(d.week); - }) - .catch((e) => { - 'use strict'; - logger.error(e); - }); - } - - swedishWord.getSwedishWord() - .then((d) => { - 'use strict'; - console.log('Swedish result: ', d); - todayCache.data.swedish = d; - }) - .catch((e) => { - 'use strict'; - console.error(e); - }); - - mdFitbit.getYesterdayFitbit() - .then((d) => { - todayCache.data.fitbit = d; - }) - .catch((e) => { - 'use strict'; - console.error(e); - }); - - todayCache.date = breakDay(); - }, broadcast: function () { - console.log('BROADCAST'); - broadcastWeather(); - eventEmitter.emit('sendSocket', {id: 'trains', data: todayCache.data.trains.data}); - - } + todayCache.date = breakDay(); + }, 'broadcast': function () { + console.log('BROADCAST'); + broadcastWeather(); + eventEmitter.emit('sendSocket', { 'id': 'trains', 'data': todayCache.data.trains.data }); + } }; setTimeout(function () { - loadData(); - if (runable()) { - module.exports.preLoadToday(); - } - //Module.exports.preLoadToday(); - + loadData(); + if (runable()) + module.exports.preLoadToday(); + + // Module.exports.preLoadToday(); }, 5000); setTimeout(function () { - // mdMailer.sendEmailV1(todayCache, __dirname); - // saveToDB(todayCache); - saveData(); + // mdMailer.sendEmailV1(todayCache, __dirname); + // saveToDB(todayCache); + + // saveData(); }, 45000); setInterval(function () { - // EventEmitter.emit('sendSocket',{id:'weather',data:todayCache.data.weather}); - // broadcastWeather(); - // eventEmitter.emit('sendSocket', {id: 'trains', data: todayCache.data.trains.data}); - + // EventEmitter.emit('sendSocket',{id:'weather',data:todayCache.data.weather}); + // broadcastWeather(); + // eventEmitter.emit('sendSocket', {id: 'trains', data: todayCache.data.trains.data}); + // mdMailer.sendEmailV1(todayCache, __dirname); }, (60000)); - cron.schedule('30 6 * * *', function () { - if (runable()) { - module.exports.preLoadToday(); - } + if (runable()) + module.exports.preLoadToday(); - return -1; + return -1; }); cron.schedule('0 */1 * * *', function () { - // Module.exports.refreshTrainAndWeather(); - // this.refreshTrain(); - module.exports.refreshWeather(); + // Module.exports.refreshTrainAndWeather(); + // this.refreshTrain(); + module.exports.refreshWeather(); - return -1; + return -1; }); cron.schedule('*/15 * * * *', function () { - module.exports.refreshTrain(); + module.exports.refreshTrain(); - // Module.exports.refreshWeather(); + // Module.exports.refreshWeather(); - return -1; + return -1; }); cron.schedule('45 6 * * *', function () { - mdMailer.sendEmailV1(todayCache, __dirname); - saveToDB(todayCache); - // Console.log('tick'); - return -1; + // mdMailer.sendEmailV1(todayCache, __dirname); + // saveToDB(todayCache); + // Console.log('tick'); + return -1; }); - diff --git a/lib/today/calHandler.js b/lib/today/calHandler.js index b9c53cd..f6eb850 100644 --- a/lib/today/calHandler.js +++ b/lib/today/calHandler.js @@ -1,132 +1,129 @@ -const request = require('request') -const log4js = require('log4js') -const logger = log4js.getLogger() -const STRING = require('string') -let util = require('util') -const Elapsed = require('elapsed') -require('sugar-date'); +const request = require('request'); +const log4js = require('log4js'); +const logger = log4js.getLogger(); +const STRING = require('string'); +const util = require('util'); +const Elapsed = require('elapsed'); +const Sugar = require('sugar'); + +logger.level = 'debug'; function processICAL(ical) { 'use strict'; logger.info('+ processICAL'); - let workingBlock = [] + const workingBlock = []; const segments = { - meetingStartID: 'DTSTART;TZID=Europe/London:', - meetingStartAlt: 'DTSTART:', - meetingStartAltOther: 'DTSTART;VALUE=DATE:', - meetingEndID: 'DTEND;TZID=Europe/London:', - meetingEndAlt: 'DTEND:', - meetingEndAltOther: 'DTEND;VALUE=DATE:', - meetingDescID: 'DESCRIPTION:', - summaryID: 'SUMMARY:', - begin: 'BEGIN:VEVENT', - end: 'END:VEVENT', - beginAlarm: 'BEGIN:VALARM', - endAlarm: 'END:VALARM', - recur: 'RRULE:' - } + 'meetingStartID': 'DTSTART;TZID=Europe/London:', + 'meetingStartAlt': 'DTSTART:', + 'meetingStartAltOther': 'DTSTART;VALUE=DATE:', + 'meetingEndID': 'DTEND;TZID=Europe/London:', + 'meetingEndAlt': 'DTEND:', + 'meetingEndAltOther': 'DTEND;VALUE=DATE:', + 'meetingDescID': 'DESCRIPTION:', + 'summaryID': 'SUMMARY:', + 'begin': 'BEGIN:VEVENT', + 'end': 'END:VEVENT', + 'beginAlarm': 'BEGIN:VALARM', + 'endAlarm': 'END:VALARM', + 'recur': 'RRULE:' + }; - const rules = ['FREQ', 'WKST', 'UNTIL', 'BYMONTH', 'BYMONTHDAY', 'INTERVAL', 'BYDAY'] + const rules = ['FREQ', 'WKST', 'UNTIL', 'BYMONTH', 'BYMONTHDAY', 'INTERVAL', 'BYDAY']; function nThDayOfMonth(monthsAhead, wantedDay) { - const now = new Date() + const now = new Date(); - for(let t=0; t < monthsAhead; t++) { + for(let t = 0; t < monthsAhead; t++) { } - } function processRecurrence(workBlock) { - let _workBlock = workBlock + const _workBlock = workBlock; // logger.debug('Processing recurrence...'); // logger.debug('Processing recurrence...'); - const weekBits = {'SU': 0, 'MO': 1, 'TU': 2, 'WE': 3, 'TH': 4, 'FR': 5, 'SA': 6} + const weekBits = { 'SU': 0, 'MO': 1, 'TU': 2, 'WE': 3, 'TH': 4, 'FR': 5, 'SA': 6 }; - const now = new Date() - const day = now.getDate() - const dayNum = now.getDay() - const month = now.getMonth() - const year = now.getFullYear() + const now = new Date(); + const day = now.getDate(); + const dayNum = now.getDay(); + const month = now.getMonth(); + const year = now.getFullYear(); - let recurSettings = {freq: null, wkst: null, until: null, bymonth: null, bymonthday: null, interval: null, byday: null} + const recurSettings = { 'freq': null, 'wkst': null, 'until': null, 'bymonth': null, 'bymonthday': null, 'interval': null, 'byday': null }; - const firstSplit = _workBlock.recur.split(';') + const firstSplit = _workBlock.recur.split(';'); - for (let t=0; t< firstSplit.length; t++) - { - const ws = firstSplit[t].split('=') - if (rules.indexOf(ws[0]) > -1) { - recurSettings[ws[0].toLowerCase()] = ws[1]; - } - } + for (let t = 0; t < firstSplit.length; t++) { + const ws = firstSplit[t].split('='); + if (rules.indexOf(ws[0]) > -1) + recurSettings[ws[0].toLowerCase()] = ws[1]; + } // if all null discard.. - if (recurSettings.freq === null && recurSettings.wkst === null && recurSettings.until === null && recurSettings.byday === null && recurSettings.bymonth === null && recurSettings.bymonthday === null && recurSettings.interval === null) { + if (recurSettings.freq === null && recurSettings.wkst === null && recurSettings.until === null && recurSettings.byday === null && recurSettings.bymonth === null && recurSettings.bymonthday === null && recurSettings.interval === null) return null; - } - if (recurSettings.until !== null) { + if (recurSettings.until !== null) // have we expired? - //var _until = Date.create(recurSettings.until).isPast(); + // var _until = Date.create(recurSettings.until).isPast(); return null; - } if (recurSettings.freq !== null) { + // logger.debug(_workBlock); + let newStart, newEnd; -// logger.debug(_workBlock); - let origStart, origEnd, distance, newStart, newEnd + // let d = new Sugar.Date(); + /* origStart = Date.create(_workBlock.dtstart); + origEnd = Date.create(_workBlock.dtend);*/ + const origStart = new Sugar.Date(_workBlock.dtstart).raw; + const origEnd = new Sugar.Date(_workBlock.dtend).raw; - origStart = Date.create(_workBlock.dtstart); - origEnd = Date.create(_workBlock.dtend); - const _d = origStart.getDate() - const _m = origStart.getMonth() - const _h = origStart.getHours() - const _min = origStart.getMinutes() - const _secs = origStart.getSeconds() - distance = origEnd - origStart; + const _d = origStart.getDate(); + const _m = origStart.getMonth(); + const _h = origStart.getHours(); + const _min = origStart.getMinutes(); + const _secs = origStart.getSeconds(); + const distance = origEnd - origStart; + // Sugar.Date() if (recurSettings.freq === 'YEARLY') { - if (recurSettings.bymonth !== null && recurSettings.bymonthday !== null) { // ok, a day and month. - newStart = Date.create().set({year:year, month: recurSettings.bymonth - 1 , day: recurSettings.bymonthday, hour:_h, minutes:_min, seconds:_secs}); - newEnd = Date.create(newStart).addMilliseconds(distance); + newStart = Sugar.Date().set({ 'year':year, 'month': recurSettings.bymonth - 1, 'day': recurSettings.bymonthday, 'hour':_h, 'minutes':_min, 'seconds':_secs }).raw; + newEnd = Sugar.Date(newStart).addMilliseconds(distance).raw; _workBlock.dtstart = newStart; _workBlock.dtend = newEnd; - - } else if (recurSettings.bymonth === null && recurSettings.bymonthday === null) { + } + else if (recurSettings.bymonth === null && recurSettings.bymonthday === null) { // extract month and year from dtstart - newStart = Date.create().set({year:year, month: _m , day: _d, hour:_h, minutes:_min, seconds:_secs}); - newEnd = Date.create(newStart).addMilliseconds(distance); + newStart = Sugar.Date().set({ 'year':year, 'month': _m, 'day': _d, 'hour':_h, 'minutes':_min, 'seconds':_secs }).raw; + newEnd = Sugar.Date(newStart).addMilliseconds(distance).raw; _workBlock.dtstart = newStart; _workBlock.dtend = newEnd; - } return _workBlock; } - if (recurSettings.freq === 'MONTHLY') { + if (recurSettings.freq === 'MONTHLY') if (recurSettings.bymonthday !== null) { // ok, a day and month. - newStart = Date.create().set({year:year, month: month , day: recurSettings.bymonthday, hour:_h, minutes:_min, seconds:_secs}); - newEnd = Date.create(newStart).addMilliseconds(distance); + newStart = Sugar.Date().set({ 'year':year, 'month': month, 'day': recurSettings.bymonthday, 'hour':_h, 'minutes':_min, 'seconds':_secs }).raw; + newEnd = Sugar.Date(newStart).addMilliseconds(distance).raw; _workBlock.dtstart = newStart; _workBlock.dtend = newEnd; - } - } if (recurSettings.freq === 'WEEKLY' && recurSettings.interval === null) { - const byDayBit = recurSettings.byday.split(',')[0] - const byDayNumber = weekBits[byDayBit] + const byDayBit = recurSettings.byday.split(',')[0]; + const byDayNumber = weekBits[byDayBit]; if (byDayNumber >= dayNum) { - const daysAdded = byDayNumber - dayNum - newStart = Date.create().set({year:year, month: month , day: day, hour:_h, minutes:_min, seconds:_secs}).addDays(daysAdded); - newEnd = Date.create(newStart).addMilliseconds(distance); + const daysAdded = byDayNumber - dayNum; + newStart = Sugar.Date().set({ 'year':year, 'month': month, 'day': day, 'hour':_h, 'minutes':_min, 'seconds':_secs }).addDays(daysAdded).raw; + newEnd = Sugar.Date(newStart).addMilliseconds(distance).raw; _workBlock.dtstart = newStart; _workBlock.dtend = newEnd; } @@ -139,143 +136,149 @@ function processICAL(ical) { } function processBlock(block) { - let _wb + let _wb; let workBlock = { - summary: '', - dtstart: null, - dtend: null, - description: '', - timeStart: null, - timeEnd: null, - duration: 0, - combined: '', - recur: null - } - let alarmFlag = false, ws, blockStep + 'summary': '', + 'dtstart': null, + 'dtend': null, + 'description': '', + 'timeStart': null, + 'timeEnd': null, + 'duration': 0, + 'combined': '', + 'recur': null + }; + let alarmFlag = false, ws, blockStep; for (let step = 0; step < block.length; step++) { blockStep = block[step]; - if (blockStep.indexOf(segments.recur) >= 0) { - workBlock.recur = STRING(block[step].split(segments.recur)[1]).collapseWhitespace().s; - //logger.debug(workBlock.recur); - } + if (blockStep.indexOf(segments.recur) >= 0) + workBlock.recur = STRING(block[step].split(segments.recur)[1]).collapseWhitespace().s; + // logger.debug(workBlock.recur); - if (blockStep.indexOf(segments.summaryID) >= 0) { + if (blockStep.indexOf(segments.summaryID) >= 0) workBlock.summary = STRING(block[step].split(segments.summaryID)[1]).collapseWhitespace().s; - } + if (blockStep.indexOf(segments.meetingStartID) >= 0) { ws = STRING(block[step].split(segments.meetingStartID)[1]).collapseWhitespace().s; - workBlock.dtstart = Date.create(ws); + // workBlock.dtstart = Date.create(ws); + workBlock.dtstart = new Sugar.Date(ws).raw; } if (blockStep.indexOf(segments.meetingEndID) >= 0) { ws = STRING(block[step].split(segments.meetingEndID)[1]).collapseWhitespace().s; - workBlock.dtend = Date.create(ws); + // workBlock.dtend = Date.create(ws); + workBlock.dtend = new Sugar.Date(ws).raw; } if (blockStep.indexOf(segments.meetingStartAlt) >= 0) { ws = STRING(block[step].split(segments.meetingStartAlt)[1]).collapseWhitespace().s; - workBlock.dtstart = Date.create(ws); + console.log('>> ws', ws); + // workBlock.dtstart = Date.create(ws); + // let d = new Sugar.Date(); + workBlock.dtstart = new Sugar.Date(ws).raw; + console.log('>> date', workBlock.dtstart); } if (blockStep.indexOf(segments.meetingEndAlt) >= 0) { ws = STRING(block[step].split(segments.meetingEndAlt)[1]).collapseWhitespace().s; - workBlock.dtend = Date.create(ws); + // workBlock.dtend = Date.create(ws); + workBlock.dtend = new Sugar.Date(ws).raw; + console.log('>> date', workBlock.dtend); } if (blockStep.indexOf(segments.meetingStartAltOther) >= 0) { - ws = STRING(block[step].split(segments.meetingStartAltOther)[1]).collapseWhitespace().s; - workBlock.dtstart = Date.create(ws); - } - if (blockStep.indexOf(segments.meetingEndAltOther) >= 0) { - ws = STRING(block[step].split(segments.meetingEndAltOther)[1]).collapseWhitespace().s; - workBlock.dtend = Date.create(ws); - } + ws = STRING(block[step].split(segments.meetingStartAltOther)[1]).collapseWhitespace().s; + // workBlock.dtstart = Date.create(ws); + workBlock.dtstart = new Sugar.Date(ws).raw; + } + if (blockStep.indexOf(segments.meetingEndAltOther) >= 0) { + ws = STRING(block[step].split(segments.meetingEndAltOther)[1]).collapseWhitespace().s; + console.log('>> ws', ws); + // workBlock.dtend = Date.create(ws); + workBlock.dtend = new Sugar.Date(ws).raw; + } - if (blockStep.indexOf(segments.meetingDescID) >= 0) { + if (blockStep.indexOf(segments.meetingDescID) >= 0) if (!alarmFlag) { workBlock.description = STRING(block[step].split(segments.meetingDescID)[1]).collapseWhitespace().s; } - } - if (blockStep.indexOf(segments.beginAlarm) >= 0) { + + if (blockStep.indexOf(segments.beginAlarm) >= 0) alarmFlag = true; - } } // We have to check recuring stuff before the cron stuff is processed. if (workBlock.recur !== null) { - _wb = processRecurrence(workBlock); - // logger.warn('returning:', _wb); - if (_wb !== null) { + // logger.warn('returning:', _wb); + if (_wb !== null) if (!Array.isArray(_wb)) { workBlock = _wb; - } else { + } + else { logger.error('We made an array'); } - - } } - //logger.debug(workBlock); + // logger.debug(workBlock); + // let d = new Sugar.Date(); if (workBlock.dtstart !== null) { - workBlock.timeStart = workBlock.dtstart.format('{24hr}:{mm}:{ss}'); + // workBlock.timeStart = workBlock.dtstart.format('{24hr}:{mm}:{ss}'); + workBlock.timeStart = Sugar.Date(workBlock.dtstart).format('{24hr}:{mm}:{ss}').raw; + + console.log('>> workBlock.timeStart', workBlock.timeStart); workBlock.combined = `${workBlock.timeStart} - '`; - workBlock.long = `${workBlock.dtstart.format('{Weekday}')}, ${workBlock.timeStart} - `; + workBlock.long = `${Sugar.Date(workBlock.dtstart).format('{Weekday}').raw}, ${workBlock.timeStart} - `; + console.log('>> workBlock.long', workBlock.long); } workBlock.combined = workBlock.combined + workBlock.summary; workBlock.longcombined = workBlock.long + workBlock.summary; - if (workBlock.dtend !== null) { - workBlock.timeEnd = workBlock.dtend.format('{24hr}:{mm}:{ss}'); - } + if (workBlock.dtend !== null) + workBlock.timeEnd = Sugar.Date(workBlock.dtend).format('{24hr}:{mm}:{ss}').raw; + if (workBlock.dtstart !== null && workBlock.dtend !== null) { - const elapsedTime = new Elapsed(workBlock.dtstart, workBlock.dtend) + const elapsedTime = new Elapsed(workBlock.dtstart, workBlock.dtend); workBlock.duration = elapsedTime.optimal; - workBlock.combined = workBlock.combined + ', ' + elapsedTime.optimal; - workBlock.longcombined = workBlock.longcombined + ', ' + elapsedTime.optimal; + workBlock.combined = `${workBlock.combined }, ${ elapsedTime.optimal}`; + workBlock.longcombined = `${workBlock.longcombined }, ${ elapsedTime.optimal}`; } return workBlock; } - const lines = ical.split('\r\n'), l = lines.length - let counter = 0 + const lines = ical.split('\r\n'), l = lines.length; + let counter = 0; - let alarmed = false - while (counter < l) { - if (lines[counter].indexOf(segments.begin) < 0) { + let alarmed = false; + while (counter < l) + if (lines[counter].indexOf(segments.begin) < 0) counter++; - } else { - let subcounter = 0 - const subBlock = [] + else { + let subcounter = 0; + const subBlock = []; alarmed = false; - while (subcounter < 75) { + while (subcounter < 75) if (lines[counter + subcounter].indexOf(segments.end) < 0) { - - if (lines[counter + subcounter].indexOf(segments.beginAlarm) > -1) { + if (lines[counter + subcounter].indexOf(segments.beginAlarm) > -1) alarmed = true; - } - if (!alarmed) { + + if (!alarmed) subBlock.push(lines[counter + subcounter]); - } - if (lines[counter + subcounter].indexOf(segments.endAlarm) > -1) { + + if (lines[counter + subcounter].indexOf(segments.endAlarm) > -1) alarmed = false; - } subcounter++; - } else { + } + else break; - } - } + counter = counter + subcounter; - const b = processBlock(subBlock) - if (Array.isArray(b)) { - logger.error('!returned an array...'); - } else { - if (b.dtstart !== null) { - workingBlock.push(b); - } - - } - + const b = processBlock(subBlock); + if (Array.isArray(b)) + logger.error('!returned an array...'); + else + if (b.dtstart !== null) + workingBlock.push(b); } - } + logger.info('- processICAL'); // If (workingBlock.dtstart == null) return {}; @@ -283,97 +286,97 @@ function processICAL(ical) { } module.exports = { - calendars: ['https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics', - 'https://calendar.google.com/calendar/ical/mt5pgdhknvgoc8usfnrso9vkv0%40group.calendar.google.com/private-58876002af9f302a593acfa6fa792dcf/basic.ics', - 'https://www.tripit.com/feed/ical/private/DB96E4BB-94A9BD8F9CC1CF51C6CC0D920840F4F5/tripit.ics', - 'https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics', - 'https://calendar.google.com/calendar/ical/i8dglj12p5nuv20sbjmun5s588%40group.calendar.google.com/private-c8adccb41e56d6a2f285078aaed313f5/basic.ics'], - jsonBlock: [], - getTodaysSimple: function() { + 'calendars': ['https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics', + 'https://calendar.google.com/calendar/ical/mt5pgdhknvgoc8usfnrso9vkv0%40group.calendar.google.com/private-58876002af9f302a593acfa6fa792dcf/basic.ics', + 'https://www.tripit.com/feed/ical/private/DB96E4BB-94A9BD8F9CC1CF51C6CC0D920840F4F5/tripit.ics', + 'https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics', + 'https://calendar.google.com/calendar/ical/i8dglj12p5nuv20sbjmun5s588%40group.calendar.google.com/private-c8adccb41e56d6a2f285078aaed313f5/basic.ics'], + 'jsonBlock': [], + 'getTodaysSimple': function() { 'use strict'; logger.info('+ getTodaysSimple'); const today = { - entries: [] - } + 'entries': [] + }; for (let t = 0; t < this.jsonBlock.length; t++) { - if (this.jsonBlock[t].dtstart.isToday()) { + // if (this.jsonBlock[t].dtstart.isToday()) + // logger.debug('>> isToday', Sugar.Date(this.jsonBlock[t].dtstart).isToday().raw); + if (Sugar.Date(this.jsonBlock[t].dtstart).isToday().raw) today.entries.push(this.jsonBlock[t]); - } } logger.info('- getTodaysSimple'); + return today; }, - getTomorrow: function() { - 'use strict'; - logger.info('+ getTomorrow'); - const today = { - entries: [] - } + 'getTomorrow': function() { + 'use strict'; + logger.info('+ getTomorrow'); + const today = { + 'entries': [] + }; + + for (let t = 0; t < this.jsonBlock.length; t++) + if (Sugar.Date(this.jsonBlock[t].dtstart).isTomorrow().raw) + + today.entries.push(this.jsonBlock[t]); + + logger.info('- getTomorrow'); + + return today; + }, + 'getWeek': function() { + 'use strict'; + logger.info('+ getWeek'); + const today = { + 'entries': [] + }; + + const now = new Sugar.Date('today').raw; + logger.debug('>> now', now); + const twoDays = new Sugar.Date('today').addDays(2).beginningOfDay().raw; + logger.debug('>> twoDays', twoDays); + const sevenDays = new Sugar.Date('today').addDays(7).beginningOfDay().raw; + logger.debug('>> sevenDays', sevenDays); + logger.debug('>> trip', { now, twoDays, sevenDays }); for (let t = 0; t < this.jsonBlock.length; t++) { - if (this.jsonBlock[t].dtstart.isTomorrow()) { - - today.entries.push(this.jsonBlock[t]); - } - } - logger.info('- getTomorrow'); - return today; - }, - getWeek: function() { - 'use strict'; - logger.info('+ getWeek'); - const today = { - entries: [] - } - let now, twoDays, sevenDays - - now = Date.create('today'); -// logger.debug(now); - twoDays = Date.create(now).addDays(2).beginningOfDay(); -// logger.debug(twoDays); - sevenDays = Date.create(twoDays).addDays(5).beginningOfDay(); - -// logger.debug(now, twoDays, sevenDays); - - for (let t = 0; t < this.jsonBlock.length; t++) { - if (this.jsonBlock[t].dtstart.isBetween(twoDays, sevenDays)) { - - today.entries.push(this.jsonBlock[t]); - } - } - logger.info('- getWeek'); - return today; - }, - getTodaysMeetings: function() { + logger.debug('>> between', Sugar.Date(this.jsonBlock[t].dtstart).raw, Sugar.Date(this.jsonBlock[t].dtstart).isBetween(twoDays, sevenDays)); + if (Sugar.Date(this.jsonBlock[t].dtstart).isBetween(twoDays, sevenDays).raw) + today.entries.push(this.jsonBlock[t]); + } + + logger.info('- getWeek'); + + return today; + }, + 'getTodaysMeetings': function() { 'use strict'; logger.info('+ getTodaysMeetings'); const today = { - previous: [], upcoming: [], current: {} - } - const now = new Date() + 'previous': [], 'upcoming': [], 'current': {} + }; + const now = new Date(); - for (let t = 0; t < this.jsonBlock.length; t++) { - if (this.jsonBlock[t].dtstart.isToday()) { - - if (this.jsonBlock[t].dtstart.isAfter(now)) { + for (let t = 0; t < this.jsonBlock.length; t++) + if (Sugar.Date(this.jsonBlock[t].dtstart).isToday().raw) { + if (Sugar.Date(this.jsonBlock[t].dtstart).isAfter(now).raw) today.upcoming.push(this.jsonBlock[t]); - } else { + else today.previous.push(this.jsonBlock[t]); - } - if (now.isBetween(this.jsonBlock[t].dtstart, this.jsonBlock[t].dtend)) { + if (now.isBetween(this.jsonBlock[t].dtstart, this.jsonBlock[t].dtend)) today.current = this.jsonBlock[t]; - } } - } + // logger.debug(today); logger.info('- getTodaysMeetings'); + return today; - }, getSimpleCalV2: function(url, cb) { + }, 'getSimpleCalV2': function(url, cb) { 'use strict'; - const self = this + const self = this; // Var calJson = []; try { @@ -381,105 +384,104 @@ module.exports = { if (err) { logger.error('Get remote Calendar Request failed'); // Callback.call(null, new Error('Request failed')); + return; } self.jsonBlock = processICAL(body); // logger.debug(self.jsonBlock); - const st = self.getTodaysSimple() + const st = self.getTodaysSimple(); - if (typeof cb === 'function') { + if (typeof cb === 'function') cb(st); - } }, function(error, response, body) { if (response.statusCode !== 200) { logger.error(response.statusCode); logger.error(body); } }); - } catch (e) { + } + catch (e) { console.log(e); } - - }, getSimpleCalV3: function(url) { + }, 'getSimpleCalV3': function(url) { 'use strict'; - const self = this + const self = this; return new Promise(function(resolve, reject) { try { request(url, function(err, res, body) { - if (err) { + if (err) // logger.error(err); return reject(err); - // Throw err; - } + // Throw err; self.jsonBlock = processICAL(body); // logger.debug(self.jsonBlock); - const st = self.getTodaysSimple() + const st = self.getTodaysSimple(); return resolve(st); }, function(error, response, body) { if (response.statusCode !== 200) { logger.error(response.statusCode); logger.error(body); + return reject(error); } }); - } catch (e) { + } + catch (e) { console.log(e); + return reject(e); } - }); // Var calJson = []; - - }, getAdvancedCalV3: function(url) { - 'use strict'; - const self = this + }, 'getAdvancedCalV3': function(url) { + 'use strict'; + const self = this; return new Promise(function(resolve, reject) { - try { - request(url, function(err, res, body) { - if (err) { - // logger.error(err); - return reject(err); - // Throw err; - } + try { + request(url, function(err, res, body) { + if (err) + // logger.error(err); + return reject(err); + // Throw err; - self.jsonBlock = processICAL(body); + self.jsonBlock = processICAL(body); - // logger.debug(self.jsonBlock); - const st = self.getTodaysSimple().entries - const tom = self.getTomorrow().entries - const week = self.getWeek().entries + // logger.debug(self.jsonBlock); + const st = self.getTodaysSimple().entries; + const tom = self.getTomorrow().entries; + const week = self.getWeek().entries; - const obj = {today: st, tomorrow: tom, week: week} - - logger.debug(obj); - return resolve(obj); - }, function(error, response, body) { - if (response.statusCode !== 200) { - logger.error(response.statusCode); - logger.error(body); - return reject(error); - } - }); - } catch (e) { - console.log(e); - return reject(e); - } - - }); - - // Var calJson = []; - - } + const obj = { 'today': st, 'tomorrow': tom, 'week': week }; + // logger.warn(obj); + + return resolve(obj); + }, function(error, response, body) { + if (response.statusCode !== 200) { + logger.error(response.statusCode); + logger.error(body); + + return reject(error); + } + }); + } + catch (e) { + console.log(e); + + return reject(e); + } + }); + // Var calJson = []; + } /** * Created by Martin on 16/02/2016. diff --git a/lib/today/history.js b/lib/today/history.js index dc420f4..8886a22 100644 --- a/lib/today/history.js +++ b/lib/today/history.js @@ -4,24 +4,24 @@ var STRING = require('string'); var logger = require('log4js').getLogger(); module.exports = { - getTechHistory: function() { + 'getTechHistory': function() { var url; var d; var day; var month; var monthNames = [ - 'January', - 'February', - 'March', - 'April', - 'May', - 'June', - 'July', - 'August', - 'September', - 'October', - 'November', - 'December' + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December' ]; d = new Date(); @@ -32,15 +32,15 @@ module.exports = { url = ['http://www.computerhistory.org/tdih/', month, '/', day].join(''); logger.debug(url); + return new Promise(function(resolve, reject) { 'use strict'; request(url, function(err, resp, body) { - if (err) { + if (err) // Logger.error(err); return reject(err); - // Throw err; - } + // Throw err; var $ = cheerio.load(body); var tdihbody = $('#tdihbody'); @@ -57,29 +57,29 @@ module.exports = { if (response.statusCode !== 200) { logger.error(response.statusCode); logger.error(body); + return reject(error); } }); }); - - }, getHistory: function() { + }, 'getHistory': function() { var url; var d = new Date(); var day; var month; var monthNames = [ - 'january', - 'february', - 'march', - 'april', - 'may', - 'june', - 'july', - 'august', - 'september', - 'october', - 'november', - 'december' + 'january', + 'february', + 'march', + 'april', + 'may', + 'june', + 'july', + 'august', + 'september', + 'october', + 'november', + 'december' ]; month = monthNames[d.getMonth()]; @@ -87,20 +87,18 @@ module.exports = { day = d.getDate(); url = [ - 'http://www.bbc.co.uk/scotland/history/onthisday/', month, '/', - day + 'http://www.bbc.co.uk/scotland/history/onthisday/', month, '/', + day ].join(''); logger.debug(url); return new Promise(function(resolve, reject) { - request(url, function(err, resp, body) { - if (err) { + if (err) // Logger.error(err); return reject(err); - // Throw err; - } + // Throw err; var $ = cheerio.load(body); @@ -108,52 +106,48 @@ module.exports = { var output = []; nbody.find('.story > p').each(function(div) { - var s = $(this).text(); - if (s.indexOf('Today\'s recipe:') == -1) { + if (s.indexOf('Today\'s recipe:') == -1) output.push(s); - } }); return resolve(output); - }, function(error, response, body) { if (response.statusCode !== 200) { logger.error(response.statusCode); logger.error(body); + return reject(error); } }); - }); - }, - updateHistory: function() { + 'updateHistory': function() { 'use strict'; var output = []; + return new Promise(function(resolve, reject) { module.exports.getHistory() - .then((d)=> { + .then((d) => { + output = d; - output = d; + module.exports.getTechHistory() + .then((d) => { + output = output.concat(d); - module.exports.getTechHistory() - .then((d) => { - output = output.concat(d); - - return resolve(output); - }) - .catch((e) => { - logger.error(e); - return reject(e); - }); - - }) - .catch((e) => { - logger.error(e); - return reject(e); - }); - - }) + return resolve(output); + }) + .catch((e) => { + logger.error(e); + + return reject(e); + }); + }) + .catch((e) => { + logger.error(e); + + return reject(e); + }); + }); } -}; \ No newline at end of file +}; diff --git a/lib/today/weather.js b/lib/today/weather.js index e70e272..f34f1ef 100644 --- a/lib/today/weather.js +++ b/lib/today/weather.js @@ -5,46 +5,44 @@ const Forecast = require('forecast.io'); const STRING = require('string'); const logger = require('log4js').getLogger(); - const forecastOptions = { - APIKey: '9ad2a41d420f3cf4960571bb886f710c', units: 'uk2' + 'APIKey': '9ad2a41d420f3cf4960571bb886f710c', 'units': 'uk2' }; module.exports = { - newDoGetWeather: function() { - 'use strict'; - return new Promise(function(resolve, reject) { - logger.info('New Retrieving weather..'); - const j = {}; - const forecast = new Forecast(forecastOptions); - forecast.get(55.95, -4.566667, - {units: 'uk2'}, - function(err, res, data) { - if (err) { - return reject(err); - } + 'newDoGetWeather': function() { + 'use strict'; + + return new Promise(function(resolve, reject) { + logger.info('New Retrieving weather..'); + const j = {}; + const forecast = new Forecast(forecastOptions); + forecast.get(55.95, -4.566667, + { 'units': 'uk2' }, + function(err, res, data) { + if (err) + return reject(err); - const tempMin = parseInt(data.daily.data[0].temperatureMin); - const tempMax = parseInt(data.daily.data[0].temperatureMax); + const tempMin = parseInt(data.daily.data[0].temperatureMin); + const tempMax = parseInt(data.daily.data[0].temperatureMax); - j.currently = data.currently.summary; - j.today = data.daily.data[0].summary; - j.later = data.daily.summary; - j.alerts = data.alerts || {}; - j.data = data; + j.currently = data.currently.summary; + j.today = data.daily.data[0].summary; + j.later = data.daily.summary; + j.alerts = data.alerts || {}; + j.data = data; - const fs = STRING(j.currently).endsWith('.') ? '' : '.'; - if (tempMax === tempMin) { - j.currently += fs + ' Around ' + tempMin.toString() + ' degrees.'; - } - else { - j.currently += fs + ' Around ' + tempMin.toString() + ' to ' + tempMax.toString() + ' degrees.'; - } - // logger.debug(j); - return resolve(j); - }); + const fs = STRING(j.currently).endsWith('.') ? '' : '.'; + if (tempMax === tempMin) + j.currently += `${fs } Around ${ tempMin.toString() } degrees.`; + + else + j.currently += `${fs } Around ${ tempMin.toString() } to ${ tempMax.toString() } degrees.`; + + // logger.debug(j); + return resolve(j); }); - } - + }); + } }; diff --git a/lib/weather.js b/lib/weather.js index 34dc0f9..b9047bf 100644 --- a/lib/weather.js +++ b/lib/weather.js @@ -8,34 +8,48 @@ const util = require('util'); const jsonfile = require('jsonfile'); const fs = require('fs'); const logger = require('log4js').getLogger(); +const weather = require('openweather-apis'); + +weather.setAPPID('936a0ed9eb23b95cf08fc9f693c24264'); +weather.setLang('en'); +weather.setCity('Glasgow City'); const forecastOptions = { - APIKey: '0657dc0d81c037cbc89ca88e383b6bbf', - units: 'uk2' + 'APIKey': '0657dc0d81c037cbc89ca88e383b6bbf', + 'units': 'uk2' }; -const file = __dirname + '/' + 'data.json'; +const file = `${__dirname }/` + 'data.json'; function saveData(d) { - jsonfile.writeFileSync(file, d); + jsonfile.writeFileSync(file, d); } -module.exports = { +function doGetWeatherOutlook () { + logger.info('Retrieving weather..'); + const j = {}; + const forecast = new Forecast(forecastOptions); + forecast.get(55.8582846, -4.2593033, { 'units': 'uk2' }, (err, res, data) => { + if (err) throw err; + logger.debug(util.inspect(data)); + saveData(data); + j.currently = data.currently.summary; + j.today = data.daily.data[0].summary; + j.later = data.daily.summary; + j.alerts = data.alerts || {}; + }); +} - doGetWeatherOutlook: function () { - logger.info('Retrieving weather..'); - let j = {}; - let forecast = new Forecast(forecastOptions); - forecast.get(55.8582846, -4.2593033, {units: 'uk2'}, (err, res, data) => { - if (err) throw err; - logger.debug(util.inspect(data)); - saveData(data); - j.currently = data.currently.summary; - j.today = data.daily.data[0].summary; - j.later = data.daily.summary; - j.alerts = data.alerts || {}; - }); - } -}; +function doGetOpenWeather() { + return new Promise((resolve, reject) => { + weather.getWeatherForecastForDays(5, function(err, wData) { + if (err) + return reject(err); + else + return resolve(wData); + }); + }); +} -module.exports.doGetWeatherOutlook(); \ No newline at end of file +module.exports.doGetWeatherOutlook = doGetWeatherOutlook; +module.exports.doGetOpenWeather = doGetOpenWeather; diff --git a/package.json b/package.json index eab3b95..b75eb24 100644 --- a/package.json +++ b/package.json @@ -7,15 +7,15 @@ "babel-eslint": "^7.2.1", "babel-preset-es2015": "^6.24.0", "cheerio": "^0.22.0", - "dateformat": "^2.0.0", + "dateformat": "^2.2.0", "ejs": "^2.5.7", - "eslint": "^4.6.1", + "eslint": "^4.7.2", "eslint-config-defaults": "^9.0.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.1.1", "eslint-plugin-promise": "^3.5.0", - "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react": "^7.4.0", "eslint-plugin-standard": "^3.0.1", "eslint-watch": "^3.0.1", "fitbit-oauth2": "0.0.1", @@ -36,16 +36,16 @@ "gulp-uglify": "^3.0.0", "htmlparser": "^1.7.7", "jade": "^1.11.0", - "jest": "^21.0.2", + "jest": "^21.2.1", "jshint": "^2.9.4", "jsonfile": "^3.0.1", "lodash": "^4.11.2", - "log4js": "^2.3.3", + "log4js": "^2.3.4", "lowdb": "^1.0.0", "mammoth": "^1.4.2", - "nano": "^6.4.0", + "nano": "^6.4.2", "node-localstorage": "^1.3.0", - "request": "^2.81.0", + "request": "^2.83.0", "simple-weather": "^1.2.2", "sugar-date": "^2.0.4", "wordsoap": "^0.2.0", @@ -53,30 +53,32 @@ "xmltojson": "^1.3.5" }, "dependencies": { - "apicache": "^0.11.2", - "body-parser": "^1.18.0", + "apicache": "^1.1.0", + "body-parser": "^1.18.2", "cloudant": "^1.6.2", "cookie-parser": "^1.4.1", "cookieparser": "^0.1.0", "elapsed": "0.0.7", "errorhandler": "^1.4.3", - "express": "^4.15.4", - "express-session": "^1.15.5", + "express": "^4.15.5", + "express-session": "^1.15.6", "ftse": "^1.0.6", "gulp": "^3.9.1", "ical2json": "^1.2.0", "limitedarray": "git+https://gitlab.silvrtree.co.uk/martind2000/limitedArray.git", "logger": "0.0.1", - "method-override": "^2.3.5", - "morgan": "^1.7.0", + "method-override": "^2.3.10", + "morgan": "^1.9.0", "node-cron": "^1.2.1", - "pug": "^2.0.0-beta11", + "openweather-apis": "^3.3.2", + "pug": "^2.0.0-rc.4", "scrape": "^0.2.3", "string": "^3.3.1", + "sugar": "^2.0.4", "trend": "^0.3.0", "ultrases": "^0.1.3", "unstyler": "^0.2.2", - "ws": "^3.1.0" + "ws": "^3.2.0" }, "scripts": { "start": "node web-server.js", diff --git a/views/pages/slackV2-min.ejs b/views/pages/slackV2-min.ejs index b1160ab..e0f6354 100644 --- a/views/pages/slackV2-min.ejs +++ b/views/pages/slackV2-min.ejs @@ -20,7 +20,7 @@ <% include ../partials/links %> -
+
diff --git a/views/pages/slackV2.ejs b/views/pages/slackV2.ejs index 0020b01..2b9536c 100644 --- a/views/pages/slackV2.ejs +++ b/views/pages/slackV2.ejs @@ -20,7 +20,7 @@ <% include ../partials/links %> -
+
- + diff --git a/views/partials/head-min.ejs b/views/partials/head-min.ejs index 5c8473b..bfc9f78 100644 --- a/views/partials/head-min.ejs +++ b/views/partials/head-min.ejs @@ -9,9 +9,9 @@ - + - + diff --git a/views/partials/head.ejs b/views/partials/head.ejs index 6d07bb3..f55e5f9 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -9,8 +9,10 @@ - + + + diff --git a/web-server.js b/web-server.js index d0f0966..5f03b14 100644 --- a/web-server.js +++ b/web-server.js @@ -1,5 +1,6 @@ const express = require('express'); const path = require('path'); +const apicache = require('apicache'); const http = require('http'); const fx = require('./lib/fx'); @@ -13,7 +14,7 @@ const morgan = require('morgan'); const cookieParser = require('cookie-parser'); const session = require('express-session'); -const methodoverride = require('method-override'); +// const methodoverride = require('method-override'); const bodyparser = require('body-parser'); const errorhandler = require('errorhandler'); @@ -22,6 +23,8 @@ const jsonfile = require('jsonfile'); const Events = require('events'); const busEmitter = new Events.EventEmitter(); +const weather = require('./lib/weather'); + // busEmitter.on('update', today.broadcast); const WebSocket = require('ws'); @@ -44,7 +47,9 @@ const Fitbit = require('fitbit-oauth2'); const polys = require('./lib/poly.js'); const logger = require('log4js').getLogger('web-server'); -const apicache = require('apicache'); + + +logger.level = 'debug'; const app = express(); GLOBAL.lastcheck = 0; @@ -53,6 +58,9 @@ let btcCache = {}, fxCache = {}, trainCache = {}; const port = process.env.PORT || 9000; +// apicache.options({ 'debug': true }); +const cache = apicache.middleware; + // app.configure(function () { app.set('port', port); app.set('view engine', 'ejs'); @@ -64,18 +72,13 @@ app.use(session({ })); /* 'default', 'short', 'tiny', 'dev' */ -app.use(methodoverride()); +// app.use(methodoverride()); app.use(bodyparser.urlencoded({ 'extended': false })); // parse application/json app.use(bodyparser.json()); -// apicache.options({ 'debug': true }); -// const cache = apicache.middleware; - -// logger.debug(apicache); - app.use(function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'X-Requested-With'); @@ -107,14 +110,25 @@ app.get('/cinema/:id', events.getCinema); app.route('/poly').get(polys); app.get('/slack', function(req, res) { - // res.render('pages/slackV2-min'); - res.render('pages/slackV2'); + res.render('pages/slackV2-min'); + // res.render('pages/slackV2'); }); app.get('/temp', function(req, res) { res.render('pages/temp'); }); +app.get('/weather', /* cache('1 hour'),*/ (req, res) => { + weather.doGetOpenWeather() + .then((d) => { + res.send(d); + }).catch((e) => { + console.error(e); + res.status(500).send('There was an error!'); + }); +}); + + const tfile = 'fb-token.json'; // Instanciate a fitbit client. See example config below.