diff --git a/app.js b/app.js index 623f7f2c..b63eacd6 100644 --- a/app.js +++ b/app.js @@ -14,7 +14,7 @@ const app = module.exports = express(); if (!process.env.SITE_URL) { - process.env.SITE_URL = (app.get('env') === 'production') ? + process.env.SITE_URL = app.get('env') === 'production' ? 'https://liftie.info' : 'http://locahost:3000'; } @@ -72,13 +72,13 @@ app.data = require('./lib/routes/data')(); require('./lib/routes')(app); app.run = function run() { - app.data.init(function(err) { + app.data.init(function (err) { if (err) { console.error(err); process.exit(1); return; } - http.createServer(app).listen(app.get('port'), function(){ + http.createServer(app).listen(app.get('port'), function () { console.log(`Running on: http://localhost:${app.get('port')}`); }); }); diff --git a/lib/checker.js b/lib/checker.js index cb8f3207..da5e4686 100644 --- a/lib/checker.js +++ b/lib/checker.js @@ -5,14 +5,13 @@ module.exports = checkNames; * Filters out the names that are not supported */ function checkNames(requested, valid, all) { - if(!requested) { + if (!requested) { return all; } if (typeof requested === 'string') { requested = requested.split(','); } - return requested.filter(function(item) { + return requested.filter(function (item) { return valid[item]; }); } - diff --git a/lib/cli/fetch.js b/lib/cli/fetch.js index 6b933de0..f6c03634 100644 --- a/lib/cli/fetch.js +++ b/lib/cli/fetch.js @@ -10,8 +10,7 @@ function fetchExample(resortId) { resort = require('../resorts/' + resortId + '/resort.json'); curl(resort.dataUrl || resort.api || resort.url, resortId); done = true; - } - catch (e) { + } catch (e) { console.error(resortId, 'is not a valid resort ID'); process.exit(1); } diff --git a/lib/cli/for-each-resort.js b/lib/cli/for-each-resort.js index 164e70d5..e07f1898 100644 --- a/lib/cli/for-each-resort.js +++ b/lib/cli/for-each-resort.js @@ -5,7 +5,7 @@ module.exports = forEachResort; function forEachResort(fn) { console.log('Reading:', lib); - readdir(lib, { withFileTypes: true }, function(err, dirents) { + readdir(lib, { withFileTypes: true }, function (err, dirents) { if (err) { console.error(err); process.exit(1); diff --git a/lib/cli/generate.js b/lib/cli/generate.js index 22da02d2..ccea839e 100644 --- a/lib/cli/generate.js +++ b/lib/cli/generate.js @@ -8,8 +8,7 @@ const curl = require('./curl'); const dirs = require('./dirs'); let fname; -const schema = [ - { +const schema = [{ name: 'id', description: 'Short name of the resort [acme]', type: 'string', @@ -81,8 +80,7 @@ if (program.json) { } execute(conf); }); -} -else { +} else { execute(); } @@ -118,7 +116,7 @@ function write(dst, json) { function copy(src, dst, params) { console.log('Generating %s...', dst); - fs.readFile(src, 'utf8', function(err, data) { + fs.readFile(src, 'utf8', function (err, data) { data = template(data)(params); fs.writeFileSync(dst, data); }); @@ -139,7 +137,7 @@ function execute(conf) { schema[2].before = splitHost; conf = conf || {}; prompt.override = conf; - prompt.addProperties(conf, schema, function(err) { + prompt.addProperties(conf, schema, function (err) { if (err) { console.error(err); process.exit(-1); diff --git a/lib/cli/noaa.js b/lib/cli/noaa.js index 19b5d305..f53d8055 100644 --- a/lib/cli/noaa.js +++ b/lib/cli/noaa.js @@ -9,7 +9,7 @@ let done = false; const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)'; -function points([ lon, lat ]) { +function points([lon, lat]) { function shorten(n) { return n.toFixed(4).replace(/0+$/, ''); } @@ -36,15 +36,15 @@ function noaaForResort(resortId, { overwrite }) { superagent(url) .accept('application/geo+json') .set('User-Agent', userAgent) - .then(function(res) { - const { body: { properties: { gridId, gridX, gridY} } } = res; + .then(function (res) { + const { body: { properties: { gridId, gridX, gridY } } } = res; const noaa = `${gridId}/${gridX},${gridY}`; if (overwrite) { descriptor.noaa = noaa; writeDescriptor(resortId, descriptor); } console.log(resortId, noaa); - }, function(e) { + }, function (e) { console.error('Cannot find NOAA station for:', resortId, e.response.text); }); } @@ -62,8 +62,7 @@ function writeDescriptor(resortId, descriptor) { function readDescriptor(resortId) { try { return require(`../resorts/${resortId}/resort.json`); - } - catch (e) { + } catch (e) { console.error(resortId, 'is not a valid resort ID'); process.exit(1); } diff --git a/lib/client/boot/service-worker.js b/lib/client/boot/service-worker.js index cadc9910..10c48f8f 100644 --- a/lib/client/boot/service-worker.js +++ b/lib/client/boot/service-worker.js @@ -2,7 +2,7 @@ module.exports = register; /* global navigator, console */ -function registrationHandler({scope, installing, waiting, active}) { +function registrationHandler({ scope, installing, waiting, active }) { console.log('SW', scope); if (installing) { diff --git a/lib/client/minimax/index.js b/lib/client/minimax/index.js index 6af72e31..a019e040 100644 --- a/lib/client/minimax/index.js +++ b/lib/client/minimax/index.js @@ -1,4 +1,4 @@ -module.exports=minimax; +module.exports = minimax; /** * @param {Array} elements list of affected element diff --git a/lib/client/resort/dom.js b/lib/client/resort/dom.js index c3b2c085..88ed8c79 100644 --- a/lib/client/resort/dom.js +++ b/lib/client/resort/dom.js @@ -4,7 +4,7 @@ function removeAllChildren(node) { } } -function next({nextElementSibling, nextSibling}) { +function next({ nextElementSibling, nextSibling }) { return nextElementSibling || nextSibling; } diff --git a/lib/client/resort/lifts.js b/lib/client/resort/lifts.js index ecc57e4d..e86e9211 100644 --- a/lib/client/resort/lifts.js +++ b/lib/client/resort/lifts.js @@ -29,7 +29,7 @@ function renderColorBar(node, percentage) { }); } -function render(node, {status, stats}) { +function render(node, { status, stats }) { renderStatus(node.querySelector('.lifts'), status); renderStats(node.querySelector('.summary'), stats); renderColorBar(node.querySelector('.summary-color-bar'), stats.percentage); diff --git a/lib/client/resort/webcams.js b/lib/client/resort/webcams.js index f63ca540..913456da 100644 --- a/lib/client/resort/webcams.js +++ b/lib/client/resort/webcams.js @@ -72,7 +72,7 @@ function render(div, webcams) { // .title // .notice - function initCam(cam, {source, image, name, notice}) { + function initCam(cam, { source, image, name, notice }) { cam.querySelector('a').setAttribute('href', source); cam.querySelector('img.active').setAttribute('src', image); cam.querySelector('img.inactive').setAttribute('src', ''); @@ -97,8 +97,7 @@ function render(div, webcams) { let cam; if (i < li.length) { cam = li[i]; - } - else { + } else { cam = ul.appendChild(li[0].cloneNode(true)); } initCam(cam.querySelector('.desktop'), webcam); diff --git a/lib/client/state/index.js b/lib/client/state/index.js index 67fa817a..6d565970 100644 --- a/lib/client/state/index.js +++ b/lib/client/state/index.js @@ -4,7 +4,7 @@ const cookie = require('js-cookie'); const k = require('k')(window); -module.exports=state; +module.exports = state; function state(nodes, st, keys) { const cookieName = `resorts-${st}`; @@ -22,7 +22,7 @@ function state(nodes, st, keys) { function read() { const text = cookie.get(cookieName); - return text && text.length ? text.split(',') : []; + return text && text.length ? text.split(',') : []; } function write(arr) { @@ -40,7 +40,7 @@ function state(nodes, st, keys) { return memo; }, {}); - nodes.forEach(({dataset, classList}) => { + nodes.forEach(({ dataset, classList }) => { const id = dataset.resort; state[id] = classList.contains(st); }); diff --git a/lib/client/stats/index.js b/lib/client/stats/index.js index 1d3c3672..7486cc35 100644 --- a/lib/client/stats/index.js +++ b/lib/client/stats/index.js @@ -11,6 +11,6 @@ function stats() { let ac = 0; const { style } = pie; Object.entries(data.percentage).forEach( - ([ key, value ]) => style.setProperty(`--${key}`, `${ac += value}%`) + ([key, value]) => style.setProperty(`--${key}`, `${ac += value}%`) ); } diff --git a/lib/embed/index.js b/lib/embed/index.js index 2206f55f..5c41a5ef 100644 --- a/lib/embed/index.js +++ b/lib/embed/index.js @@ -1,8 +1,8 @@ /*global document, window */ function el(attrs) { - const attrStr = Object.keys(attrs).map(function(attr) { - return attr + '="' + attrs[attr] + '"'; + const attrStr = Object.keys(attrs).map(function (attr) { + return attr + '="' + attrs[attr] + '"'; }).join(' '); return ['