gulp work
This commit is contained in:
parent
eef699af4d
commit
f919ea38e7
192
.eslintrc.json
192
.eslintrc.json
@ -1,174 +1,24 @@
|
||||
{
|
||||
"root": true,
|
||||
//"parser": "babel-eslint", // https://github.com/babel/babel-eslint
|
||||
"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
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase
|
||||
"properties": "never"
|
||||
}],
|
||||
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
|
||||
"before": false,
|
||||
"after": true
|
||||
}],
|
||||
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
|
||||
"eol-last": 2, // http://eslint.org/docs/rules/eol-last
|
||||
"func-names": 0, // http://eslint.org/docs/rules/func-names
|
||||
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
|
||||
"beforeColon": false,
|
||||
"afterColon": true
|
||||
}],
|
||||
"new-cap": [2, { // http://eslint.org/docs/rules/new-cap
|
||||
"newIsCap": true
|
||||
}],
|
||||
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
|
||||
"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": ["*"]
|
||||
}]
|
||||
}
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
11
app/app.js
11
app/app.js
@ -25,7 +25,6 @@
|
||||
d: 4
|
||||
}];
|
||||
|
||||
MicroEvent.mixin(this);
|
||||
let self = this;
|
||||
|
||||
let addDays = function(myDate, days) {
|
||||
@ -135,16 +134,6 @@
|
||||
|
||||
tick();
|
||||
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() {
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
@import "../../bower_components/mui/src/sass/mui/colors";
|
||||
|
||||
// customize MUI variables
|
||||
$mui-primary-color: mui-color('teal', '500');
|
||||
$mui-primary-color-dark: mui-color('teal', '700');
|
||||
$mui-primary-color-light: mui-color('teal', '100');
|
||||
$mui-primary-color: mui-color('blue-grey', '500');
|
||||
$mui-primary-color-dark: mui-color('blue-grey', '700');
|
||||
$mui-primary-color-light: mui-color('blue-grey', '100');
|
||||
|
||||
$mui-accent-color: mui-color('deep-purple', '900');
|
||||
$mui-accent-color-dark: mui-color('indigo', 'A100');
|
||||
$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 "../../bower_components/mui/src/sass/mui";
|
||||
|
20
bower.json
Normal file
20
bower.json
Normal 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
2
fonts.list
Normal file
@ -0,0 +1,2 @@
|
||||
Roboto+Slab
|
||||
Roboto+Condensed
|
30
gulpfile.js
30
gulpfile.js
@ -18,7 +18,7 @@ let filePath = {
|
||||
build_dir: 'live'
|
||||
};
|
||||
|
||||
let dest = 'live';
|
||||
let dest = 'app/live';
|
||||
|
||||
|
||||
let fontOptions = { };
|
||||
@ -50,7 +50,7 @@ gulp.task('appJS', function() {
|
||||
loops: true, // Optimize loops
|
||||
unused: true, // Drop unused variables/functions
|
||||
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
|
||||
join_vars: true, // Join var declarations
|
||||
cascade: true, // Try to cascade `right` into `left` in sequences
|
||||
@ -61,18 +61,32 @@ gulp.task('appJS', function() {
|
||||
.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() {
|
||||
return gulp.src([
|
||||
'app/libs/zepto.min.js',
|
||||
'app/libs/microevent.js',
|
||||
'app/libs/ejs.js',
|
||||
'app/libs/underscore.js',
|
||||
'app/libs/backbone.js'
|
||||
'bower_components/zepto/zepto.min.js',
|
||||
'bower_components/ejs/ejs.min.js',
|
||||
'bower_components/underscore/underscore-min.js',
|
||||
'bower_components/backbone/backbone-min.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'))
|
||||
;
|
||||
});
|
||||
|
||||
gulp.task('default', ['appJS', 'vendor']);
|
||||
gulp.task('default', ['appJS', 'vendor', 'customMUI', 'fonts']);
|
71
lib/btc.js
71
lib/btc.js
@ -1,52 +1,51 @@
|
||||
var http = require('http');
|
||||
var btcCache = {};
|
||||
exports.doBTC = function (req,res) {
|
||||
console.log('Bitcoin request');
|
||||
function btcQuery(callback, r) {
|
||||
var req = r;
|
||||
var options = {
|
||||
host: 'api.coindesk.com',
|
||||
let http = require('http');
|
||||
let btcCache = {};
|
||||
exports.doBTC = function(req, res) {
|
||||
console.log('Bitcoin request');
|
||||
function btcQuery(callback, r) {
|
||||
var req = r;
|
||||
var options = {
|
||||
host: 'api.coindesk.com',
|
||||
// port: 80,
|
||||
path: '/v1/bpi/currentprice.json',
|
||||
path: '/v1/bpi/currentprice.json',
|
||||
// method: 'GET',
|
||||
headers: {
|
||||
headers: {
|
||||
/* 'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(data)*/
|
||||
|
||||
}
|
||||
};
|
||||
try {
|
||||
http.request(options).on('response', function (response) {
|
||||
var data = '';
|
||||
response.on("data", function (chunk) {
|
||||
data += chunk;
|
||||
try {
|
||||
http.request(options).on('response', function(response) {
|
||||
var data = '';
|
||||
response.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
response.on('end', function () {
|
||||
callback(JSON.parse(data), r);
|
||||
response.on('end', function() {
|
||||
callback(JSON.parse(data), r);
|
||||
});
|
||||
response.on('error', function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
console.error(e);
|
||||
});
|
||||
}).end();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
var now = new Date();
|
||||
if (now - GLOBAL.lastcheck > (59000 )) {
|
||||
btcQuery(function (a, b) {
|
||||
let now = new Date();
|
||||
if (now - GLOBAL.lastcheck > (59000 )) {
|
||||
btcQuery(function(a) {
|
||||
// console.log(a);
|
||||
console.log('Got btc data.')
|
||||
btcCache = a;
|
||||
GLOBAL.lastcheck = now;
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(btcCache));
|
||||
}, res)
|
||||
console.log('Got btc data.');
|
||||
btcCache = a;
|
||||
GLOBAL.lastcheck = now;
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(btcCache));
|
||||
}, 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
@ -1,16 +1,16 @@
|
||||
var request = require('request');
|
||||
var log4js = require('log4js');
|
||||
var logger = log4js.getLogger();
|
||||
var STRING = require('string');
|
||||
var util = require('util');
|
||||
var Elapsed = require('elapsed');
|
||||
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');
|
||||
|
||||
function processICAL(ical) {
|
||||
'use strict';
|
||||
logger.info('+ processICAL');
|
||||
var workingBlock = [];
|
||||
var segments = {
|
||||
let workingBlock = []
|
||||
const segments = {
|
||||
meetingStartID: 'DTSTART;TZID=Europe/London:',
|
||||
meetingStartAlt: 'DTSTART:',
|
||||
meetingStartAltOther: 'DTSTART;VALUE=DATE:',
|
||||
@ -24,38 +24,38 @@ function processICAL(ical) {
|
||||
beginAlarm: 'BEGIN:VALARM',
|
||||
endAlarm: 'END:VALARM',
|
||||
recur: 'RRULE:'
|
||||
};
|
||||
}
|
||||
|
||||
var rules = ['FREQ','WKST','UNTIL','BYMONTH','BYMONTHDAY','INTERVAL','BYDAY'];
|
||||
const rules = ['FREQ', 'WKST', 'UNTIL', 'BYMONTH', 'BYMONTHDAY', 'INTERVAL', 'BYDAY']
|
||||
|
||||
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) {
|
||||
var _workBlock = workBlock;
|
||||
let _workBlock = workBlock
|
||||
// logger.debug('Processing recurrence...');
|
||||
// logger.debug('Processing recurrence...');
|
||||
var 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();
|
||||
const weekBits = {'SU': 0, 'MO': 1, 'TU': 2, 'WE': 3, 'TH': 4, 'FR': 5, 'SA': 6}
|
||||
|
||||
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) {
|
||||
recurSettings[ws[0].toLowerCase()] = ws[1];
|
||||
}
|
||||
@ -76,18 +76,17 @@ function processICAL(ical) {
|
||||
if (recurSettings.freq !== null) {
|
||||
|
||||
// logger.debug(_workBlock);
|
||||
var origStart, origEnd, distance, newStart, newEnd;
|
||||
let origStart, origEnd, distance, newStart, newEnd
|
||||
|
||||
origStart = Date.create(_workBlock.dtstart);
|
||||
origEnd = Date.create(_workBlock.dtend);
|
||||
var _d = origStart.getDate();
|
||||
var _m = origStart.getMonth();
|
||||
var _h = origStart.getHours();
|
||||
var _min = origStart.getMinutes();
|
||||
var _secs = origStart.getSeconds();
|
||||
const _d = origStart.getDate()
|
||||
const _m = origStart.getMonth()
|
||||
const _h = origStart.getHours()
|
||||
const _min = origStart.getMinutes()
|
||||
const _secs = origStart.getSeconds()
|
||||
distance = origEnd - origStart;
|
||||
|
||||
|
||||
if (recurSettings.freq === 'YEARLY') {
|
||||
|
||||
if (recurSettings.bymonth !== null && recurSettings.bymonthday !== null) {
|
||||
@ -122,10 +121,10 @@ function processICAL(ical) {
|
||||
}
|
||||
|
||||
if (recurSettings.freq === 'WEEKLY' && recurSettings.interval === null) {
|
||||
var byDayBit = recurSettings.byday.split(',')[0];
|
||||
var byDayNumber = weekBits[byDayBit];
|
||||
const byDayBit = recurSettings.byday.split(',')[0]
|
||||
const byDayNumber = weekBits[byDayBit]
|
||||
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);
|
||||
newEnd = Date.create(newStart).addMilliseconds(distance);
|
||||
_workBlock.dtstart = newStart;
|
||||
@ -140,8 +139,8 @@ function processICAL(ical) {
|
||||
}
|
||||
|
||||
function processBlock(block) {
|
||||
var _wb;
|
||||
var workBlock = {
|
||||
let _wb
|
||||
let workBlock = {
|
||||
summary: '',
|
||||
dtstart: null,
|
||||
dtend: null,
|
||||
@ -151,9 +150,9 @@ function processICAL(ical) {
|
||||
duration: 0,
|
||||
combined: '',
|
||||
recur: null
|
||||
};
|
||||
var alarmFlag = false, ws, blockStep;
|
||||
for (var step = 0; step < block.length; step++) {
|
||||
}
|
||||
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;
|
||||
@ -189,7 +188,6 @@ function processICAL(ical) {
|
||||
workBlock.dtend = Date.create(ws);
|
||||
}
|
||||
|
||||
|
||||
if (blockStep.indexOf(segments.meetingDescID) >= 0) {
|
||||
if (!alarmFlag) {
|
||||
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.
|
||||
|
||||
if (workBlock.recur !== null) {
|
||||
@ -219,8 +216,8 @@ function processICAL(ical) {
|
||||
//logger.debug(workBlock);
|
||||
if (workBlock.dtstart !== null) {
|
||||
workBlock.timeStart = workBlock.dtstart.format('{24hr}:{mm}:{ss}');
|
||||
workBlock.combined = '<em>' + workBlock.timeStart + '</em> - ';
|
||||
workBlock.long = '<em>' + workBlock.dtstart.format('{Weekday}') +', ' + workBlock.timeStart + '</em> - ';
|
||||
workBlock.combined = `<em>${workBlock.timeStart}</em> - '`;
|
||||
workBlock.long = `<em>${workBlock.dtstart.format('{Weekday}')}, ${workBlock.timeStart}</em> - `;
|
||||
}
|
||||
workBlock.combined = workBlock.combined + workBlock.summary;
|
||||
workBlock.longcombined = workBlock.long + workBlock.summary;
|
||||
@ -228,7 +225,7 @@ function processICAL(ical) {
|
||||
workBlock.timeEnd = workBlock.dtend.format('{24hr}:{mm}:{ss}');
|
||||
}
|
||||
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.combined = workBlock.combined + ', ' + elapsedTime.optimal;
|
||||
workBlock.longcombined = workBlock.longcombined + ', ' + elapsedTime.optimal;
|
||||
@ -237,14 +234,16 @@ function processICAL(ical) {
|
||||
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) {
|
||||
if (lines[counter].indexOf(segments.begin) < 0) {
|
||||
counter++;
|
||||
} else {
|
||||
var subcounter = 0, subBlock = [];
|
||||
let subcounter = 0
|
||||
const subBlock = []
|
||||
alarmed = false;
|
||||
while (subcounter < 75) {
|
||||
if (lines[counter + subcounter].indexOf(segments.end) < 0) {
|
||||
@ -265,7 +264,7 @@ function processICAL(ical) {
|
||||
}
|
||||
}
|
||||
counter = counter + subcounter;
|
||||
var b = processBlock(subBlock);
|
||||
const b = processBlock(subBlock)
|
||||
if (Array.isArray(b)) {
|
||||
logger.error('!returned an array...');
|
||||
} else {
|
||||
@ -293,11 +292,11 @@ module.exports = {
|
||||
getTodaysSimple: function() {
|
||||
'use strict';
|
||||
logger.info('+ getTodaysSimple');
|
||||
var today = {
|
||||
const today = {
|
||||
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()) {
|
||||
|
||||
today.entries.push(this.jsonBlock[t]);
|
||||
@ -309,11 +308,11 @@ module.exports = {
|
||||
getTomorrow: function() {
|
||||
'use strict';
|
||||
logger.info('+ getTomorrow');
|
||||
var today = {
|
||||
const today = {
|
||||
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()) {
|
||||
|
||||
today.entries.push(this.jsonBlock[t]);
|
||||
@ -325,10 +324,10 @@ module.exports = {
|
||||
getWeek: function() {
|
||||
'use strict';
|
||||
logger.info('+ getWeek');
|
||||
var today = {
|
||||
const today = {
|
||||
entries: []
|
||||
};
|
||||
var now, twoDays, sevenDays;
|
||||
}
|
||||
let now, twoDays, sevenDays
|
||||
|
||||
now = Date.create('today');
|
||||
// logger.debug(now);
|
||||
@ -338,7 +337,7 @@ module.exports = {
|
||||
|
||||
// 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)) {
|
||||
|
||||
today.entries.push(this.jsonBlock[t]);
|
||||
@ -350,12 +349,12 @@ module.exports = {
|
||||
getTodaysMeetings: function() {
|
||||
'use strict';
|
||||
logger.info('+ getTodaysMeetings');
|
||||
var today = {
|
||||
const today = {
|
||||
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.isAfter(now)) {
|
||||
@ -374,7 +373,7 @@ module.exports = {
|
||||
return today;
|
||||
}, getSimpleCalV2: function(url, cb) {
|
||||
'use strict';
|
||||
var self = this;
|
||||
const self = this
|
||||
|
||||
// Var calJson = [];
|
||||
try {
|
||||
@ -388,7 +387,7 @@ module.exports = {
|
||||
self.jsonBlock = processICAL(body);
|
||||
|
||||
// logger.debug(self.jsonBlock);
|
||||
var st = self.getTodaysSimple();
|
||||
const st = self.getTodaysSimple()
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
cb(st);
|
||||
@ -405,7 +404,7 @@ module.exports = {
|
||||
|
||||
}, getSimpleCalV3: function(url) {
|
||||
'use strict';
|
||||
var self = this;
|
||||
const self = this
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
try {
|
||||
@ -419,7 +418,7 @@ module.exports = {
|
||||
self.jsonBlock = processICAL(body);
|
||||
|
||||
// logger.debug(self.jsonBlock);
|
||||
var st = self.getTodaysSimple();
|
||||
const st = self.getTodaysSimple()
|
||||
|
||||
return resolve(st);
|
||||
}, function(error, response, body) {
|
||||
@ -440,9 +439,9 @@ module.exports = {
|
||||
|
||||
}, getAdvancedCalV3: function(url) {
|
||||
'use strict';
|
||||
var self = this;
|
||||
const self = this
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
try {
|
||||
request(url, function(err, res, body) {
|
||||
if (err) {
|
||||
@ -454,12 +453,11 @@ module.exports = {
|
||||
self.jsonBlock = processICAL(body);
|
||||
|
||||
// logger.debug(self.jsonBlock);
|
||||
var st = self.getTodaysSimple().entries;
|
||||
var tom = self.getTomorrow().entries;
|
||||
var week = self.getWeek().entries;
|
||||
const st = self.getTodaysSimple().entries
|
||||
const tom = self.getTomorrow().entries
|
||||
const week = self.getWeek().entries
|
||||
|
||||
|
||||
var obj = {today:st, tomorrow:tom, week:week};
|
||||
const obj = {today: st, tomorrow: tom, week: week}
|
||||
|
||||
logger.debug(obj);
|
||||
return resolve(obj);
|
||||
|
@ -5,15 +5,21 @@
|
||||
* Time: 23:22
|
||||
*
|
||||
*/
|
||||
var quotes = require('./quotes');
|
||||
const calHandler = require('./calHandler');
|
||||
const logger = require('log4js').getLogger();
|
||||
|
||||
|
||||
quotes.GetQuotes()
|
||||
.then((d) => {
|
||||
'use strict';
|
||||
console.log('Quotes: ', d);
|
||||
})
|
||||
.catch((e)=> {
|
||||
'use strict';
|
||||
console.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);
|
||||
});
|
||||
}
|
11
package.json
11
package.json
@ -4,11 +4,20 @@
|
||||
"devDependencies": {
|
||||
"babel": "^6.23.0",
|
||||
"babel-core": "^6.24.0",
|
||||
"babel-eslint": "^7.2.0",
|
||||
"babel-eslint": "^7.2.1",
|
||||
"babel-preset-es2015": "^6.24.0",
|
||||
"cheerio": "^0.20.0",
|
||||
"dateformat": "^1.0.12",
|
||||
"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",
|
||||
"forecast.io": "0.0.9",
|
||||
"gulp-autoprefixer": "^3.1.1",
|
||||
|
@ -32,10 +32,8 @@ const SocketHandler = require('./lib/wshandlerv2');
|
||||
let webSocket = new SocketHandler(busEmitter, wss);
|
||||
|
||||
|
||||
|
||||
// train = require('lib/train')
|
||||
/* ,submit = require('./routes/mongo/submit') */
|
||||
;
|
||||
|
||||
let fs = require('fs');
|
||||
const config = require('./config/config.json');
|
||||
|
@ -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 -->
|
||||
<header id="header">
|
||||
<div class="mui-appbar mui--appbar-line-height">
|
||||
@ -370,23 +370,15 @@
|
||||
<script src="live/js/vendor.js"></script>
|
||||
<script src="live/js/app.js"></script>
|
||||
<script>
|
||||
(){
|
||||
bitcoin = new Bitcoin({model: new BitcoinModel()});
|
||||
fx = new FxView({model: new FxModel()});
|
||||
(function (w) {
|
||||
w.bitcoin = new Bitcoin({model: new BitcoinModel()});
|
||||
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'});
|
||||
/*
|
||||
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'})});
|
||||
|
||||
}();
|
||||
})(window);
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
17
views/partials/head-min.ejs
Normal file
17
views/partials/head-min.ejs
Normal 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>
|
@ -131,7 +131,7 @@ app.route('/poly').get(polys);
|
||||
});*/
|
||||
|
||||
app.get('/slack', function(req, res) {
|
||||
res.render('pages/slackV2');
|
||||
res.render('pages/slackV2-min');
|
||||
});
|
||||
|
||||
app.get('/temp', function(req, res) {
|
||||
|
Loading…
Reference in New Issue
Block a user