gulp work

This commit is contained in:
martind2000 2017-04-05 14:22:31 +01:00
parent eef699af4d
commit f919ea38e7
15 changed files with 231 additions and 337 deletions

View File

@ -1,174 +1,24 @@
{ {
"root": true, "plugins": [
//"parser": "babel-eslint", // https://github.com/babel/babel-eslint "react"
"env": { // http://eslint.org/docs/user-guide/configuring.html#specifying-environments
"browser": true, // browser global variables
"node": true // Node.js global variables and Node.js-specific rules
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": false,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": false,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"jsx": false
},
"rules": {
/**
* Strict mode
*/
// babel inserts "use strict"; for us
"strict": [2, "never"], // http://eslint.org/docs/rules/strict
/**
* ES6
*/
"no-var": 2, // http://eslint.org/docs/rules/no-var
"prefer-const": 0, // http://eslint.org/docs/rules/prefer-const
/**
* Variables
*/
"no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
"no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
"no-unused-vars": [2, { // http://eslint.org/docs/rules/no-unused-vars
"vars": "local",
"args": "none"
}],
"no-use-before-define": 0, // http://eslint.org/docs/rules/no-use-before-define
/**
* Possible errors
*/
"comma-dangle": [2, "never"], // http://eslint.org/docs/rules/comma-dangle
"no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
"no-console": 1, // http://eslint.org/docs/rules/no-console
"no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
"no-alert": 1, // http://eslint.org/docs/rules/no-alert
"no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
"no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
"no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
"no-empty": 2, // http://eslint.org/docs/rules/no-empty
"no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
"no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
"no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
"no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
"no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
"no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
"no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
"no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
"no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
"no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
"use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
"block-scoped-var": 0, // http://eslint.org/docs/rules/block-scoped-var
/**
* Best practices
*/
"consistent-return": 0, // http://eslint.org/docs/rules/consistent-return
"curly": [2, "multi-line"], // http://eslint.org/docs/rules/curly
"default-case": 2, // http://eslint.org/docs/rules/default-case
"dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
"allowKeywords": true
}],
"eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq
"guard-for-in": 0, // http://eslint.org/docs/rules/guard-for-in
"no-caller": 2, // http://eslint.org/docs/rules/no-caller
"no-else-return": 2, // http://eslint.org/docs/rules/no-else-return
"no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
"no-eval": 2, // http://eslint.org/docs/rules/no-eval
"no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
"no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
"no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
"no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
"no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
"no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
"no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
"no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
"no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
"no-new": 2, // http://eslint.org/docs/rules/no-new
"no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
"no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
"no-octal": 2, // http://eslint.org/docs/rules/no-octal
"no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
"no-param-reassign": 0, // http://eslint.org/docs/rules/no-param-reassign
"no-proto": 2, // http://eslint.org/docs/rules/no-proto
"no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
// "no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
"no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
"no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
"no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
"no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
"no-with": 2, // http://eslint.org/docs/rules/no-with
"radix": 2, // http://eslint.org/docs/rules/radix
"vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top
"wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
"yoda": 2, // http://eslint.org/docs/rules/yoda
/**
* Style
*/
"indent": [2, 2], // http://eslint.org/docs/rules/indent
"brace-style": [2, // http://eslint.org/docs/rules/brace-style
"1tbs", {
"allowSingleLine": true
}],
"quotes": [
2, "single", "avoid-escape" // http://eslint.org/docs/rules/quotes
], ],
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase "parserOptions": {
"properties": "never" "ecmaVersion": 6,
}], "sourceType": "module",
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing "ecmaFeatures": {
"before": false, "jsx": true
"after": true }
}], },
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style "env": {
"eol-last": 2, // http://eslint.org/docs/rules/eol-last "es6": true,
"func-names": 0, // http://eslint.org/docs/rules/func-names "browser": true,
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing "node": true,
"beforeColon": false, "mocha": true
"afterColon": true },
}], "extends": [
"new-cap": [2, { // http://eslint.org/docs/rules/new-cap "eslint:recommended",
"newIsCap": true "plugin:react/recommended"
}], ],
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines "rules": {
"max": 2 }
}], }
"no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
"no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
"no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
"no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces
"no-extra-parens": [2, "functions"], // http://eslint.org/docs/rules/no-extra-parens
"no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle
"one-var": [2, "never"], // http://eslint.org/docs/rules/one-var
"padded-blocks": [2, "never"], // http://eslint.org/docs/rules/padded-blocks
"semi": [2, "always"], // http://eslint.org/docs/rules/semi
"semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing
"before": false,
"after": true
}],
"keyword-spacing": [2, { // http://eslint.org/docs/rules/keyword-spacing
"before": true,
"after": true
}],
"space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks
"space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren
"space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops
"spaced-comment": [0, "always", { // http://eslint.org/docs/rules/spaced-comment
"exceptions": ["*"],
"markers": ["*"]
}]
}
}

View File

@ -25,7 +25,6 @@
d: 4 d: 4
}]; }];
MicroEvent.mixin(this);
let self = this; let self = this;
let addDays = function(myDate, days) { let addDays = function(myDate, days) {
@ -135,16 +134,6 @@
tick(); tick();
get_weather(); get_weather();
// getNextTrainTime('dbe', 'glq');
// getNextTrainTime('glq', 'dbe');
// start 15 minute timer
_fastTimer = setInterval(function() {
// getNextTrainTime('dbe', 'glq');
// getNextTrainTime('glq', 'dbe');
}, (60000));
_slowTimer = setInterval(function() { _slowTimer = setInterval(function() {

View File

@ -2,15 +2,15 @@
@import "../../bower_components/mui/src/sass/mui/colors"; @import "../../bower_components/mui/src/sass/mui/colors";
// customize MUI variables // customize MUI variables
$mui-primary-color: mui-color('teal', '500'); $mui-primary-color: mui-color('blue-grey', '500');
$mui-primary-color-dark: mui-color('teal', '700'); $mui-primary-color-dark: mui-color('blue-grey', '700');
$mui-primary-color-light: mui-color('teal', '100'); $mui-primary-color-light: mui-color('blue-grey', '100');
$mui-accent-color: mui-color('deep-purple', '900'); $mui-accent-color: mui-color('deep-purple', '900');
$mui-accent-color-dark: mui-color('indigo', 'A100'); $mui-accent-color-dark: mui-color('indigo', 'A100');
$mui-accent-color-light: mui-color('indigo', 'A400'); $mui-accent-color-light: mui-color('indigo', 'A400');
$mui-base-font-family: 'Roboto Slab', "Helvetica Neue", Helvetica, Arial, Verdana,"Trebuchet MS"; $mui-base-font-family: 'Roboto Condensed', "Helvetica Neue", Helvetica, Arial, Verdana,"Trebuchet MS";
// import MUI SASS // import MUI SASS
@import "../../bower_components/mui/src/sass/mui"; @import "../../bower_components/mui/src/sass/mui";

20
bower.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "silvergit",
"description": "silvergit",
"main": "web-server.js",
"authors": [
"Martin Donnelly"
],
"license": "ISC",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
}
}

2
fonts.list Normal file
View File

@ -0,0 +1,2 @@
Roboto+Slab
Roboto+Condensed

View File

@ -18,7 +18,7 @@ let filePath = {
build_dir: 'live' build_dir: 'live'
}; };
let dest = 'live'; let dest = 'app/live';
let fontOptions = { }; let fontOptions = { };
@ -50,7 +50,7 @@ gulp.task('appJS', function() {
loops: true, // Optimize loops loops: true, // Optimize loops
unused: true, // Drop unused variables/functions unused: true, // Drop unused variables/functions
hoist_funs: true, // Hoist function declarations hoist_funs: true, // Hoist function declarations
hoist_vars: false, // Hoist variable declarations hoist_vars: true, // Hoist variable declarations
if_return: true, // Optimize if-s followed by return/continue if_return: true, // Optimize if-s followed by return/continue
join_vars: true, // Join var declarations join_vars: true, // Join var declarations
cascade: true, // Try to cascade `right` into `left` in sequences cascade: true, // Try to cascade `right` into `left` in sequences
@ -61,18 +61,32 @@ gulp.task('appJS', function() {
.pipe(gulp.dest(dest + '/js')); .pipe(gulp.dest(dest + '/js'));
}); });
gulp.task('customMUI', function() {
return gulp.src(['app/css/custom.scss'])
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
//.pipe(cssnano())
.pipe(rename('mui.custom.css'))
.pipe(gulp.dest(dest + '/css'));
});
gulp.task('vendor', function() { gulp.task('vendor', function() {
return gulp.src([ return gulp.src([
'app/libs/zepto.min.js', 'bower_components/zepto/zepto.min.js',
'app/libs/microevent.js', 'bower_components/ejs/ejs.min.js',
'app/libs/ejs.js', 'bower_components/underscore/underscore-min.js',
'app/libs/underscore.js', 'bower_components/backbone/backbone-min.js'
'app/libs/backbone.js'
]) ])
.pipe(concat('vendor.js')) .pipe(concat('vendor.js'))
.pipe(uglify({mangle: false})) .pipe(uglify({mangle: false}))
.pipe(gulp.dest(dest + '/js')); .pipe(gulp.dest(dest + '/js'));
}); });
gulp.task('fonts', function() {
return gulp.src('./fonts.list')
.pipe(googleWebFonts(fontOptions))
.pipe(gulp.dest(dest + '/fonts'))
;
});
gulp.task('default', ['appJS', 'vendor']); gulp.task('default', ['appJS', 'vendor', 'customMUI', 'fonts']);

View File

@ -1,52 +1,51 @@
var http = require('http'); let http = require('http');
var btcCache = {}; let btcCache = {};
exports.doBTC = function (req,res) { exports.doBTC = function(req, res) {
console.log('Bitcoin request'); console.log('Bitcoin request');
function btcQuery(callback, r) { function btcQuery(callback, r) {
var req = r; var req = r;
var options = { var options = {
host: 'api.coindesk.com', host: 'api.coindesk.com',
// port: 80, // port: 80,
path: '/v1/bpi/currentprice.json', path: '/v1/bpi/currentprice.json',
// method: 'GET', // method: 'GET',
headers: { headers: {
/* 'Content-Type': 'application/json', /* 'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)*/ 'Content-Length': Buffer.byteLength(data)*/
} }
}; };
try { try {
http.request(options).on('response', function (response) { http.request(options).on('response', function(response) {
var data = ''; var data = '';
response.on("data", function (chunk) { response.on('data', function(chunk) {
data += chunk; data += chunk;
}); });
response.on('end', function () { response.on('end', function() {
callback(JSON.parse(data), r); callback(JSON.parse(data), r);
}); });
response.on('error', function(e) { response.on('error', function(e) {
console.error(e); console.error(e);
}); });
}).end(); }).end();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
} }
var now = new Date(); let now = new Date();
if (now - GLOBAL.lastcheck > (59000 )) { if (now - GLOBAL.lastcheck > (59000 )) {
btcQuery(function (a, b) { btcQuery(function(a) {
// console.log(a); // console.log(a);
console.log('Got btc data.') console.log('Got btc data.');
btcCache = a; btcCache = a;
GLOBAL.lastcheck = now; GLOBAL.lastcheck = now;
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(btcCache)); res.end(JSON.stringify(btcCache));
}, res) }, res);
} else {
console.log('Using cache');
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(btcCache));
} }
else { };
console.log("Using cache");
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(btcCache));
}
};

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,16 @@
var request = require('request'); const request = require('request')
var log4js = require('log4js'); const log4js = require('log4js')
var logger = log4js.getLogger(); const logger = log4js.getLogger()
var STRING = require('string'); const STRING = require('string')
var util = require('util'); let util = require('util')
var Elapsed = require('elapsed'); const Elapsed = require('elapsed')
require('sugar-date'); require('sugar-date');
function processICAL(ical) { function processICAL(ical) {
'use strict'; 'use strict';
logger.info('+ processICAL'); logger.info('+ processICAL');
var workingBlock = []; let workingBlock = []
var segments = { const segments = {
meetingStartID: 'DTSTART;TZID=Europe/London:', meetingStartID: 'DTSTART;TZID=Europe/London:',
meetingStartAlt: 'DTSTART:', meetingStartAlt: 'DTSTART:',
meetingStartAltOther: 'DTSTART;VALUE=DATE:', meetingStartAltOther: 'DTSTART;VALUE=DATE:',
@ -24,38 +24,38 @@ function processICAL(ical) {
beginAlarm: 'BEGIN:VALARM', beginAlarm: 'BEGIN:VALARM',
endAlarm: 'END:VALARM', endAlarm: 'END:VALARM',
recur: 'RRULE:' recur: 'RRULE:'
}; }
var rules = ['FREQ','WKST','UNTIL','BYMONTH','BYMONTHDAY','INTERVAL','BYDAY']; const rules = ['FREQ', 'WKST', 'UNTIL', 'BYMONTH', 'BYMONTHDAY', 'INTERVAL', 'BYDAY']
function nThDayOfMonth(monthsAhead, wantedDay) { function nThDayOfMonth(monthsAhead, wantedDay) {
var now = new Date(); const now = new Date()
for(var t=0; t < monthsAhead; t++) { for(let t=0; t < monthsAhead; t++) {
} }
} }
function processRecurrence(workBlock) { function processRecurrence(workBlock) {
var _workBlock = workBlock; let _workBlock = workBlock
// logger.debug('Processing recurrence...'); // logger.debug('Processing recurrence...');
// logger.debug('Processing recurrence...'); // logger.debug('Processing recurrence...');
var 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}
var blocks=[];
var now = new Date();
var day = now.getDate();
var dayNum = now.getDay();
var month = now.getMonth();
var year = now.getFullYear();
var recurSettings = {freq:null, wkst:null, until:null, bymonth:null, bymonthday:null, interval:null, byday:null}; const now = new Date()
const day = now.getDate()
const dayNum = now.getDay()
const month = now.getMonth()
const year = now.getFullYear()
var firstSplit = _workBlock.recur.split(';'); let recurSettings = {freq: null, wkst: null, until: null, bymonth: null, bymonthday: null, interval: null, byday: null}
for (var t=0; t< firstSplit.length;t++) const firstSplit = _workBlock.recur.split(';')
for (let t=0; t< firstSplit.length; t++)
{ {
var ws = firstSplit[t].split('='); const ws = firstSplit[t].split('=')
if (rules.indexOf(ws[0]) > -1) { if (rules.indexOf(ws[0]) > -1) {
recurSettings[ws[0].toLowerCase()] = ws[1]; recurSettings[ws[0].toLowerCase()] = ws[1];
} }
@ -76,18 +76,17 @@ function processICAL(ical) {
if (recurSettings.freq !== null) { if (recurSettings.freq !== null) {
// logger.debug(_workBlock); // logger.debug(_workBlock);
var origStart, origEnd, distance, newStart, newEnd; let origStart, origEnd, distance, newStart, newEnd
origStart = Date.create(_workBlock.dtstart); origStart = Date.create(_workBlock.dtstart);
origEnd = Date.create(_workBlock.dtend); origEnd = Date.create(_workBlock.dtend);
var _d = origStart.getDate(); const _d = origStart.getDate()
var _m = origStart.getMonth(); const _m = origStart.getMonth()
var _h = origStart.getHours(); const _h = origStart.getHours()
var _min = origStart.getMinutes(); const _min = origStart.getMinutes()
var _secs = origStart.getSeconds(); const _secs = origStart.getSeconds()
distance = origEnd - origStart; distance = origEnd - origStart;
if (recurSettings.freq === 'YEARLY') { if (recurSettings.freq === 'YEARLY') {
if (recurSettings.bymonth !== null && recurSettings.bymonthday !== null) { if (recurSettings.bymonth !== null && recurSettings.bymonthday !== null) {
@ -122,10 +121,10 @@ function processICAL(ical) {
} }
if (recurSettings.freq === 'WEEKLY' && recurSettings.interval === null) { if (recurSettings.freq === 'WEEKLY' && recurSettings.interval === null) {
var byDayBit = recurSettings.byday.split(',')[0]; const byDayBit = recurSettings.byday.split(',')[0]
var byDayNumber = weekBits[byDayBit]; const byDayNumber = weekBits[byDayBit]
if (byDayNumber >= dayNum) { if (byDayNumber >= dayNum) {
var daysAdded = byDayNumber - dayNum; const daysAdded = byDayNumber - dayNum
newStart = Date.create().set({year:year, month: month , day: day, hour:_h, minutes:_min, seconds:_secs}).addDays(daysAdded); newStart = Date.create().set({year:year, month: month , day: day, hour:_h, minutes:_min, seconds:_secs}).addDays(daysAdded);
newEnd = Date.create(newStart).addMilliseconds(distance); newEnd = Date.create(newStart).addMilliseconds(distance);
_workBlock.dtstart = newStart; _workBlock.dtstart = newStart;
@ -140,8 +139,8 @@ function processICAL(ical) {
} }
function processBlock(block) { function processBlock(block) {
var _wb; let _wb
var workBlock = { let workBlock = {
summary: '', summary: '',
dtstart: null, dtstart: null,
dtend: null, dtend: null,
@ -151,9 +150,9 @@ function processICAL(ical) {
duration: 0, duration: 0,
combined: '', combined: '',
recur: null recur: null
}; }
var alarmFlag = false, ws, blockStep; let alarmFlag = false, ws, blockStep
for (var step = 0; step < block.length; step++) { for (let step = 0; step < block.length; step++) {
blockStep = block[step]; blockStep = block[step];
if (blockStep.indexOf(segments.recur) >= 0) { if (blockStep.indexOf(segments.recur) >= 0) {
workBlock.recur = STRING(block[step].split(segments.recur)[1]).collapseWhitespace().s; workBlock.recur = STRING(block[step].split(segments.recur)[1]).collapseWhitespace().s;
@ -189,7 +188,6 @@ function processICAL(ical) {
workBlock.dtend = Date.create(ws); workBlock.dtend = Date.create(ws);
} }
if (blockStep.indexOf(segments.meetingDescID) >= 0) { if (blockStep.indexOf(segments.meetingDescID) >= 0) {
if (!alarmFlag) { if (!alarmFlag) {
workBlock.description = STRING(block[step].split(segments.meetingDescID)[1]).collapseWhitespace().s; workBlock.description = STRING(block[step].split(segments.meetingDescID)[1]).collapseWhitespace().s;
@ -200,7 +198,6 @@ function processICAL(ical) {
} }
} }
// We have to check recuring stuff before the cron stuff is processed. // We have to check recuring stuff before the cron stuff is processed.
if (workBlock.recur !== null) { if (workBlock.recur !== null) {
@ -219,8 +216,8 @@ function processICAL(ical) {
//logger.debug(workBlock); //logger.debug(workBlock);
if (workBlock.dtstart !== null) { if (workBlock.dtstart !== null) {
workBlock.timeStart = workBlock.dtstart.format('{24hr}:{mm}:{ss}'); workBlock.timeStart = workBlock.dtstart.format('{24hr}:{mm}:{ss}');
workBlock.combined = '<em>' + workBlock.timeStart + '</em> - '; workBlock.combined = `<em>${workBlock.timeStart}</em> - '`;
workBlock.long = '<em>' + workBlock.dtstart.format('{Weekday}') +', ' + workBlock.timeStart + '</em> - '; workBlock.long = `<em>${workBlock.dtstart.format('{Weekday}')}, ${workBlock.timeStart}</em> - `;
} }
workBlock.combined = workBlock.combined + workBlock.summary; workBlock.combined = workBlock.combined + workBlock.summary;
workBlock.longcombined = workBlock.long + workBlock.summary; workBlock.longcombined = workBlock.long + workBlock.summary;
@ -228,7 +225,7 @@ function processICAL(ical) {
workBlock.timeEnd = workBlock.dtend.format('{24hr}:{mm}:{ss}'); workBlock.timeEnd = workBlock.dtend.format('{24hr}:{mm}:{ss}');
} }
if (workBlock.dtstart !== null && workBlock.dtend !== null) { if (workBlock.dtstart !== null && workBlock.dtend !== null) {
var elapsedTime = new Elapsed(workBlock.dtstart, workBlock.dtend); const elapsedTime = new Elapsed(workBlock.dtstart, workBlock.dtend)
workBlock.duration = elapsedTime.optimal; workBlock.duration = elapsedTime.optimal;
workBlock.combined = workBlock.combined + ', ' + elapsedTime.optimal; workBlock.combined = workBlock.combined + ', ' + elapsedTime.optimal;
workBlock.longcombined = workBlock.longcombined + ', ' + elapsedTime.optimal; workBlock.longcombined = workBlock.longcombined + ', ' + elapsedTime.optimal;
@ -237,14 +234,16 @@ function processICAL(ical) {
return workBlock; return workBlock;
} }
var lines = ical.split('\r\n'), l = lines.length, counter = 0; const lines = ical.split('\r\n'), l = lines.length
let counter = 0
var alarmed = false; let alarmed = false
while (counter < l) { while (counter < l) {
if (lines[counter].indexOf(segments.begin) < 0) { if (lines[counter].indexOf(segments.begin) < 0) {
counter++; counter++;
} else { } else {
var subcounter = 0, subBlock = []; let subcounter = 0
const subBlock = []
alarmed = false; alarmed = false;
while (subcounter < 75) { while (subcounter < 75) {
if (lines[counter + subcounter].indexOf(segments.end) < 0) { if (lines[counter + subcounter].indexOf(segments.end) < 0) {
@ -265,7 +264,7 @@ function processICAL(ical) {
} }
} }
counter = counter + subcounter; counter = counter + subcounter;
var b = processBlock(subBlock); const b = processBlock(subBlock)
if (Array.isArray(b)) { if (Array.isArray(b)) {
logger.error('!returned an array...'); logger.error('!returned an array...');
} else { } else {
@ -293,11 +292,11 @@ module.exports = {
getTodaysSimple: function() { getTodaysSimple: function() {
'use strict'; 'use strict';
logger.info('+ getTodaysSimple'); logger.info('+ getTodaysSimple');
var today = { const today = {
entries: [] entries: []
}; }
for (var t = 0; t < this.jsonBlock.length; t++) { for (let t = 0; t < this.jsonBlock.length; t++) {
if (this.jsonBlock[t].dtstart.isToday()) { if (this.jsonBlock[t].dtstart.isToday()) {
today.entries.push(this.jsonBlock[t]); today.entries.push(this.jsonBlock[t]);
@ -309,11 +308,11 @@ module.exports = {
getTomorrow: function() { getTomorrow: function() {
'use strict'; 'use strict';
logger.info('+ getTomorrow'); logger.info('+ getTomorrow');
var today = { const today = {
entries: [] entries: []
}; }
for (var t = 0; t < this.jsonBlock.length; t++) { for (let t = 0; t < this.jsonBlock.length; t++) {
if (this.jsonBlock[t].dtstart.isTomorrow()) { if (this.jsonBlock[t].dtstart.isTomorrow()) {
today.entries.push(this.jsonBlock[t]); today.entries.push(this.jsonBlock[t]);
@ -325,10 +324,10 @@ module.exports = {
getWeek: function() { getWeek: function() {
'use strict'; 'use strict';
logger.info('+ getWeek'); logger.info('+ getWeek');
var today = { const today = {
entries: [] entries: []
}; }
var now, twoDays, sevenDays; let now, twoDays, sevenDays
now = Date.create('today'); now = Date.create('today');
// logger.debug(now); // logger.debug(now);
@ -338,7 +337,7 @@ module.exports = {
// logger.debug(now, twoDays, sevenDays); // logger.debug(now, twoDays, sevenDays);
for (var t = 0; t < this.jsonBlock.length; t++) { for (let t = 0; t < this.jsonBlock.length; t++) {
if (this.jsonBlock[t].dtstart.isBetween(twoDays, sevenDays)) { if (this.jsonBlock[t].dtstart.isBetween(twoDays, sevenDays)) {
today.entries.push(this.jsonBlock[t]); today.entries.push(this.jsonBlock[t]);
@ -350,12 +349,12 @@ module.exports = {
getTodaysMeetings: function() { getTodaysMeetings: function() {
'use strict'; 'use strict';
logger.info('+ getTodaysMeetings'); logger.info('+ getTodaysMeetings');
var today = { const today = {
previous: [], upcoming: [], current: {} previous: [], upcoming: [], current: {}
}; }
var now = new Date(); const now = new Date()
for (var t = 0; t < this.jsonBlock.length; t++) { for (let t = 0; t < this.jsonBlock.length; t++) {
if (this.jsonBlock[t].dtstart.isToday()) { if (this.jsonBlock[t].dtstart.isToday()) {
if (this.jsonBlock[t].dtstart.isAfter(now)) { if (this.jsonBlock[t].dtstart.isAfter(now)) {
@ -374,7 +373,7 @@ module.exports = {
return today; return today;
}, getSimpleCalV2: function(url, cb) { }, getSimpleCalV2: function(url, cb) {
'use strict'; 'use strict';
var self = this; const self = this
// Var calJson = []; // Var calJson = [];
try { try {
@ -388,7 +387,7 @@ module.exports = {
self.jsonBlock = processICAL(body); self.jsonBlock = processICAL(body);
// logger.debug(self.jsonBlock); // logger.debug(self.jsonBlock);
var st = self.getTodaysSimple(); const st = self.getTodaysSimple()
if (typeof cb === 'function') { if (typeof cb === 'function') {
cb(st); cb(st);
@ -405,7 +404,7 @@ module.exports = {
}, getSimpleCalV3: function(url) { }, getSimpleCalV3: function(url) {
'use strict'; 'use strict';
var self = this; const self = this
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
try { try {
@ -419,7 +418,7 @@ module.exports = {
self.jsonBlock = processICAL(body); self.jsonBlock = processICAL(body);
// logger.debug(self.jsonBlock); // logger.debug(self.jsonBlock);
var st = self.getTodaysSimple(); const st = self.getTodaysSimple()
return resolve(st); return resolve(st);
}, function(error, response, body) { }, function(error, response, body) {
@ -440,9 +439,9 @@ module.exports = {
}, getAdvancedCalV3: function(url) { }, getAdvancedCalV3: function(url) {
'use strict'; 'use strict';
var self = this; const self = this
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
try { try {
request(url, function(err, res, body) { request(url, function(err, res, body) {
if (err) { if (err) {
@ -454,12 +453,11 @@ module.exports = {
self.jsonBlock = processICAL(body); self.jsonBlock = processICAL(body);
// logger.debug(self.jsonBlock); // logger.debug(self.jsonBlock);
var st = self.getTodaysSimple().entries; const st = self.getTodaysSimple().entries
var tom = self.getTomorrow().entries; const tom = self.getTomorrow().entries
var week = self.getWeek().entries; const week = self.getWeek().entries
const obj = {today: st, tomorrow: tom, week: week}
var obj = {today:st, tomorrow:tom, week:week};
logger.debug(obj); logger.debug(obj);
return resolve(obj); return resolve(obj);

View File

@ -5,15 +5,21 @@
* Time: 23:22 * Time: 23:22
* *
*/ */
var quotes = require('./quotes'); const calHandler = require('./calHandler');
const logger = require('log4js').getLogger();
for (let t = 0; t < calHandler.calendars.length; t++) {
quotes.GetQuotes() calHandler.getAdvancedCalV3(calHandler.calendars[t])
.then((d) => { .then((d) => {
'use strict'; 'use strict';
console.log('Quotes: ', d); /*
}) todayCache.data.cal.today = todayCache.data.cal.today.concat(d.today);
.catch((e)=> { todayCache.data.cal.tomorrow = todayCache.data.cal.tomorrow.concat(d.tomorrow);
'use strict'; todayCache.data.cal.week = todayCache.data.cal.week.concat(d.week);
console.error(e); */
}); })
.catch((e) => {
'use strict';
logger.error(e);
});
}

View File

@ -4,11 +4,20 @@
"devDependencies": { "devDependencies": {
"babel": "^6.23.0", "babel": "^6.23.0",
"babel-core": "^6.24.0", "babel-core": "^6.24.0",
"babel-eslint": "^7.2.0", "babel-eslint": "^7.2.1",
"babel-preset-es2015": "^6.24.0", "babel-preset-es2015": "^6.24.0",
"cheerio": "^0.20.0", "cheerio": "^0.20.0",
"dateformat": "^1.0.12", "dateformat": "^1.0.12",
"ejs": "^2.3.4", "ejs": "^2.3.4",
"eslint": "^3.18.0",
"eslint-config-defaults": "^9.0.0",
"eslint-config-standard": "^7.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^6.10.3",
"eslint-plugin-standard": "^2.1.1",
"eslint-watch": "^3.0.1",
"fitbit-oauth2": "0.0.1", "fitbit-oauth2": "0.0.1",
"forecast.io": "0.0.9", "forecast.io": "0.0.9",
"gulp-autoprefixer": "^3.1.1", "gulp-autoprefixer": "^3.1.1",

View File

@ -32,10 +32,8 @@ const SocketHandler = require('./lib/wshandlerv2');
let webSocket = new SocketHandler(busEmitter, wss); let webSocket = new SocketHandler(busEmitter, wss);
// train = require('lib/train') // train = require('lib/train')
/* ,submit = require('./routes/mongo/submit') */ /* ,submit = require('./routes/mongo/submit') */
;
let fs = require('fs'); let fs = require('fs');
const config = require('./config/config.json'); const config = require('./config/config.json');

View File

@ -1,4 +1,4 @@
<% include ../partials/head %> <% include ../partials/head-min %>
<!-- Slack - I have plenty of talent and vision I just don't give a damn --> <!-- Slack - I have plenty of talent and vision I just don't give a damn -->
<header id="header"> <header id="header">
<div class="mui-appbar mui--appbar-line-height"> <div class="mui-appbar mui--appbar-line-height">
@ -370,23 +370,15 @@
<script src="live/js/vendor.js"></script> <script src="live/js/vendor.js"></script>
<script src="live/js/app.js"></script> <script src="live/js/app.js"></script>
<script> <script>
(){ (function (w) {
bitcoin = new Bitcoin({model: new BitcoinModel()}); w.bitcoin = new Bitcoin({model: new BitcoinModel()});
fx = new FxView({model: new FxModel()}); w.fx = new FxView({model: new FxModel()});
w.dbqglqView = new TrainView({model: new TrainModel({from: 'dbe', to: 'glq'})});
w.glqdbeView = new TrainView({model: new TrainModel({from: 'glq', to: 'dbe'})});
w.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
// dbeglqModel = new TrainModel({from:'dbe', to:'glq'}); })(window);
/*
glqdbeModel = new TrainModel({from:'glq', to:'dbe'});
glqhymModel = new TrainModel({from:'glq', to:'hym'});
hymglqModel = new TrainModel({from:'hym', to:'glq'});
*/
dbqglqView = new TrainView({model: new TrainModel({from:'dbe', to:'glq'})});
glqdbeView = new TrainView({model: new TrainModel({from:'glq', to:'dbe'})});
glqhymView = new TrainView({model: new TrainModel({from:'glq', to:'hym'})});
hymglqView = new TrainView({model: new TrainModel({from:'hym', to:'glq'})});
}();
</script> </script>
</html> </html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="viewport" content="width=360; initial-scale=1;">
<meta charset="UTF-8">
<title>Events</title>
<meta name="Author" content=""/>
<link rel="stylesheet" href="live/fonts/fonts.css">
<link href="live/css/mui.custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>

View File

@ -131,7 +131,7 @@ app.route('/poly').get(polys);
});*/ });*/
app.get('/slack', function(req, res) { app.get('/slack', function(req, res) {
res.render('pages/slackV2'); res.render('pages/slackV2-min');
}); });
app.get('/temp', function(req, res) { app.get('/temp', function(req, res) {