From 56008323050fae7698c9bc115b38f97655ecdcb0 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Mon, 30 Jan 2017 00:51:08 +0100 Subject: [PATCH] [TASK] Move to es5 eslint airbnb Step forward to es6 airbnb --- .eslintrc | 8 +- Gruntfile.js | 12 +- app.js | 30 ++--- lib/about.js | 56 ++++---- lib/container.js | 8 +- lib/datadistributor.js | 4 +- lib/filters/filtergui.js | 16 +-- lib/filters/genericnode.js | 20 +-- lib/filters/nodefilter.js | 2 +- lib/forcegraph.js | 172 ++++++++++++------------ lib/gui.js | 56 ++++---- lib/infobox/link.js | 44 +++--- lib/infobox/location.js | 51 ++++--- lib/infobox/main.js | 26 ++-- lib/infobox/node.js | 220 +++++++++++++++--------------- lib/legend.js | 40 +++--- lib/linklist.js | 56 ++++---- lib/locationmarker.js | 14 +- lib/main.js | 50 +++---- lib/map.js | 164 +++++++++++----------- lib/map/clientlayer.js | 14 +- lib/map/labelslayer.js | 91 +++++++------ lib/nodelist.js | 88 ++++++------ lib/proportions.js | 107 ++++++++------- lib/router.js | 67 +++++---- lib/sidebar.js | 38 +++--- lib/simplenodelist.js | 41 +++--- lib/sorttable.js | 22 +-- lib/tabs.js | 24 ++-- lib/title.js | 18 +-- lib/utils/helper.js | 124 ++++++++--------- package.json | 3 + tasks/build.js | 104 +++++++------- tasks/clean.js | 10 +- tasks/development.js | 34 ++--- tasks/linting.js | 12 +- yarn.lock | 269 ++++++++++++++++++++++++++++++------- 37 files changed, 1148 insertions(+), 967 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0f6064d..64cc9da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,12 @@ --- "extends": - - "defaults/configurations/eslint" + - "eslint-config-airbnb-es5" rules: - "semi": ["error", "always"] "no-undef": 0 "no-console": ["warn", { allow: ["warn", "error"] }] + "no-param-reassign": 0 + "func-names": 0 + "guard-for-in": 0 + "no-undefined": 0 + "no-nested-ternary": 0 diff --git a/Gruntfile.js b/Gruntfile.js index 9b5a25e..161b046 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,9 @@ -module.exports = function (grunt) { - "use strict"; +module.exports = function exports(grunt) { + 'use strict'; - grunt.loadTasks("tasks"); + grunt.loadTasks('tasks'); - grunt.registerTask("default", ["lint", "copy", "sass:dist", "postcss", "requirejs:default", "inlinedata", "cachebreaker", "inline", "htmlmin", "clean:release"]); - grunt.registerTask("lint", ["sasslint", "eslint"]); - grunt.registerTask("serve", ["lint", "copy", "sass:dev", "postcss", "requirejs:dev", "inlinedata", "htmlmin", "browserSync", "watch"]); + grunt.registerTask('default', ['lint', 'copy', 'sass:dist', 'postcss', 'requirejs:default', 'inlinedata', 'cachebreaker', 'inline', 'htmlmin', 'clean:release']); + grunt.registerTask('lint', ['sasslint', 'eslint']); + grunt.registerTask('serve', ['lint', 'copy', 'sass:dev', 'postcss', 'requirejs:dev', 'inlinedata', 'htmlmin', 'browserSync', 'watch']); }; diff --git a/app.js b/app.js index ea13f39..2d9b159 100644 --- a/app.js +++ b/app.js @@ -1,26 +1,26 @@ -"use strict"; +'use strict'; require.config({ - baseUrl: "lib", + baseUrl: 'lib', paths: { - "leaflet": "../node_modules/leaflet/dist/leaflet", - "leaflet.label": "../node_modules/leaflet-label/dist/leaflet.label", - "chroma-js": "../node_modules/chroma-js/chroma.min", - "moment": "../node_modules/moment", - "tablesort": "../node_modules/tablesort/src/tablesort", - "d3": "../node_modules/d3/d3.min", - "virtual-dom": "../node_modules/virtual-dom/dist/virtual-dom", - "rbush": "../node_modules/rbush/rbush", - "helper": "utils/helper" + 'leaflet': '../node_modules/leaflet/dist/leaflet', + 'leaflet.label': '../node_modules/leaflet-label/dist/leaflet.label', + 'chroma-js': '../node_modules/chroma-js/chroma.min', + 'moment': '../node_modules/moment', + 'tablesort': '../node_modules/tablesort/src/tablesort', + 'd3': '../node_modules/d3/d3.min', + 'virtual-dom': '../node_modules/virtual-dom/dist/virtual-dom', + 'rbush': '../node_modules/rbush/rbush', + 'helper': 'utils/helper' }, shim: { - "leaflet.label": ["leaflet"], - "tablesort": { - exports: "Tablesort" + 'leaflet.label': ['leaflet'], + 'tablesort': { + exports: 'Tablesort' } } }); -require(["main"], function (main) { +require(['main'], function (main) { main(jsonData); }); diff --git a/lib/about.js b/lib/about.js index 045b3b9..7e2f078 100644 --- a/lib/about.js +++ b/lib/about.js @@ -1,42 +1,42 @@ define(function () { - "use strict"; + 'use strict'; return function () { - this.render = function (d) { - d.innerHTML = "

Über Meshviewer

" + + this.render = function render(d) { + d.innerHTML = '

Über Meshviewer

' + - "

Mit Doppelklick und Shift+Doppelklick kann man in der Karte " + - "auch zoomen.

" + + '

Mit Doppelklick und Shift+Doppelklick kann man in der Karte ' + + 'auch zoomen.

' + - "

AGPL 3

" + + '

AGPL 3

' + - "

Copyright (C) Milan Pässler

" + - "

Copyright (C) Nils Schneider

" + + '

Copyright (C) Milan Pässler

' + + '

Copyright (C) Nils Schneider

' + - "

This program is free software: you can redistribute it and/or " + - "modify it under the terms of the GNU Affero General Public " + - "License as published by the Free Software Foundation, either " + - "version 3 of the License, or (at your option) any later version.

" + + '

This program is free software: you can redistribute it and/or ' + + 'modify it under the terms of the GNU Affero General Public ' + + 'License as published by the Free Software Foundation, either ' + + 'version 3 of the License, or (at your option) any later version.

' + - "

This program is distributed in the hope that it will be useful, " + - "but WITHOUT ANY WARRANTY; without even the implied warranty of " + - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " + - "GNU Affero General Public License for more details.

" + + '

This program is distributed in the hope that it will be useful, ' + + 'but WITHOUT ANY WARRANTY; without even the implied warranty of ' + + 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' + + 'GNU Affero General Public License for more details.

' + - "

You should have received a copy of the GNU Affero General " + - "Public License along with this program. If not, see " + - "" + - "https://www.gnu.org/licenses/.

" + + '

You should have received a copy of the GNU Affero General ' + + 'Public License along with this program. If not, see ' + + '' + + 'https://www.gnu.org/licenses/.

' + - "

The source code is available at " + - "" + - "https://github.com/ffrgb/meshviewer." + + '

The source code is available at ' + + '' + + 'https://github.com/ffrgb/meshviewer.' + - "

Forked and based on " + - "" + - "https://github.com/ffnord/meshviewer and " + - "" + - "https://github.com/plumpudding/hopglass.

"; + '

Forked and based on ' + + '' + + 'https://github.com/ffnord/meshviewer and ' + + '' + + 'https://github.com/plumpudding/hopglass.

'; }; }; }); diff --git a/lib/container.js b/lib/container.js index d799167..41129d1 100644 --- a/lib/container.js +++ b/lib/container.js @@ -1,20 +1,20 @@ define([], function () { - "use strict"; + 'use strict'; return function (tag) { if (!tag) { - tag = "div"; + tag = 'div'; } var self = this; var container = document.createElement(tag); - self.add = function (d) { + self.add = function add(d) { d.render(container); }; - self.render = function (el) { + self.render = function render(el) { el.appendChild(container); }; diff --git a/lib/datadistributor.js b/lib/datadistributor.js index ea79341..32e5c1c 100644 --- a/lib/datadistributor.js +++ b/lib/datadistributor.js @@ -1,5 +1,5 @@ -define(["filters/nodefilter"], function (NodeFilter) { - "use strict"; +define(['filters/nodefilter'], function (NodeFilter) { + 'use strict'; return function () { var targets = []; diff --git a/lib/filters/filtergui.js b/lib/filters/filtergui.js index af1f31e..ebb5ce3 100644 --- a/lib/filters/filtergui.js +++ b/lib/filters/filtergui.js @@ -1,10 +1,10 @@ define(function () { - "use strict"; + 'use strict'; return function (distributor) { - var container = document.createElement("ul"); - container.classList.add("filters"); - var div = document.createElement("div"); + var container = document.createElement('ul'); + container.classList.add('filters'); + var div = document.createElement('div'); function render(el) { el.appendChild(div); @@ -16,13 +16,13 @@ define(function () { } filters.forEach(function (d) { - var li = document.createElement("li"); + var li = document.createElement('li'); container.appendChild(li); d.render(li); - var button = document.createElement("button"); - button.classList.add("ion-android-close"); - button.onclick = function () { + var button = document.createElement('button'); + button.classList.add('ion-android-close'); + button.onclick = function onclick() { distributor.removeFilter(d); }; li.appendChild(button); diff --git a/lib/filters/genericnode.js b/lib/filters/genericnode.js index 6a6ae15..cef74c6 100644 --- a/lib/filters/genericnode.js +++ b/lib/filters/genericnode.js @@ -1,13 +1,13 @@ -define(["helper"], function (helper) { - "use strict"; +define(['helper'], function (helper) { + 'use strict'; return function (name, key, value, f) { var negate = false; var refresh; - var label = document.createElement("label"); - var strong = document.createElement("strong"); - label.textContent = name + ": "; + var label = document.createElement('label'); + var strong = document.createElement('strong'); + label.textContent = name + ': '; label.appendChild(strong); function run(d) { @@ -20,15 +20,15 @@ define(["helper"], function (helper) { return o === value ? !negate : negate; } - function setRefresh(f) { - refresh = f; + function setRefresh(r) { + refresh = r; } function draw(el) { if (negate) { - el.classList.add("not"); + el.classList.add('not'); } else { - el.classList.remove("not"); + el.classList.remove('not'); } strong.textContent = value; @@ -38,7 +38,7 @@ define(["helper"], function (helper) { el.appendChild(label); draw(el); - label.onclick = function () { + label.onclick = function onclick() { negate = !negate; draw(el); diff --git a/lib/filters/nodefilter.js b/lib/filters/nodefilter.js index 68da159..1b3e882 100644 --- a/lib/filters/nodefilter.js +++ b/lib/filters/nodefilter.js @@ -1,5 +1,5 @@ define(function () { - "use strict"; + 'use strict'; return function (filter) { return function (data) { diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 33ab21b..271132f 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -1,5 +1,5 @@ -define(["d3", "helper"], function (d3, helper) { - "use strict"; +define(['d3', 'helper'], function (d3, helper) { + 'use strict'; var margin = 200; var NODE_RADIUS = 15; @@ -7,8 +7,11 @@ define(["d3", "helper"], function (d3, helper) { return function (config, linkScale, sidebar, router) { var self = this; - var canvas, ctx, screenRect; - var nodesDict, linksDict; + var canvas; + var ctx; + var screenRect; + var nodesDict; + var linksDict; var zoomBehavior; var force; var el; @@ -30,8 +33,8 @@ define(["d3", "helper"], function (d3, helper) { var LINK_DISTANCE = 70; - function graphDiameter(nodes) { - return Math.sqrt(nodes.length / Math.PI) * LINK_DISTANCE * 1.41; + function graphDiameter(n) { + return Math.sqrt(n.length / Math.PI) * LINK_DISTANCE * 1.41; } function savePositions() { @@ -40,32 +43,31 @@ define(["d3", "helper"], function (d3, helper) { } var save = intNodes.map(function (d) { - return {id: d.o.id, x: d.x, y: d.y}; + return { id: d.o.id, x: d.x, y: d.y }; }); - localStorage.setItem("graph/nodeposition", JSON.stringify(save)); + localStorage.setItem('graph/nodeposition', JSON.stringify(save)); } function nodeName(d) { if (d.o.node && d.o.node.nodeinfo) { return d.o.node.nodeinfo.hostname; - } else { - return d.o.id; } + return d.o.id; } function dragstart() { var e = translateXY(d3.mouse(el)); - var nodes = intNodes.filter(function (d) { + var n = intNodes.filter(function (d) { return distancePoint(e, d) < NODE_RADIUS; }); - if (nodes.length === 0) { + if (n.length === 0) { return; } - draggedNode = nodes[0]; + draggedNode = n[0]; d3.event.sourceEvent.stopPropagation(); d3.event.sourceEvent.preventDefault(); draggedNode.fixed |= 2; @@ -94,9 +96,9 @@ define(["d3", "helper"], function (d3, helper) { } var draggableNode = d3.behavior.drag() - .on("dragstart", dragstart) - .on("drag", dragmove) - .on("dragend", dragend); + .on('dragstart', dragstart) + .on('drag', dragmove) + .on('dragend', dragend); function animatePanzoom(translate, scale) { var translateP = zoomBehavior.translate(); @@ -107,13 +109,13 @@ define(["d3", "helper"], function (d3, helper) { zoomBehavior.scale(scale); panzoom(); } else { - var start = {x: translateP[0], y: translateP[1], scale: scaleP}; - var end = {x: translate[0], y: translate[1], scale: scale}; + var start = { x: translateP[0], y: translateP[1], scale: scaleP }; + var end = { x: translate[0], y: translate[1], scale: scale }; var interpolate = d3.interpolateObject(start, end); var duration = 500; - var ease = d3.ease("cubic-in-out"); + var ease = d3.ease('cubic-in-out'); d3.timer(function (t) { if (t >= duration) { @@ -188,7 +190,7 @@ define(["d3", "helper"], function (d3, helper) { highlightedLinks = []; if (highlight !== undefined) { - if (highlight.type === "node") { + if (highlight.type === 'node') { var n = nodesDict[highlight.o.nodeinfo.node_id]; if (n) { @@ -200,7 +202,7 @@ define(["d3", "helper"], function (d3, helper) { } return; - } else if (highlight.type === "link") { + } else if (highlight.type === 'link') { var l = linksDict[highlight.o.id]; if (l) { @@ -231,8 +233,8 @@ define(["d3", "helper"], function (d3, helper) { } function drawLabel(d) { - var neighbours = d.neighbours.filter(function (d) { - return d.link.o.type !== "fastd" && d.link.o.type !== "L2TP"; + var neighbours = d.neighbours.filter(function (n) { + return n.link.o.type !== 'fastd' && n.link.o.type !== 'L2TP'; }); var sum = neighbours.reduce(function (a, b) { @@ -273,10 +275,10 @@ define(["d3", "helper"], function (d3, helper) { } function drawNode(color, radius, scale, r) { - var node = document.createElement("canvas"); + var node = document.createElement('canvas'); node.height = node.width = scale * radius * 8 * r; - var nctx = node.getContext("2d"); + var nctx = node.getContext('2d'); nctx.scale(scale * r, scale * r); nctx.save(); @@ -287,16 +289,16 @@ define(["d3", "helper"], function (d3, helper) { nctx.moveTo(radius, 0); nctx.arc(0, 0, radius, 0, 2 * Math.PI); - nctx.strokeStyle = "rgba(255, 0, 0, 1)"; + nctx.strokeStyle = 'rgba(255, 0, 0, 1)'; nctx.shadowOffsetX = node.width * 1.5; nctx.shadowOffsetY = node.height * 1.5 + 3; nctx.shadowBlur = 12; - nctx.shadowColor = "rgba(0, 0, 0, 0.16)"; + nctx.shadowColor = 'rgba(0, 0, 0, 0.16)'; nctx.stroke(); nctx.shadowOffsetX = node.width * 1.5; nctx.shadowOffsetY = node.height * 1.5 + 3; nctx.shadowBlur = 12; - nctx.shadowColor = "rgba(0, 0, 0, 0.23)"; + nctx.shadowColor = 'rgba(0, 0, 0, 0.23)'; nctx.stroke(); nctx.restore(); @@ -328,14 +330,14 @@ define(["d3", "helper"], function (d3, helper) { ctx.translate(translate[0], translate[1]); ctx.scale(scale, scale); - var clientColor = "rgba(230, 50, 75, 1.0)"; - var unknownColor = "#D10E2A"; - var nonUplinkColor = "#F2E3C6"; - var uplinkColor = "#5BAAEB"; - var unseenColor = "#FFA726"; - var highlightColor = "rgba(252, 227, 198, 0.15)"; + var clientColor = 'rgba(230, 50, 75, 1.0)'; + var unknownColor = '#D10E2A'; + var nonUplinkColor = '#F2E3C6'; + var uplinkColor = '#5BAAEB'; + var unseenColor = '#FFA726'; + var highlightColor = 'rgba(252, 227, 198, 0.15)'; var nodeRadius = 6; - var cableColor = "#50B0F0"; + var cableColor = '#50B0F0'; // -- draw links -- ctx.save(); @@ -349,9 +351,9 @@ define(["d3", "helper"], function (d3, helper) { ctx.beginPath(); ctx.moveTo(d.source.x + dx * nodeRadius, d.source.y + dy * nodeRadius); ctx.lineTo(d.target.x - dx * nodeRadius, d.target.y - dy * nodeRadius); - ctx.strokeStyle = d.o.type === "Kabel" ? cableColor : d.color; - ctx.globalAlpha = d.o.type === "fastd" || d.o.type === "L2TP" ? 0.2 : 0.8; - ctx.lineWidth = d.o.type === "fastd" || d.o.type === "L2TP" ? 1.5 : 2.5; + ctx.strokeStyle = d.o.type === 'Kabel' ? cableColor : d.color; + ctx.globalAlpha = d.o.type === 'fastd' || d.o.type === 'L2TP' ? 0.2 : 0.8; + ctx.lineWidth = d.o.type === 'fastd' || d.o.type === 'L2TP' ? 1.5 : 2.5; ctx.stroke(); }); @@ -405,14 +407,14 @@ define(["d3", "helper"], function (d3, helper) { var startAngle = Math.PI; for (var orbit = 0, i = 0; i < clients; orbit++) { - var distance = startDistance + orbit * 2 * radius * a; - var n = Math.floor((Math.PI * distance) / (a * radius)); + var di = startDistance + orbit * 2 * radius * a; + var n = Math.floor((Math.PI * di) / (a * radius)); var delta = clients - i; for (var j = 0; j < Math.min(delta, n); i++, j++) { var angle = 2 * Math.PI / n * j; - var x = d.x + distance * Math.cos(angle + startAngle); - var y = d.y + distance * Math.sin(angle + startAngle); + var x = d.x + di * Math.cos(angle + startAngle); + var y = d.y + di * Math.sin(angle + startAngle); ctx.moveTo(x, y); ctx.arc(x, y, radius, 0, 2 * Math.PI); @@ -427,11 +429,11 @@ define(["d3", "helper"], function (d3, helper) { // -- draw node highlights -- if (highlightedNodes.length) { ctx.save(); - ctx.shadowColor = "rgba(255, 255, 255, 1.0)"; + ctx.shadowColor = 'rgba(255, 255, 255, 1.0)'; ctx.shadowBlur = 10 * nodeRadius; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; - ctx.globalCompositeOperation = "lighten"; + ctx.globalCompositeOperation = 'lighten'; ctx.fillStyle = highlightColor; ctx.beginPath(); @@ -448,13 +450,13 @@ define(["d3", "helper"], function (d3, helper) { if (highlightedLinks.length) { ctx.save(); ctx.lineWidth = 2 * 5 * nodeRadius; - ctx.shadowColor = "rgba(255, 255, 255, 1.0)"; + ctx.shadowColor = 'rgba(255, 255, 255, 1.0)'; ctx.shadowBlur = 10 * nodeRadius; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; - ctx.globalCompositeOperation = "lighten"; + ctx.globalCompositeOperation = 'lighten'; ctx.strokeStyle = highlightColor; - ctx.lineCap = "round"; + ctx.lineCap = 'round'; ctx.beginPath(); highlightedLinks.forEach(function (d) { @@ -482,8 +484,8 @@ define(["d3", "helper"], function (d3, helper) { var r = window.devicePixelRatio; canvas.width = el.offsetWidth * r; canvas.height = el.offsetHeight * r; - canvas.style.width = el.offsetWidth + "px"; - canvas.style.height = el.offsetHeight + "px"; + canvas.style.width = el.offsetWidth + 'px'; + canvas.style.height = el.offsetHeight + 'px'; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.scale(r, r); requestAnimationFrame(redraw); @@ -539,17 +541,17 @@ define(["d3", "helper"], function (d3, helper) { var e = translateXY(d3.mouse(el)); - var nodes = intNodes.filter(function (d) { + var n = intNodes.filter(function (d) { return distancePoint(e, d) < NODE_RADIUS; }); - if (nodes.length > 0) { - router.node(nodes[0].o.node)(); + if (n.length > 0) { + router.node(n[0].o.node)(); return; } var links = intLinks.filter(function (d) { - return d.o.type !== "fastd" && d.o.type !== "L2TP"; + return d.o.type !== 'fastd' && d.o.type !== 'L2TP'; }).filter(function (d) { return distanceLink(e, d.source, d.target) < LINE_RADIUS; }); @@ -589,52 +591,50 @@ define(["d3", "helper"], function (d3, helper) { }; } - el = document.createElement("div"); - el.classList.add("graph"); + el = document.createElement('div'); + el.classList.add('graph'); - font = window.getComputedStyle(el).fontSize + " " + window.getComputedStyle(el).fontFamily; + font = window.getComputedStyle(el).fontSize + ' ' + window.getComputedStyle(el).fontFamily; zoomBehavior = d3.behavior.zoom() .scaleExtent([1 / 3, 3]) - .on("zoom", onPanZoom) + .on('zoom', onPanZoom) .translate([sidebar(), 0]); canvas = d3.select(el) - .attr("tabindex", 1) - .on("keypress", keyboardZoom(zoomBehavior)) + .attr('tabindex', 1) + .on('keypress', keyboardZoom(zoomBehavior)) .call(zoomBehavior) - .append("canvas") - .on("click", onClick) + .append('canvas') + .on('click', onClick) .call(draggableNode) .node(); - ctx = canvas.getContext("2d"); + ctx = canvas.getContext('2d'); force = d3.layout.force() .charge(-250) .gravity(0.1) .linkDistance(function (d) { - if (d.o.type === "fastd" || d.o.type === "L2TP") { + if (d.o.type === 'fastd' || d.o.type === 'L2TP') { return 0; - } else { - return LINK_DISTANCE; } + return LINK_DISTANCE; }) .linkStrength(function (d) { - if (d.o.type === "fastd" || d.o.type === "L2TP") { + if (d.o.type === 'fastd' || d.o.type === 'L2TP') { return 0.02; - } else { - return Math.max(0.5, 1 / d.o.tq); } + return Math.max(0.5, 1 / d.o.tq); }) - .on("tick", tickEvent) - .on("end", savePositions); + .on('tick', tickEvent) + .on('end', savePositions); - window.addEventListener("resize", resizeCanvas); + window.addEventListener('resize', resizeCanvas); panzoom(); - self.setData = function (data) { + self.setData = function setData(data) { var oldNodes = {}; intNodes.forEach(function (d) { @@ -696,9 +696,9 @@ define(["d3", "helper"], function (d3, helper) { var offset = 5; var lineWidth = 3; - var buffer = document.createElement("canvas"); + var buffer = document.createElement('canvas'); var r = window.devicePixelRatio; - var bctx = buffer.getContext("2d"); + var bctx = buffer.getContext('2d'); bctx.font = font; var width = bctx.measureText(name).width; var scale = zoomBehavior.scaleExtent()[1] * r; @@ -706,10 +706,10 @@ define(["d3", "helper"], function (d3, helper) { buffer.height = (16 + 2 * lineWidth) * scale; bctx.font = font; bctx.scale(scale, scale); - bctx.textBaseline = "middle"; - bctx.textAlign = "center"; - bctx.fillStyle = "rgba(242, 227, 198, 1.0)"; - bctx.shadowColor = "rgba(0, 0, 0, 1)"; + bctx.textBaseline = 'middle'; + bctx.textAlign = 'center'; + bctx.fillStyle = 'rgba(242, 227, 198, 1.0)'; + bctx.shadowColor = 'rgba(0, 0, 0, 1)'; bctx.shadowBlur = 5; bctx.fillText(name, buffer.width / (2 * scale), buffer.height / (2 * scale)); @@ -743,7 +743,7 @@ define(["d3", "helper"], function (d3, helper) { }); if (helper.localStorageTest()) { - var save = JSON.parse(localStorage.getItem("graph/nodeposition")); + var save = JSON.parse(localStorage.getItem('graph/nodeposition')); if (save) { var nodePositions = {}; @@ -772,25 +772,25 @@ define(["d3", "helper"], function (d3, helper) { resizeCanvas(); }; - self.resetView = function () { + self.resetView = function resetView() { highlight = undefined; updateHighlight(); doAnimation = true; }; - self.gotoNode = function (d) { - highlight = {type: "node", o: d}; + self.gotoNode = function gotoNode(d) { + highlight = { type: 'node', o: d }; updateHighlight(); doAnimation = true; }; - self.gotoLink = function (d) { - highlight = {type: "link", o: d}; + self.gotoLink = function gotoLink(d) { + highlight = { type: 'link', o: d }; updateHighlight(); doAnimation = true; }; - self.destroy = function () { + self.destroy = function destroy() { force.stop(); canvas.remove(); force = null; @@ -800,7 +800,7 @@ define(["d3", "helper"], function (d3, helper) { } }; - self.render = function (d) { + self.render = function render(d) { d.appendChild(el); resizeCanvas(); updateHighlight(); diff --git a/lib/gui.js b/lib/gui.js index a3d2609..f38c422 100644 --- a/lib/gui.js +++ b/lib/gui.js @@ -1,22 +1,22 @@ -define(["chroma-js", "map", "sidebar", "tabs", "container", "legend", - "linklist", "nodelist", "simplenodelist", "infobox/main", - "proportions", "forcegraph", "title", "about", "datadistributor", - "filters/filtergui"], +define(['chroma-js', 'map', 'sidebar', 'tabs', 'container', 'legend', + 'linklist', 'nodelist', 'simplenodelist', 'infobox/main', + 'proportions', 'forcegraph', 'title', 'about', 'datadistributor', + 'filters/filtergui'], function (chroma, Map, Sidebar, Tabs, Container, Legend, Linklist, Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph, Title, About, DataDistributor, FilterGUI) { - "use strict"; + 'use strict'; return function (config, router) { var self = this; var content; var contentDiv; - var linkScale = chroma.scale(chroma.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5]); + var linkScale = chroma.scale(chroma.bezier(['#04C714', '#FF5500', '#F02311'])).domain([1, 5]); var sidebar; - var buttons = document.createElement("div"); - buttons.classList.add("buttons"); + var buttons = document.createElement('div'); + buttons.classList.add('buttons'); var fanout = new DataDistributor(); var fanoutUnfiltered = new DataDistributor(); @@ -51,24 +51,24 @@ define(["chroma-js", "map", "sidebar", "tabs", "container", "legend", }; } - var loader = document.getElementsByClassName("loader")[0]; - loader.classList.add("hide"); + var loader = document.getElementsByClassName('loader')[0]; + loader.classList.add('hide'); - contentDiv = document.createElement("div"); - contentDiv.classList.add("content"); + contentDiv = document.createElement('div'); + contentDiv.classList.add('content'); document.body.appendChild(contentDiv); sidebar = new Sidebar(document.body); contentDiv.appendChild(buttons); - var buttonToggle = document.createElement("button"); - buttonToggle.classList.add("ion-eye", "shadow"); - buttonToggle.onclick = function () { + var buttonToggle = document.createElement('button'); + buttonToggle.classList.add('ion-eye', 'shadow'); + buttonToggle.onclick = function onclick() { if (content.constructor === Map) { - router.view("g"); + router.view('g'); } else { - router.view("m"); + router.view('m'); } }; @@ -76,13 +76,13 @@ define(["chroma-js", "map", "sidebar", "tabs", "container", "legend", var title = new Title(config); - var header = new Container("header"); + var header = new Container('header'); var infobox = new Infobox(config, sidebar, router); var tabs = new Tabs(); var overview = new Container(); var legend = new Legend(config); - var newnodeslist = new SimpleNodelist("new", "firstseen", router, "Neue Knoten"); - var lostnodeslist = new SimpleNodelist("lost", "lastseen", router, "Verschwundene Knoten"); + var newnodeslist = new SimpleNodelist('new', 'firstseen', router, 'Neue Knoten'); + var lostnodeslist = new SimpleNodelist('lost', 'lastseen', router, 'Verschwundene Knoten'); var nodelist = new Nodelist(router); var linklist = new Linklist(linkScale, router); var statistics = new Proportions(config, fanout); @@ -106,19 +106,19 @@ define(["chroma-js", "map", "sidebar", "tabs", "container", "legend", header.add(filterGUI); sidebar.add(tabs); - tabs.add("Aktuelles", overview); - tabs.add("Knoten", nodelist); - tabs.add("Verbindungen", linklist); - tabs.add("Statistiken", statistics); - tabs.add("Über", about); + tabs.add('Aktuelles', overview); + tabs.add('Knoten', nodelist); + tabs.add('Verbindungen', linklist); + tabs.add('Statistiken', statistics); + tabs.add('Über', about); router.addTarget(title); router.addTarget(infobox); - router.addView("m", mkView(Map)); - router.addView("g", mkView(ForceGraph)); + router.addView('m', mkView(Map)); + router.addView('g', mkView(ForceGraph)); - router.view("m"); + router.view('m'); self.setData = fanoutUnfiltered.setData; diff --git a/lib/infobox/link.js b/lib/infobox/link.js index dc3cd1b..8a7f203 100644 --- a/lib/infobox/link.js +++ b/lib/infobox/link.js @@ -1,55 +1,55 @@ -define(["helper"], function (helper) { - "use strict"; +define(['helper'], function (helper) { + 'use strict'; function showStatImg(o, source, target, time) { var subst = {}; - subst["{SOURCE}"] = source; - subst["{TARGET}"] = target; - subst["{TIME}"] = time; + subst['{SOURCE}'] = source; + subst['{TARGET}'] = target; + subst['{TIME}'] = time; return helper.showStat(o, subst); } return function (config, el, router, d) { var unknown = !d.source.node; - var h2 = document.createElement("h2"); + var h2 = document.createElement('h2'); var a1; if (!unknown) { - a1 = document.createElement("a"); - a1.href = "#"; + a1 = document.createElement('a'); + a1.href = '#'; a1.onclick = router.node(d.source.node); } else { - a1 = document.createElement("span"); + a1 = document.createElement('span'); } a1.textContent = unknown ? d.source.id : d.source.node.nodeinfo.hostname; h2.appendChild(a1); - var arrow = document.createElement("spam"); - arrow.classList.add("ion-ios-arrow-thin-right"); + var arrow = document.createElement('spam'); + arrow.classList.add('ion-ios-arrow-thin-right'); h2.appendChild(arrow); - var a2 = document.createElement("a"); - a2.href = "#"; + var a2 = document.createElement('a'); + a2.href = '#'; a2.onclick = router.node(d.target.node); a2.textContent = d.target.node.nodeinfo.hostname; h2.appendChild(a2); el.appendChild(h2); - var attributes = document.createElement("table"); - attributes.classList.add("attributes"); + var attributes = document.createElement('table'); + attributes.classList.add('attributes'); - helper.attributeEntry(attributes, "TQ", helper.showTq(d)); - helper.attributeEntry(attributes, "Entfernung", helper.showDistance(d)); - var hw1 = unknown ? null : helper.dictGet(d.source.node.nodeinfo, ["hardware", "model"]); - var hw2 = helper.dictGet(d.target.node.nodeinfo, ["hardware", "model"]); - helper.attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " – " + (hw2 != null ? hw2 : "unbekannt")); + helper.attributeEntry(attributes, 'TQ', helper.showTq(d)); + helper.attributeEntry(attributes, 'Entfernung', helper.showDistance(d)); + var hw1 = unknown ? null : helper.dictGet(d.source.node.nodeinfo, ['hardware', 'model']); + var hw2 = helper.dictGet(d.target.node.nodeinfo, ['hardware', 'model']); + helper.attributeEntry(attributes, 'Hardware', (hw1 !== null ? hw1 : 'unbekannt') + ' – ' + (hw2 !== null ? hw2 : 'unbekannt')); el.appendChild(attributes); if (config.linkInfos) { var source = d.source.node_id; var target = d.target.node_id; - var time = d.target.node.lastseen.format("DDMMYYYYHmmss"); + var time = d.target.node.lastseen.format('DDMMYYYYHmmss'); config.linkInfos.forEach(function (linkInfo) { - var h4 = document.createElement("h4"); + var h4 = document.createElement('h4'); h4.textContent = linkInfo.name; el.appendChild(h4); el.appendChild(showStatImg(linkInfo, source, target, time)); diff --git a/lib/infobox/location.js b/lib/infobox/location.js index 0128deb..909df48 100644 --- a/lib/infobox/location.js +++ b/lib/infobox/location.js @@ -1,68 +1,67 @@ -define(["helper"], function (helper) { - "use strict"; +define(['helper'], function (helper) { + 'use strict'; return function (config, el, router, d) { - var sidebarTitle = document.createElement("h2"); - sidebarTitle.textContent = "Location: " + d.toString(); + var sidebarTitle = document.createElement('h2'); + sidebarTitle.textContent = 'Location: ' + d.toString(); el.appendChild(sidebarTitle); - helper.getJSON(config.reverseGeocodingApi + "?format=json&lat=" + d.lat + "&lon=" + d.lng + "&zoom=18&addressdetails=0") + helper.getJSON(config.reverseGeocodingApi + '?format=json&lat=' + d.lat + '&lon=' + d.lng + '&zoom=18&addressdetails=0') .then(function (result) { if (result.display_name) { sidebarTitle.textContent = result.display_name; } }); - var editLat = document.createElement("input"); - editLat.type = "text"; + var editLat = document.createElement('input'); + editLat.type = 'text'; editLat.value = d.lat.toFixed(9); - el.appendChild(createBox("lat", "Breitengrad", editLat)); + el.appendChild(createBox('lat', 'Breitengrad', editLat)); - var editLng = document.createElement("input"); - editLng.type = "text"; + var editLng = document.createElement('input'); + editLng.type = 'text'; editLng.value = d.lng.toFixed(9); - el.appendChild(createBox("lng", "Längengrad", editLng)); + el.appendChild(createBox('lng', 'Längengrad', editLng)); - var editUci = document.createElement("textarea"); + var editUci = document.createElement('textarea'); editUci.value = "uci set gluon-node-info.@location[0]='location'; " + "uci set gluon-node-info.@location[0].share_location='1';" + "uci set gluon-node-info.@location[0].latitude='" + d.lat.toFixed(9) + "';" + "uci set gluon-node-info.@location[0].longitude='" + d.lng.toFixed(9) + "';" + - "uci commit gluon-node-info"; + 'uci commit gluon-node-info'; - el.appendChild(createBox("uci", "Uci", editUci)); + el.appendChild(createBox('uci', 'Uci', editUci)); function createBox(name, title, inputElem) { - var box = document.createElement("div"); - var heading = document.createElement("h3"); + var box = document.createElement('div'); + var heading = document.createElement('h3'); heading.textContent = title; box.appendChild(heading); - var btn = document.createElement("button"); - btn.classList.add("ion-ios-copy"); - btn.title = "Kopieren"; - btn.onclick = function () { + var btn = document.createElement('button'); + btn.classList.add('ion-ios-copy'); + btn.title = 'Kopieren'; + btn.onclick = function onclick() { copy2clip(inputElem.id); }; - inputElem.id = "location-" + name; + inputElem.id = 'location-' + name; inputElem.readOnly = true; - var line = document.createElement("p"); + var line = document.createElement('p'); line.appendChild(inputElem); line.appendChild(btn); box.appendChild(line); - box.id = "box-" + name; + box.id = 'box-' + name; return box; } function copy2clip(id) { - var copyField = document.querySelector("#" + id); + var copyField = document.querySelector('#' + id); copyField.select(); try { - document.execCommand("copy"); + document.execCommand('copy'); } catch (err) { console.warn(err); } } - }; }); diff --git a/lib/infobox/main.js b/lib/infobox/main.js index 5db0991..d358fc9 100644 --- a/lib/infobox/main.js +++ b/lib/infobox/main.js @@ -1,5 +1,5 @@ -define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Node, Location) { - "use strict"; +define(['infobox/link', 'infobox/node', 'infobox/location'], function (link, node, location) { + 'use strict'; return function (config, sidebar, router) { var self = this; @@ -18,16 +18,16 @@ define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Nod sidebar.ensureVisible(); sidebar.hide(); - el = document.createElement("div"); + el = document.createElement('div'); sidebar.container.insertBefore(el, sidebar.container.firstChild); el.scrollIntoView(false); - el.classList.add("infobox"); + el.classList.add('infobox'); el.destroy = destroy; - var closeButton = document.createElement("button"); - closeButton.classList.add("close"); - closeButton.classList.add("ion-android-close"); + var closeButton = document.createElement('button'); + closeButton.classList.add('close'); + closeButton.classList.add('ion-android-close'); closeButton.onclick = router.reset; el.appendChild(closeButton); } @@ -42,27 +42,27 @@ define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Nod self.resetView = destroy; - self.gotoNode = function (d, update) { + self.gotoNode = function gotoNode(d, update) { if (update !== true) { create(); } else { clear(); } - Node(config, el, router, d); + node(config, el, router, d); }; - self.gotoLink = function (d, update) { + self.gotoLink = function gotoLink(d, update) { if (update !== true) { create(); } else { clear(); } - Link(config, el, router, d); + link(config, el, router, d); }; - self.gotoLocation = function (d) { + self.gotoLocation = function gotoLocation(d) { create(); - Location(config, el, router, d); + location(config, el, router, d); }; return self; diff --git a/lib/infobox/node.js b/lib/infobox/node.js index d5a68bf..6ed6f8c 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -1,6 +1,6 @@ -define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"], - function (chroma, moment, Tablesort, helper) { - "use strict"; +define(['chroma-js', 'moment/moment', 'tablesort', 'helper', 'moment/locale/de'], + function (chroma, moment, tablesort, helper) { + 'use strict'; function showGeoURI(d) { if (!helper.hasLocation(d)) { @@ -8,37 +8,37 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } return function (el) { - var a = document.createElement("a"); - a.textContent = Number(d.nodeinfo.location.latitude.toFixed(6)) + ", " + Number(d.nodeinfo.location.longitude.toFixed(6)); - a.href = "geo:" + d.nodeinfo.location.latitude + "," + d.nodeinfo.location.longitude; + var a = document.createElement('a'); + a.textContent = Number(d.nodeinfo.location.latitude.toFixed(6)) + ', ' + Number(d.nodeinfo.location.longitude.toFixed(6)); + a.href = 'geo:' + d.nodeinfo.location.latitude + ',' + d.nodeinfo.location.longitude; el.appendChild(a); }; } function showStatus(d) { return function (el) { - el.classList.add(d.flags.unseen ? "unseen" : (d.flags.online ? "online" : "offline")); + el.classList.add(d.flags.unseen ? 'unseen' : (d.flags.online ? 'online' : 'offline')); if (d.flags.online) { - el.textContent = "online, letzte Nachricht " + d.lastseen.fromNow() + " (" + d.lastseen.format("DD.MM.YYYY, H:mm:ss") + ")"; + el.textContent = 'online, letzte Nachricht ' + d.lastseen.fromNow() + ' (' + d.lastseen.format('DD.MM.YYYY, H:mm:ss') + ')'; } else { - el.textContent = "offline, letzte Nachricht " + d.lastseen.fromNow() + " (" + d.lastseen.format("DD.MM.YYYY, H:mm:ss") + ")"; + el.textContent = 'offline, letzte Nachricht ' + d.lastseen.fromNow() + ' (' + d.lastseen.format('DD.MM.YYYY, H:mm:ss') + ')'; } }; } function showFirmware(d) { - var release = helper.dictGet(d.nodeinfo, ["software", "firmware", "release"]); - var base = helper.dictGet(d.nodeinfo, ["software", "firmware", "base"]); + var release = helper.dictGet(d.nodeinfo, ['software', 'firmware', 'release']); + var base = helper.dictGet(d.nodeinfo, ['software', 'firmware', 'base']); if (release === null || base === null) { return undefined; } - return release + " / " + base; + return release + ' / ' + base; } function showSite(d, config) { - var site = helper.dictGet(d.nodeinfo, ["system", "site_code"]); + var site = helper.dictGet(d.nodeinfo, ['system', 'site_code']); var rt = site; if (config.siteNames) { config.siteNames.forEach(function (t) { @@ -51,15 +51,15 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } function showUptime(d) { - if (!("uptime" in d.statistics)) { + if (!('uptime' in d.statistics)) { return undefined; } - return moment.duration(d.statistics.uptime, "seconds").humanize(); + return moment.duration(d.statistics.uptime, 'seconds').humanize(); } function showFirstseen(d) { - if (!("firstseen" in d)) { + if (!('firstseen' in d)) { return undefined; } @@ -72,18 +72,18 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } return function (el) { - el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : "keine")); - el.appendChild(document.createElement("br")); + el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : 'keine')); + el.appendChild(document.createElement('br')); - var span = document.createElement("span"); - span.classList.add("clients"); - span.innerHTML = "".repeat(d.statistics.clients); + var span = document.createElement('span'); + span.classList.add('clients'); + span.innerHTML = ''.repeat(d.statistics.clients); el.appendChild(span); }; } function showIPs(d) { - var ips = helper.dictGet(d.nodeinfo, ["network", "addresses"]); + var ips = helper.dictGet(d.nodeinfo, ['network', 'addresses']); if (ips === null) { return undefined; } @@ -92,15 +92,15 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] return function (el) { ips.forEach(function (ip, i) { - var link = !ip.startsWith("fe80:"); + var link = !ip.startsWith('fe80:'); if (i > 0) { - el.appendChild(document.createElement("br")); + el.appendChild(document.createElement('br')); } if (link) { - var a = document.createElement("a"); - a.href = "http://[" + ip + "]/"; + var a = document.createElement('a'); + a.href = 'http://[' + ip + ']/'; a.textContent = ip; el.appendChild(a); } else { @@ -111,32 +111,32 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } function showBar(v) { - var span = document.createElement("span"); - span.classList.add("bar"); + var span = document.createElement('span'); + span.classList.add('bar'); - var bar = document.createElement("span"); - bar.style.width = (v * 100) + "%"; + var bar = document.createElement('span'); + bar.style.width = (v * 100) + '%'; span.appendChild(bar); - var label = document.createElement("label"); - label.textContent = (Math.round(v * 100)) + " %"; + var label = document.createElement('label'); + label.textContent = (Math.round(v * 100)) + ' %'; span.appendChild(label); return span; } function showLoadBar(v, p) { - var span = document.createElement("span"); - span.classList.add("bar"); + var span = document.createElement('span'); + span.classList.add('bar'); - var bar = document.createElement("span"); - bar.style.width = ((v * 100) % 100) + "%"; + var bar = document.createElement('span'); + bar.style.width = ((v * 100) % 100) + '%'; if (v >= p) { - span.classList.add("warning"); + span.classList.add('warning'); } span.appendChild(bar); - var label = document.createElement("label"); + var label = document.createElement('label'); label.textContent = (v); span.appendChild(label); @@ -144,7 +144,7 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } function showLoad(d) { - if (!("loadavg" in d.statistics)) { + if (!('loadavg' in d.statistics)) { return undefined; } @@ -154,7 +154,7 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } function showRAM(d) { - if (!("memory_usage" in d.statistics)) { + if (!('memory_usage' in d.statistics)) { return undefined; } @@ -164,60 +164,60 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } function showAutoupdate(d) { - var au = helper.dictGet(d.nodeinfo, ["software", "autoupdater"]); + var au = helper.dictGet(d.nodeinfo, ['software', 'autoupdater']); if (!au) { return undefined; } - return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"; + return au.enabled ? 'aktiviert (' + au.branch + ')' : 'deaktiviert'; } function showStatImg(o, d) { var subst = {}; - subst["{NODE_ID}"] = d.nodeinfo.node_id ? d.nodeinfo.node_id : "unknown"; - subst["{NODE_NAME}"] = d.nodeinfo.hostname ? d.nodeinfo.hostname.replace(/[^a-z0-9\-]/ig, "_") : "unknown"; - subst["{TIME}"] = d.lastseen.format("DDMMYYYYHmmss"); + subst['{NODE_ID}'] = d.nodeinfo.node_id ? d.nodeinfo.node_id : 'unknown'; + subst['{NODE_NAME}'] = d.nodeinfo.hostname ? d.nodeinfo.hostname.replace(/[^a-z0-9\-]/ig, '_') : 'unknown'; + subst['{TIME}'] = d.lastseen.format('DDMMYYYYHmmss'); return helper.showStat(o, subst); } return function (config, el, router, d) { - var linkScale = chroma.scale(chroma.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5]); - var h2 = document.createElement("h2"); + var linkScale = chroma.scale(chroma.bezier(['#04C714', '#FF5500', '#F02311'])).domain([1, 5]); + var h2 = document.createElement('h2'); h2.textContent = d.nodeinfo.hostname; el.appendChild(h2); - var attributes = document.createElement("table"); - attributes.classList.add("attributes"); + var attributes = document.createElement('table'); + attributes.classList.add('attributes'); - helper.attributeEntry(attributes, "Status", showStatus(d)); - helper.attributeEntry(attributes, "Gateway", d.flags.gateway ? "ja" : null); - helper.attributeEntry(attributes, "Koordinaten", showGeoURI(d)); + helper.attributeEntry(attributes, 'Status', showStatus(d)); + helper.attributeEntry(attributes, 'Gateway', d.flags.gateway ? 'ja' : null); + helper.attributeEntry(attributes, 'Koordinaten', showGeoURI(d)); if (config.nodeInfobox && config.nodeInfobox.contact) { - helper.attributeEntry(attributes, "Kontakt", helper.dictGet(d.nodeinfo, ["owner", "contact"])); + helper.attributeEntry(attributes, 'Kontakt', helper.dictGet(d.nodeinfo, ['owner', 'contact'])); } - helper.attributeEntry(attributes, "Hardware", helper.dictGet(d.nodeinfo, ["hardware", "model"])); - helper.attributeEntry(attributes, "Primäre MAC", helper.dictGet(d.nodeinfo, ["network", "mac"])); - helper.attributeEntry(attributes, "Node ID", helper.dictGet(d.nodeinfo, ["node_id"])); - helper.attributeEntry(attributes, "Firmware", showFirmware(d)); - helper.attributeEntry(attributes, "Site", showSite(d, config)); - helper.attributeEntry(attributes, "Uptime", showUptime(d)); - helper.attributeEntry(attributes, "Teil des Netzes", showFirstseen(d)); + helper.attributeEntry(attributes, 'Hardware', helper.dictGet(d.nodeinfo, ['hardware', 'model'])); + helper.attributeEntry(attributes, 'Primäre MAC', helper.dictGet(d.nodeinfo, ['network', 'mac'])); + helper.attributeEntry(attributes, 'Node ID', helper.dictGet(d.nodeinfo, ['node_id'])); + helper.attributeEntry(attributes, 'Firmware', showFirmware(d)); + helper.attributeEntry(attributes, 'Site', showSite(d, config)); + helper.attributeEntry(attributes, 'Uptime', showUptime(d)); + helper.attributeEntry(attributes, 'Teil des Netzes', showFirstseen(d)); if (config.nodeInfobox && config.nodeInfobox.hardwareUsage) { - helper.attributeEntry(attributes, "Systemlast", showLoad(d)); - helper.attributeEntry(attributes, "Arbeitsspeicher", showRAM(d)); + helper.attributeEntry(attributes, 'Systemlast', showLoad(d)); + helper.attributeEntry(attributes, 'Arbeitsspeicher', showRAM(d)); } - helper.attributeEntry(attributes, "IP Adressen", showIPs(d)); - helper.attributeEntry(attributes, "Gewähltes Gateway", helper.dictGet(d.statistics, ["gateway"])); - helper.attributeEntry(attributes, "Autom. Updates", showAutoupdate(d)); - helper.attributeEntry(attributes, "Clients", showClients(d)); + helper.attributeEntry(attributes, 'IP Adressen', showIPs(d)); + helper.attributeEntry(attributes, 'Gewähltes Gateway', helper.dictGet(d.statistics, ['gateway'])); + helper.attributeEntry(attributes, 'Autom. Updates', showAutoupdate(d)); + helper.attributeEntry(attributes, 'Clients', showClients(d)); el.appendChild(attributes); if (config.nodeInfos) { config.nodeInfos.forEach(function (nodeInfo) { - var h4 = document.createElement("h4"); + var h4 = document.createElement('h4'); h4.textContent = nodeInfo.name; el.appendChild(h4); el.appendChild(showStatImg(nodeInfo, d)); @@ -225,86 +225,86 @@ define(["chroma-js", "moment/moment", "tablesort", "helper", "moment/locale/de"] } if (d.neighbours.length > 0) { - var h3 = document.createElement("h3"); - h3.textContent = "Links (" + d.neighbours.length + ")"; + var h3 = document.createElement('h3'); + h3.textContent = 'Links (' + d.neighbours.length + ')'; el.appendChild(h3); - var table = document.createElement("table"); - var thead = document.createElement("thead"); + var table = document.createElement('table'); + var thead = document.createElement('thead'); - var tr = document.createElement("tr"); - var th1 = document.createElement("th"); - th1.textContent = " "; + var tr = document.createElement('tr'); + var th1 = document.createElement('th'); + th1.textContent = ' '; tr.appendChild(th1); - var th2 = document.createElement("th"); - th2.textContent = "Knoten"; - th2.classList.add("sort-default"); + var th2 = document.createElement('th'); + th2.textContent = 'Knoten'; + th2.classList.add('sort-default'); tr.appendChild(th2); - var th3 = document.createElement("th"); - th3.textContent = "TQ"; + var th3 = document.createElement('th'); + th3.textContent = 'TQ'; tr.appendChild(th3); - var th4 = document.createElement("th"); - th4.textContent = "Entfernung"; + var th4 = document.createElement('th'); + th4.textContent = 'Entfernung'; tr.appendChild(th4); thead.appendChild(tr); table.appendChild(thead); - var tbody = document.createElement("tbody"); + var tbody = document.createElement('tbody'); - d.neighbours.forEach(function (d) { - var unknown = !(d.node); - var tr = document.createElement("tr"); + d.neighbours.forEach(function (n) { + var unknown = !(n.node); + var tr1 = document.createElement('tr'); - var td1 = document.createElement("td"); + var td1 = document.createElement('td'); - var direction = document.createElement("span"); - direction.classList.add(d.incoming ? "ion-ios-arrow-thin-left" : "ion-ios-arrow-thin-right"); + var direction = document.createElement('span'); + direction.classList.add(n.incoming ? 'ion-ios-arrow-thin-left' : 'ion-ios-arrow-thin-right'); td1.appendChild(direction); - if (!unknown && helper.hasLocation(d.node)) { - var span = document.createElement("span"); - span.classList.add("ion-location"); + if (!unknown && helper.hasLocation(n.node)) { + var span = document.createElement('span'); + span.classList.add('ion-location'); td1.appendChild(span); } - tr.appendChild(td1); + tr1.appendChild(td1); - var td2 = document.createElement("td"); + var td2 = document.createElement('td'); if (!unknown) { - var a1 = document.createElement("a"); - a1.textContent = d.node.nodeinfo.hostname; - a1.classList.add("online"); - a1.href = "#"; - a1.onclick = router.node(d.node); + var a1 = document.createElement('a'); + a1.textContent = n.node.nodeinfo.hostname; + a1.classList.add('online'); + a1.href = '#'; + a1.onclick = router.node(n.node); td2.appendChild(a1); } else { - td2.textContent = d.id; + td2.textContent = n.id; } - tr.appendChild(td2); + tr1.appendChild(td2); - var td3 = document.createElement("td"); - td3.textContent = helper.showTq(d.link); - td3.style.color = linkScale(d.link.tq).hex(); - tr.appendChild(td3); + var td3 = document.createElement('td'); + td3.textContent = helper.showTq(n.link); + td3.style.color = linkScale(n.link.tq).hex(); + tr1.appendChild(td3); - var td4 = document.createElement("td"); - td4.textContent = helper.showDistance(d.link); - td4.setAttribute("data-sort", d.link.distance !== undefined ? -d.link.distance : 1); - tr.appendChild(td4); + var td4 = document.createElement('td'); + td4.textContent = helper.showDistance(n.link); + td4.setAttribute('data-sort', n.link.distance !== undefined ? -n.link.distance : 1); + tr1.appendChild(td4); tbody.appendChild(tr); }); table.appendChild(tbody); - table.classList.add("node-links"); + table.classList.add('node-links'); - Tablesort(table); + tablesort(table); el.appendChild(table); } diff --git a/lib/legend.js b/lib/legend.js index edf8093..9cf9878 100644 --- a/lib/legend.js +++ b/lib/legend.js @@ -1,44 +1,44 @@ -define(["helper"], function (helper) { - "use strict"; +define(['helper'], function (helper) { + 'use strict'; return function (config) { var self = this; - var stats = document.createTextNode(""); - var timestamp = document.createTextNode(""); + var stats = document.createTextNode(''); + var timestamp = document.createTextNode(''); - self.setData = function (d) { + self.setData = function setData(d) { var totalNodes = helper.sum(d.nodes.all.map(helper.one)); var totalOnlineNodes = helper.sum(d.nodes.all.filter(helper.online).map(helper.one)); - var totalClients = helper.sum(d.nodes.all.filter(helper.online).map(function (d) { - return d.statistics.clients ? d.statistics.clients : 0; + var totalClients = helper.sum(d.nodes.all.filter(helper.online).map(function (n) { + return n.statistics.clients ? n.statistics.clients : 0; })); - var totalGateways = helper.sum(d.nodes.all.filter(helper.online).filter(function (d) { - return d.flags.gateway; + var totalGateways = helper.sum(d.nodes.all.filter(helper.online).filter(function (n) { + return n.flags.gateway; }).map(helper.one)); - stats.textContent = totalNodes + " Knoten, " + - "davon " + totalOnlineNodes + " Knoten online " + - "mit " + totalClients + " Client" + ( totalClients === 1 ? " " : "s " ) + - "auf " + totalGateways + " Gateway" + ( totalGateways === 1 ? "" : "s" ); + stats.textContent = totalNodes + ' Knoten, ' + + 'davon ' + totalOnlineNodes + ' Knoten online ' + + 'mit ' + totalClients + ' Client' + ( totalClients === 1 ? ' ' : 's ' ) + + 'auf ' + totalGateways + ' Gateway' + ( totalGateways === 1 ? '' : 's' ); - timestamp.textContent = "Stand: " + d.timestamp.format("DD.MM.Y HH:mm"); + timestamp.textContent = 'Stand: ' + d.timestamp.format('DD.MM.Y HH:mm'); }; - self.render = function (el) { - var h2 = document.createElement("h2"); + self.render = function render(el) { + var h2 = document.createElement('h2'); h2.textContent = config.siteName; el.appendChild(h2); - var p = document.createElement("p"); - p.classList.add("legend"); + var p = document.createElement('p'); + p.classList.add('legend'); p.innerHTML = ' Neuer Knoten' + ' Knoten ist online' + ' Knoten ist offline'; el.appendChild(p); - p.appendChild(document.createElement("br")); + p.appendChild(document.createElement('br')); p.appendChild(stats); - p.appendChild(document.createElement("br")); + p.appendChild(document.createElement('br')); p.appendChild(timestamp); }; diff --git a/lib/linklist.js b/lib/linklist.js index 90f6b11..67503ab 100644 --- a/lib/linklist.js +++ b/lib/linklist.js @@ -1,56 +1,54 @@ -define(["sorttable", "virtual-dom", "helper"], function (SortTable, V, helper) { - "use strict"; +define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) { + 'use strict'; function linkName(d) { - return (d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + " – " + d.target.node.nodeinfo.hostname; + return (d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + ' – ' + d.target.node.nodeinfo.hostname; } var headings = [{ - name: "Knoten", + name: 'Knoten', sort: function (a, b) { return linkName(a).localeCompare(linkName(b)); }, reverse: false - }, - { - name: "TQ", - sort: function (a, b) { - return a.tq - b.tq; - }, - reverse: true + }, { + name: 'TQ', + sort: function (a, b) { + return a.tq - b.tq; }, - { - name: "Entfernung", - sort: function (a, b) { - return (a.distance === undefined ? -1 : a.distance) - - (b.distance === undefined ? -1 : b.distance); - }, - reverse: true - }]; + reverse: true + }, { + name: 'Entfernung', + sort: function (a, b) { + return (a.distance === undefined ? -1 : a.distance) - + (b.distance === undefined ? -1 : b.distance); + }, + reverse: true + }]; return function (linkScale, router) { var table = new SortTable(headings, 2, renderRow); - table.el.classList.add("link-list"); + table.el.classList.add('link-list'); function renderRow(d) { - var td1Content = [V.h("a", {href: "#", onclick: router.link(d)}, linkName(d))]; + var td1Content = [V.h('a', { href: '#', onclick: router.link(d) }, linkName(d))]; - var td1 = V.h("td", td1Content); - var td2 = V.h("td", {style: {color: linkScale(d.tq).hex()}}, helper.showTq(d)); - var td3 = V.h("td", helper.showDistance(d)); + var td1 = V.h('td', td1Content); + var td2 = V.h('td', { style: { color: linkScale(d.tq).hex() } }, helper.showTq(d)); + var td3 = V.h('td', helper.showDistance(d)); - return V.h("tr", [td1, td2, td3]); + return V.h('tr', [td1, td2, td3]); } - this.render = function (d) { - var h2 = document.createElement("h2"); - h2.textContent = "Verbindungen"; + this.render = function render(d) { + var h2 = document.createElement('h2'); + h2.textContent = 'Verbindungen'; d.appendChild(h2); d.appendChild(table.el); }; - this.setData = function (d) { + this.setData = function setData(d) { table.setData(d.graph.links); }; }; diff --git a/lib/locationmarker.js b/lib/locationmarker.js index a4a596f..f465a3a 100644 --- a/lib/locationmarker.js +++ b/lib/locationmarker.js @@ -1,10 +1,10 @@ -define(["leaflet"], function (L) { - "use strict"; +define(['leaflet'], function (L) { + 'use strict'; return L.CircleMarker.extend({ outerCircle: { stroke: false, - color: "#4285F4", + color: '#4285F4', opacity: 1, fillOpacity: 0.3, clickable: false, @@ -13,8 +13,8 @@ define(["leaflet"], function (L) { innerCircle: { stroke: true, - color: "#ffffff", - fillColor: "#4285F4", + color: '#ffffff', + fillColor: '#4285F4', weight: 1.5, clickable: false, opacity: 1, @@ -24,7 +24,7 @@ define(["leaflet"], function (L) { accuracyCircle: { stroke: true, - color: "#4285F4", + color: '#4285F4', weight: 1, clickable: false, opacity: 0.7, @@ -36,7 +36,7 @@ define(["leaflet"], function (L) { this.outerCircle = L.circleMarker(latlng, this.outerCircle); L.CircleMarker.prototype.initialize.call(this, latlng, this.innerCircle); - this.on("remove", function () { + this.on('remove', function () { this._map.removeLayer(this.accuracyCircle); this._map.removeLayer(this.outerCircle); }); diff --git a/lib/main.js b/lib/main.js index 60846d1..7f11ec1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,6 +1,6 @@ -define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de"], +define(['moment/moment', 'router', 'leaflet', 'gui', 'helper', 'moment/locale/de'], function (moment, Router, L, GUI, helper) { - "use strict"; + 'use strict'; return function (config) { function handleData(data) { @@ -20,8 +20,8 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de var vererr; if (i % 2) { if (data[i].version !== 1) { - vererr = "Unsupported graph version: " + data[i].version; - console.error(vererr); //silent fail + vererr = 'Unsupported graph version: ' + data[i].version; + console.error(vererr); // silent fail } else { data[i].batadv.links.forEach(rearrangeLinks); dataGraph.batadv.nodes = dataGraph.batadv.nodes.concat(data[i].batadv.nodes); @@ -29,8 +29,8 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de dataGraph.timestamp = data[i].timestamp; } } else if (data[i].version !== 2) { - vererr = "Unsupported nodes version: " + data[i].version; - console.error(vererr); //silent fail + vererr = 'Unsupported nodes version: ' + data[i].version; + console.error(vererr); // silent fail } else { dataNodes.nodes = dataNodes.nodes.concat(data[i].nodes); dataNodes.timestamp = data[i].timestamp; @@ -38,7 +38,7 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de } var nodes = dataNodes.nodes.filter(function (d) { - return "firstseen" in d && "lastseen" in d; + return 'firstseen' in d && 'lastseen' in d; }); nodes.forEach(function (node) { @@ -47,10 +47,10 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de }); var now = moment(); - var age = moment(now).subtract(config.maxAge, "days"); + var age = moment(now).subtract(config.maxAge, 'days'); - var newnodes = helper.limit("firstseen", age, helper.sortByKey("firstseen", nodes).filter(helper.online)); - var lostnodes = helper.limit("lastseen", age, helper.sortByKey("lastseen", nodes).filter(helper.offline)); + var newnodes = helper.limit('firstseen', age, helper.sortByKey('firstseen', nodes).filter(helper.online)); + var lostnodes = helper.limit('lastseen', age, helper.sortByKey('lastseen', nodes).filter(helper.offline)); var graphnodes = {}; @@ -88,11 +88,11 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de var unknown = (d.source.node === undefined); var ids; if (unknown) { - ids = [d.source.id.replace(/:/g, ""), d.target.node.nodeinfo.node_id]; + ids = [d.source.id.replace(/:/g, ''), d.target.node.nodeinfo.node_id]; } else { ids = [d.source.node.nodeinfo.node_id, d.target.node.nodeinfo.node_id]; } - d.id = ids.join("-"); + d.id = ids.join('-'); if (unknown || !d.source.node.nodeinfo.location || !d.target.node.nodeinfo.location || isNaN(d.source.node.nodeinfo.location.latitude) || @@ -115,18 +115,18 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de links.forEach(function (d) { if (d.target.node.flags.gateway === true || (d.source.node !== undefined && d.source.node.flags.gateway === true)) { - d.type = "fastd"; + d.type = 'fastd'; } else { - d.type = "N/A"; + d.type = 'N/A'; } var unknown = (d.source.node === undefined); if (unknown) { - d.target.node.neighbours.push({id: d.source.id, link: d, incoming: true}); + d.target.node.neighbours.push({ id: d.source.id, link: d, incoming: true }); return; } - d.source.node.neighbours.push({node: d.target.node, link: d, incoming: false}); - d.target.node.neighbours.push({node: d.source.node, link: d, incoming: true}); - if (d.type !== "fastd" && d.type !== "L2TP") { + d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false }); + d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true }); + if (d.type !== 'fastd' && d.type !== 'L2TP') { d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1; } }); @@ -150,19 +150,19 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de }; } - moment.locale("de"); + moment.locale('de'); var router = new Router(); var urls = []; - if (typeof config.dataPath === "string" || config.dataPath instanceof String) { + if (typeof config.dataPath === 'string' || config.dataPath instanceof String) { config.dataPath = [config.dataPath]; } for (var i in config.dataPath) { - urls.push(config.dataPath[i] + "nodes.json"); - urls.push(config.dataPath[i] + "graph.json"); + urls.push(config.dataPath[i] + 'nodes.json'); + urls.push(config.dataPath[i] + 'graph.json'); } function update() { @@ -178,9 +178,9 @@ define(["moment/moment", "router", "leaflet", "gui", "helper", "moment/locale/de router.start(); window.setInterval(function () { - update().then(function (d) { - gui.setData(d); - router.setData(d); + update().then(function (n) { + gui.setData(n); + router.setData(n); router.update(); }); }, 60000); diff --git a/lib/map.js b/lib/map.js index da162f4..53268c2 100644 --- a/lib/map.js +++ b/lib/map.js @@ -1,8 +1,6 @@ -define(["map/clientlayer", "map/labelslayer", - "leaflet", "moment/moment", "locationmarker", "rbush", "helper", - "leaflet.label", "moment/locale/de"], +define(['map/clientlayer', 'map/labelslayer', 'leaflet', 'moment/moment', 'locationmarker', 'rbush', 'helper', 'leaflet.label', 'moment/locale/de'], function (ClientLayer, LabelsLayer, L, moment, LocationMarker, rbush, helper) { - "use strict"; + 'use strict'; var options = { worldCopyJump: true, @@ -11,21 +9,21 @@ define(["map/clientlayer", "map/labelslayer", var LocateButton = L.Control.extend({ options: { - position: "bottomright" + position: 'bottomright' }, active: false, button: undefined, - initialize: function (f, options) { - L.Util.setOptions(this, options); + initialize: function (f, o) { + L.Util.setOptions(this, o); this.f = f; }, onAdd: function () { - var button = L.DomUtil.create("button", "ion-android-locate shadow"); + var button = L.DomUtil.create('button', 'ion-android-locate shadow'); L.DomEvent.disableClickPropagation(button); - L.DomEvent.addListener(button, "click", this.onClick, this); + L.DomEvent.addListener(button, 'click', this.onClick, this); this.button = button; @@ -33,7 +31,7 @@ define(["map/clientlayer", "map/labelslayer", }, update: function () { - this.button.classList.toggle("active", this.active); + this.button.classList.toggle('active', this.active); }, set: function (v) { @@ -48,23 +46,23 @@ define(["map/clientlayer", "map/labelslayer", var CoordsPickerButton = L.Control.extend({ options: { - position: "bottomright" + position: 'bottomright' }, active: false, button: undefined, - initialize: function (f, options) { - L.Util.setOptions(this, options); + initialize: function (f, o) { + L.Util.setOptions(this, o); this.f = f; }, onAdd: function () { - var button = L.DomUtil.create("button", "ion-pin shadow"); + var button = L.DomUtil.create('button', 'ion-pin shadow'); // Click propagation isn't disabled as this causes problems with the // location picking mode; instead propagation is stopped in onClick(). - L.DomEvent.addListener(button, "click", this.onClick, this); + L.DomEvent.addListener(button, 'click', this.onClick, this); this.button = button; @@ -72,7 +70,7 @@ define(["map/clientlayer", "map/labelslayer", }, update: function () { - this.button.classList.toggle("active", this.active); + this.button.classList.toggle('active', this.active); }, set: function (v) { @@ -91,11 +89,11 @@ define(["map/clientlayer", "map/labelslayer", return function (d) { var m = L.circleMarker([d.nodeinfo.location.latitude, d.nodeinfo.location.longitude], iconFunc(d)); - m.resetStyle = function () { + m.resetStyle = function resetStyle() { m.setStyle(iconFunc(d)); }; - m.on("click", router.node(d)); + m.on('click', router.node(d)); m.bindLabel(d.nodeinfo.hostname); dict[d.nodeinfo.node_id] = m; @@ -106,25 +104,25 @@ define(["map/clientlayer", "map/labelslayer", function addLinksToMap(dict, linkScale, graph, router) { graph = graph.filter(function (d) { - return "distance" in d && d.type !== "VPN"; + return 'distance' in d && d.type !== 'VPN'; }); return graph.map(function (d) { var opts = { - color: d.type === "Kabel" ? "#50B0F0" : linkScale(d.tq).hex(), + color: d.type === 'Kabel' ? '#50B0F0' : linkScale(d.tq).hex(), weight: 4, opacity: 0.5, - dashArray: "none" + dashArray: 'none' }; var line = L.polyline(d.latlngs, opts); - line.resetStyle = function () { + line.resetStyle = function resetStyle() { line.setStyle(opts); }; - line.bindLabel(d.source.node.nodeinfo.hostname + " – " + d.target.node.nodeinfo.hostname + "
" + helper.showDistance(d) + " / " + helper.showTq(d) + ""); - line.on("click", router.link(d)); + line.bindLabel(d.source.node.nodeinfo.hostname + ' – ' + d.target.node.nodeinfo.hostname + '
' + helper.showDistance(d) + ' / ' + helper.showTq(d) + ''); + line.on('click', router.link(d)); dict[d.id] = line; @@ -133,50 +131,55 @@ define(["map/clientlayer", "map/labelslayer", } var iconOnline = { - color: "#1566A9", - fillColor: "#1566A9", + color: '#1566A9', + fillColor: '#1566A9', radius: 6, fillOpacity: 0.5, opacity: 0.5, weight: 2, - className: "stroke-first" + className: 'stroke-first' }; var iconOffline = { - color: "#D43E2A", - fillColor: "#D43E2A", + color: '#D43E2A', + fillColor: '#D43E2A', radius: 3, fillOpacity: 0.5, opacity: 0.5, weight: 1, - className: "stroke-first" + className: 'stroke-first' }; var iconLost = { - color: "#D43E2A", - fillColor: "#D43E2A", + color: '#D43E2A', + fillColor: '#D43E2A', radius: 4, fillOpacity: 0.8, opacity: 0.8, weight: 1, - className: "stroke-first" + className: 'stroke-first' }; var iconAlert = { - color: "#D43E2A", - fillColor: "#D43E2A", + color: '#D43E2A', + fillColor: '#D43E2A', radius: 5, fillOpacity: 0.8, opacity: 0.8, weight: 2, - className: "stroke-first" + className: 'stroke-first' }; - var iconNew = {color: "#1566A9", fillColor: "#93E929", radius: 6, fillOpacity: 1.0, opacity: 0.5, weight: 2}; + var iconNew = { color: '#1566A9', fillColor: '#93E929', radius: 6, fillOpacity: 1.0, opacity: 0.5, weight: 2 }; return function (config, linkScale, sidebar, router, buttons) { var self = this; var barycenter; - var groupOnline, groupOffline, groupNew, groupLost, groupLines; + var groupOnline; + var groupOffline; + var groupNew; + var groupLost; + var groupLines; var savedView; - var map, userLocation; + var map; + var userLocation; var layerControl; var baseLayers = {}; @@ -233,14 +236,14 @@ define(["map/clientlayer", "map/labelslayer", } function enableCoords() { - map.getContainer().classList.add("pick-coordinates"); - map.on("click", showCoordinates); + map.getContainer().classList.add('pick-coordinates'); + map.on('click', showCoordinates); showCoordsPickerButton.set(true); } function disableCoords() { - map.getContainer().classList.remove("pick-coordinates"); - map.off("click", showCoordinates); + map.getContainer().classList.remove('pick-coordinates'); + map.off('click', showCoordinates); showCoordsPickerButton.set(false); } @@ -266,11 +269,11 @@ define(["map/clientlayer", "map/labelslayer", } function contextMenuOpenLayerMenu() { - document.querySelector(".leaflet-control-layers").classList.add("leaflet-control-layers-expanded"); + document.querySelector('.leaflet-control-layers').classList.add('leaflet-control-layers-expanded'); } - var el = document.createElement("div"); - el.classList.add("map"); + var el = document.createElement('div'); + el.classList.add('map'); map = L.map(el, options); var now = new Date(); @@ -288,8 +291,8 @@ define(["map/clientlayer", "map/labelslayer", var layers = config.mapLayers.map(function (d) { return { - "name": d.name, - "layer": "url" in d ? L.tileLayer(d.url.replace("{retina}", L.Browser.retina ? '@2x' : ''), d.config) : console.warn("Missing map url") + 'name': d.name, + 'layer': 'url' in d ? L.tileLayer(d.url.replace('{retina}', L.Browser.retina ? '@2x' : ''), d.config) : console.warn('Missing map url') }; }); @@ -299,18 +302,18 @@ define(["map/clientlayer", "map/labelslayer", baseLayers[d.name] = d.layer; }); - map.on("locationfound", locationFound); - map.on("locationerror", locationError); - map.on("dragend", saveView); - map.on("contextmenu", contextMenuOpenLayerMenu); + map.on('locationfound', locationFound); + map.on('locationerror', locationError); + map.on('dragend', saveView); + map.on('contextmenu', contextMenuOpenLayerMenu); addButton(locateUserButton); addButton(showCoordsPickerButton); - layerControl = L.control.layers(baseLayers, [], {position: "bottomright"}); + layerControl = L.control.layers(baseLayers, [], { position: 'bottomright' }); layerControl.addTo(map); - var clientLayer = new ClientLayer({minZoom: 15}); + var clientLayer = new ClientLayer({ minZoom: 15 }); clientLayer.addTo(map); clientLayer.setZIndex(5); @@ -318,7 +321,7 @@ define(["map/clientlayer", "map/labelslayer", labelsLayer.addTo(map); labelsLayer.setZIndex(6); - map.on("baselayerchange", function (e) { + map.on('baselayerchange', function (e) { map.options.maxZoom = e.layer.options.maxZoom; clientLayer.options.maxZoom = map.options.maxZoom; labelsLayer.options.maxZoom = map.options.maxZoom; @@ -326,20 +329,20 @@ define(["map/clientlayer", "map/labelslayer", map.setZoom(map.options.maxZoom); } if (helper.localStorageTest()) { - localStorage.setItem("map/selectedLayer", JSON.stringify({name: e.name})); + localStorage.setItem('map/selectedLayer', JSON.stringify({ name: e.name })); } - var cssMode = document.querySelector(".css-mode"); + var cssMode = document.querySelector('.css-mode'); if (cssMode) { cssMode.parentNode.removeChild(cssMode); - document.querySelector("html").className = ''; + document.querySelector('html').className = ''; labelsLayer.updateLayer(); } if (e.layer.options.mode) { - document.querySelector("head").innerHTML += ""; - document.querySelector("html").classList.add(e.layer.options.mode); + document.querySelector('head').innerHTML += ""; + document.querySelector('html').classList.add(e.layer.options.mode); var cssInterval = setInterval(function () { - if (typeof document.querySelector(".css-mode").sheet.cssRules != 'undefined') { + if (typeof document.querySelector('.css-mode').sheet.cssRules !== 'undefined') { labelsLayer.updateLayer(); clearInterval(cssInterval); } @@ -362,7 +365,7 @@ define(["map/clientlayer", "map/labelslayer", } function setView(bounds) { - map.fitBounds(bounds, {paddingTopLeft: [sidebar(), 0], maxZoom: config.nodeZoom}); + map.fitBounds(bounds, { paddingTopLeft: [sidebar(), 0], maxZoom: config.nodeZoom }); } function resetZoom() { @@ -374,7 +377,7 @@ define(["map/clientlayer", "map/labelslayer", function goto(m) { var bounds; - if ("getBounds" in m) { + if ('getBounds' in m) { bounds = m.getBounds(); } else { bounds = L.latLngBounds([m.getLatLng()]); @@ -390,17 +393,17 @@ define(["map/clientlayer", "map/labelslayer", var m; if (highlight !== undefined) { - if (highlight.type === "node") { + if (highlight.type === 'node') { m = nodeDict[highlight.o.nodeinfo.node_id]; if (m) { - m.setStyle({color: "orange", weight: 20, fillOpacity: 1, opacity: 0.7, className: "stroke-first"}); + m.setStyle({ color: 'orange', weight: 20, fillOpacity: 1, opacity: 0.7, className: 'stroke-first' }); } - } else if (highlight.type === "link") { + } else if (highlight.type === 'link') { m = linkDict[highlight.o.id]; if (m) { - m.setStyle({weight: 4, opacity: 1, dashArray: "5, 10"}); + m.setStyle({ weight: 4, opacity: 1, dashArray: '5, 10' }); } } } @@ -425,7 +428,7 @@ define(["map/clientlayer", "map/labelslayer", return o; } - self.setData = function (data) { + self.setData = function setData(data) { nodeDict = {}; linkDict = {}; @@ -452,7 +455,7 @@ define(["map/clientlayer", "map/labelslayer", var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router); groupLines = L.featureGroup(lines).addTo(map); - if (typeof config.fixedCenter === "undefined") { + if (typeof config.fixedCenter === 'undefined') { console.error('FixedCenter is required'); } else { barycenter = L.circle(L.latLng(new L.LatLng(config.fixedCenter.lat, config.fixedCenter.lng)), config.fixedCenter.radius * 1000); @@ -478,13 +481,14 @@ define(["map/clientlayer", "map/labelslayer", var markersLost = data.nodes.lost.filter(helper.hasLocation) .map(mkMarker(nodeDict, function (d) { - if (d.lastseen.isAfter(moment(data.now).subtract(3, "days"))) { + if (d.lastseen.isAfter(moment(data.now).subtract(3, 'days'))) { return iconAlert; } - if (d.lastseen.isAfter(moment(data.now).subtract(14, "days"))) { + if (d.lastseen.isAfter(moment(data.now).subtract(14, 'days'))) { return iconLost; } + return null; }, router)); groupOffline = L.featureGroup(markersOffline).addTo(map); @@ -507,29 +511,29 @@ define(["map/clientlayer", "map/labelslayer", updateView(true); }; - self.resetView = function () { + self.resetView = function resetView() { disableTracking(); highlight = undefined; updateView(); }; - self.gotoNode = function (d, update) { + self.gotoNode = function gotoNode(d, update) { disableTracking(); - highlight = {type: "node", o: d}; + highlight = { type: 'node', o: d }; updateView(update); }; - self.gotoLink = function (d, update) { + self.gotoLink = function gotoLink(d, update) { disableTracking(); - highlight = {type: "link", o: d}; + highlight = { type: 'link', o: d }; updateView(update); }; - self.gotoLocation = function () { - //ignore + self.gotoLocation = function gotoLocation() { + // ignore }; - self.destroy = function () { + self.destroy = function destroy() { clearButtons(); map.remove(); @@ -538,7 +542,7 @@ define(["map/clientlayer", "map/labelslayer", } }; - self.render = function (d) { + self.render = function render(d) { d.appendChild(el); map.invalidateSize(); }; diff --git a/lib/map/clientlayer.js b/lib/map/clientlayer.js index 1dc8cb7..1773b3f 100644 --- a/lib/map/clientlayer.js +++ b/lib/map/clientlayer.js @@ -1,14 +1,14 @@ -define(["leaflet"], +define(['leaflet'], function (L) { - "use strict"; + 'use strict'; return L.TileLayer.Canvas.extend({ setData: function (d) { this.data = d; - //pre-calculate start angles - this.data.all().forEach(function (d) { - d.startAngle = (parseInt(d.node.nodeinfo.node_id.substr(10, 2), 16) / 255) * 2 * Math.PI; + // pre-calculate start angles + this.data.all().forEach(function (n) { + n.startAngle = (parseInt(n.node.nodeinfo.node_id.substr(10, 2), 16) / 255) * 2 * Math.PI; }); this.redraw(); }, @@ -37,7 +37,7 @@ define(["leaflet"], return; } - var ctx = canvas.getContext("2d"); + var ctx = canvas.getContext('2d'); var radius = 3; var a = 1.2; @@ -71,7 +71,7 @@ define(["leaflet"], } }); - ctx.fillStyle = "rgba(220, 0, 103, 0.7)"; + ctx.fillStyle = 'rgba(220, 0, 103, 0.7)'; ctx.fill(); } }); diff --git a/lib/map/labelslayer.js b/lib/map/labelslayer.js index f6fa95f..2382522 100644 --- a/lib/map/labelslayer.js +++ b/lib/map/labelslayer.js @@ -1,24 +1,24 @@ -define(["leaflet", "rbush"], +define(['leaflet', 'rbush'], function (L, rbush) { - "use strict"; + 'use strict'; - var labelLocations = [["left", "middle", 0 / 8], - ["center", "top", 6 / 8], - ["right", "middle", 4 / 8], - ["left", "top", 7 / 8], - ["left", "ideographic", 1 / 8], - ["right", "top", 5 / 8], - ["center", "ideographic", 2 / 8], - ["right", "ideographic", 3 / 8]]; + var labelLocations = [['left', 'middle', 0 / 8], + ['center', 'top', 6 / 8], + ['right', 'middle', 4 / 8], + ['left', 'top', 7 / 8], + ['left', 'ideographic', 1 / 8], + ['right', 'top', 5 / 8], + ['center', 'ideographic', 2 / 8], + ['right', 'ideographic', 3 / 8]]; var bodyStyle = window.getComputedStyle(document.querySelector('body')); var labelShadow; var nodeRadius = 4; - var ctx = document.createElement("canvas").getContext("2d"); + var cFont = document.createElement('canvas').getContext('2d'); function measureText(font, text) { - ctx.font = font; - return ctx.measureText(text); + cFont.font = font; + return cFont.measureText(text); } function mapRTree(d) { @@ -31,7 +31,7 @@ define(["leaflet", "rbush"], function prepareLabel(fillStyle, fontSize, offset, stroke, minZoom) { return function (d) { - var font = fontSize + "px " + bodyStyle.fontFamily; + var font = fontSize + 'px ' + bodyStyle.fontFamily; return { position: L.latLng(d.nodeinfo.location.latitude, d.nodeinfo.location.longitude), label: d.nodeinfo.hostname, @@ -103,10 +103,10 @@ define(["leaflet", "rbush"], // - color (string) var labelsOnline = d.online.map(prepareLabel(bodyStyle.color, 11, 8, true, 13)); - var labelsOffline = d.offline.map(prepareLabel("rgba(212, 62, 42, 0.9)", 9, 5, false, 16)); - var labelsNew = d.new.map(prepareLabel("rgba(48, 99, 20, 0.9)", 11, 8, true, 0)); - var labelsLost = d.lost.map(prepareLabel("rgba(212, 62, 42, 0.9)", 11, 8, true, 0)); - labelShadow = bodyStyle.backgroundColor.replace(/rgb/i, "rgba").replace(/\)/i, ',0.7)'); + var labelsOffline = d.offline.map(prepareLabel('rgba(212, 62, 42, 0.9)', 9, 5, false, 16)); + var labelsNew = d.new.map(prepareLabel('rgba(48, 99, 20, 0.9)', 11, 8, true, 0)); + var labelsLost = d.lost.map(prepareLabel('rgba(212, 62, 42, 0.9)', 11, 8, true, 0)); + labelShadow = bodyStyle.backgroundColor.replace(/rgb/i, 'rgba').replace(/\)/i, ',0.7)'); var labels = [] .concat(labelsNew) @@ -122,8 +122,8 @@ define(["leaflet", "rbush"], var map = this._map; function nodeToRect(z) { - return function (d) { - var p = map.project(d.position, z); + return function (n) { + var p = map.project(n.position, z); return [p.x - nodeRadius, p.y - nodeRadius, p.x + nodeRadius, p.y + nodeRadius]; }; @@ -134,52 +134,51 @@ define(["leaflet", "rbush"], trees[z].load(labels.map(nodeToRect(z))); } - labels = labels.map(function (d) { + labels = labels.map(function (n) { var best = labelLocations.map(function (loc) { - var offset = calcOffset(d.offset, loc); - var z; + var offset = calcOffset(n.offset, loc); + var i; - for (z = maxZoom; z >= d.minZoom; z--) { - var p = map.project(d.position, z); - var rect = labelRect(p, offset, loc, d, minZoom, maxZoom, z); - var candidates = trees[z].search(rect); + for (i = maxZoom; i >= n.minZoom; i--) { + var p = map.project(n.position, i); + var rect = labelRect(p, offset, loc, n, minZoom, maxZoom, i); + var candidates = trees[i].search(rect); if (candidates.length > 0) { break; } } - return {loc: loc, z: z + 1}; - }).filter(function (d) { - return d.z <= maxZoom; + return { loc: loc, z: i + 1 }; + }).filter(function (k) { + return k.z <= maxZoom; }).sort(function (a, b) { return a.z - b.z; })[0]; if (best !== undefined) { - d.offset = calcOffset(d.offset, best.loc); - d.minZoom = best.z; - d.anchor = best.loc; + n.offset = calcOffset(n.offset, best.loc); + n.minZoom = best.z; + n.anchor = best.loc; - for (var z = maxZoom; z >= best.z; z--) { - var p = map.project(d.position, z); - var rect = labelRect(p, d.offset, best.loc, d, minZoom, maxZoom, z); - trees[z].insert(rect); + for (var i = maxZoom; i >= best.z; i--) { + var p = map.project(n.position, i); + var rect = labelRect(p, n.offset, best.loc, n, minZoom, maxZoom, i); + trees[i].insert(rect); } - return d; - } else { - return undefined; + return n; } - }).filter(function (d) { - return d !== undefined; + return undefined; + }).filter(function (n) { + return n !== undefined; }); this.margin = 16; if (labels.length > 0) { - this.margin += labels.map(function (d) { - return d.width; + this.margin += labels.map(function (n) { + return n.width; }).sort().reverse()[0]; } @@ -210,14 +209,14 @@ define(["leaflet", "rbush"], p.x -= s.x; p.y -= s.y; - return {p: p, label: d.label}; + return { p: p, label: d.label }; } var bbox = getTileBBox(s, map, tileSize, this.margin); var labels = this.labels.search(bbox).map(projectNodes); - var ctx = canvas.getContext("2d"); + var ctx = canvas.getContext('2d'); ctx.lineWidth = 5; ctx.strokeStyle = labelShadow; diff --git a/lib/nodelist.js b/lib/nodelist.js index fdf1f71..a99a9b6 100644 --- a/lib/nodelist.js +++ b/lib/nodelist.js @@ -1,23 +1,24 @@ -define(["sorttable", "virtual-dom", "helper"], function (SortTable, V, helper) { - "use strict"; +define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) { + 'use strict'; function getUptime(now, d) { - if (d.flags.online && "uptime" in d.statistics) { + if (d.flags.online && 'uptime' in d.statistics) { return Math.round(d.statistics.uptime); - } else if (!d.flags.online && "lastseen" in d) { + } else if (!d.flags.online && 'lastseen' in d) { return Math.round(-(now.unix() - d.lastseen.unix())); } + return 0; } function showUptime(uptime) { - var s = ""; + var s = ''; uptime /= 3600; if (uptime !== undefined) { if (Math.abs(uptime) >= 24) { - s = Math.round(uptime / 24) + "d"; + s = Math.round(uptime / 24) + 'd'; } else { - s = Math.round(uptime) + "h"; + s = Math.round(uptime) + 'h'; } } @@ -27,75 +28,72 @@ define(["sorttable", "virtual-dom", "helper"], function (SortTable, V, helper) { var headings = [{ name: '' }, { - name: "Knoten", + name: 'Knoten', sort: function (a, b) { return a.nodeinfo.hostname.localeCompare(b.nodeinfo.hostname); }, reverse: false - }, - { - name: "Uptime", - sort: function (a, b) { - return a.uptime - b.uptime; - }, - reverse: true + }, { + name: 'Uptime', + sort: function (a, b) { + return a.uptime - b.uptime; }, - { - name: "#Links", - sort: function (a, b) { - return a.meshlinks - b.meshlinks; - }, - reverse: true + reverse: true + }, { + name: '#Links', + sort: function (a, b) { + return a.meshlinks - b.meshlinks; }, - { - name: "Clients", - sort: function (a, b) { - return ("clients" in a.statistics ? a.statistics.clients : -1) - - ("clients" in b.statistics ? b.statistics.clients : -1); - }, - reverse: true - }]; + reverse: true + }, { + name: 'Clients', + sort: function (a, b) { + return ('clients' in a.statistics ? a.statistics.clients : -1) - + ('clients' in b.statistics ? b.statistics.clients : -1); + }, + reverse: true + }]; return function (router) { function renderRow(d) { var td0Content = []; var td1Content = []; - var aClass = ["hostname", d.flags.online ? "online" : "offline"]; + var aClass = ['hostname', d.flags.online ? 'online' : 'offline']; - td1Content.push(V.h("a", { - className: aClass.join(" "), + td1Content.push(V.h('a', { + className: aClass.join(' '), onclick: router.node(d), - href: "#" + href: '#' }, d.nodeinfo.hostname)); if (helper.hasLocation(d)) { - td0Content.push(V.h("span", {className: "icon ion-location"})); + td0Content.push(V.h('span', { className: 'icon ion-location' })); } - var td0 = V.h("td", td0Content); - var td1 = V.h("td", td1Content); - var td2 = V.h("td", showUptime(d.uptime)); - var td3 = V.h("td", d.meshlinks.toString()); - var td4 = V.h("td", Number("clients" in d.statistics ? d.statistics.clients : 0).toFixed(0)); + var td0 = V.h('td', td0Content); + var td1 = V.h('td', td1Content); + var td2 = V.h('td', showUptime(d.uptime)); + var td3 = V.h('td', d.meshlinks.toString()); + var td4 = V.h('td', Number('clients' in d.statistics ? d.statistics.clients : 0).toFixed(0)); - return V.h("tr", [td0, td1, td2, td3, td4]); + return V.h('tr', [td0, td1, td2, td3, td4]); } var table = new SortTable(headings, 1, renderRow); table.el.classList.add('node-list'); - this.render = function (d) { - var h2 = document.createElement("h2"); - h2.textContent = "Alle Knoten"; + this.render = function render(d) { + var h2 = document.createElement('h2'); + h2.textContent = 'Alle Knoten'; d.appendChild(h2); d.appendChild(table.el); }; - this.setData = function (d) { + this.setData = function setData(d) { var data = d.nodes.all.map(function (e) { var n = Object.create(e); - n.uptime = getUptime(d.now, e) || 0; + n.uptime = getUptime(d.now, e); n.meshlinks = e.meshlinks || 0; return n; }); diff --git a/lib/proportions.js b/lib/proportions.js index 31d4539..f3dfca2 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -1,28 +1,28 @@ -define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], +define(['chroma-js', 'virtual-dom', 'filters/genericnode', 'helper'], function (Chroma, V, Filter, helper) { - "use strict"; + 'use strict'; return function (config, filterManager) { var self = this; - var scale = Chroma.scale("YlGnBu").mode("lab"); + var scale = Chroma.scale('YlGnBu').mode('lab'); - var statusTable = document.createElement("table"); - statusTable.classList.add("proportion"); + var statusTable = document.createElement('table'); + statusTable.classList.add('proportion'); - var fwTable = document.createElement("table"); - fwTable.classList.add("proportion"); + var fwTable = document.createElement('table'); + fwTable.classList.add('proportion'); - var hwTable = document.createElement("table"); - hwTable.classList.add("proportion"); + var hwTable = document.createElement('table'); + hwTable.classList.add('proportion'); - var geoTable = document.createElement("table"); - geoTable.classList.add("proportion"); + var geoTable = document.createElement('table'); + geoTable.classList.add('proportion'); - var autoTable = document.createElement("table"); - autoTable.classList.add("proportion"); + var autoTable = document.createElement('table'); + autoTable.classList.add('proportion'); - var siteTable = document.createElement("table"); - siteTable.classList.add("proportion"); + var siteTable = document.createElement('table'); + siteTable.classList.add('proportion'); function showStatGlobal(o) { return helper.showStat(o); @@ -60,7 +60,7 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], function fillTable(name, table, data) { if (!table.last) { - table.last = V.h("table"); + table.last = V.h('table'); } var max = 0; @@ -72,31 +72,31 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], var items = data.map(function (d) { var v = d[1] / max; - var c1 = Chroma.contrast(scale(v), "white"); - var c2 = Chroma.contrast(scale(v), "black"); + var c1 = Chroma.contrast(scale(v), 'white'); + var c2 = Chroma.contrast(scale(v), 'black'); var filter = new Filter(name, d[2], d[0], d[3]); - var a = V.h("a", {href: "#", onclick: addFilter(filter)}, d[0]); + var a = V.h('a', { href: '#', onclick: addFilter(filter) }, d[0]); - var th = V.h("th", a); - var td = V.h("td", V.h("span", { + var th = V.h('th', a); + var td = V.h('td', V.h('span', { style: { - width: Math.round(v * 100) + "%", + width: Math.round(v * 100) + '%', backgroundColor: scale(v).hex(), - color: c1 > c2 ? "white" : "black" + color: c1 > c2 ? 'white' : 'black' } }, d[1].toFixed(0))); - return V.h("tr", [th, td]); + return V.h('tr', [th, td]); }); - var tableNew = V.h("table", items); + var tableNew = V.h('table', items); table = V.patch(table, V.diff(table.last, tableNew)); table.last = tableNew; } - self.setData = function (data) { + self.setData = function setData(data) { var onlineNodes = data.nodes.all.filter(helper.online); var nodes = onlineNodes.concat(data.nodes.lost); var nodeDict = {}; @@ -105,26 +105,25 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], nodeDict[d.nodeinfo.node_id] = d; }); - var statusDict = count(nodes, ["flags", "online"], function (d) { - return d ? "online" : "offline"; + var statusDict = count(nodes, ['flags', 'online'], function (d) { + return d ? 'online' : 'offline'; }); - var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"]); - var hwDict = count(nodes, ["nodeinfo", "hardware", "model"]); - var geoDict = count(nodes, ["nodeinfo", "location"], function (d) { - return d && d.longitude && d.latitude ? "ja" : "nein"; + var fwDict = count(nodes, ['nodeinfo', 'software', 'firmware', 'release']); + var hwDict = count(nodes, ['nodeinfo', 'hardware', 'model']); + var geoDict = count(nodes, ['nodeinfo', 'location'], function (d) { + return d && d.longitude && d.latitude ? 'ja' : 'nein'; }); - var autoDict = count(nodes, ["nodeinfo", "software", "autoupdater"], function (d) { + var autoDict = count(nodes, ['nodeinfo', 'software', 'autoupdater'], function (d) { if (d === null) { return null; } else if (d.enabled) { return d.branch; - } else { - return "(deaktiviert)"; } + return '(deaktiviert)'; }); - var siteDict = count(nodes, ["nodeinfo", "system", "site_code"], function (d) { + var siteDict = count(nodes, ['nodeinfo', 'system', 'site_code'], function (d) { var rt = d; if (config.siteNames) { config.siteNames.forEach(function (t) { @@ -136,10 +135,10 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], return rt; }); - fillTable("Status", statusTable, statusDict.sort(function (a, b) { + fillTable('Status', statusTable, statusDict.sort(function (a, b) { return b[1] - a[1]; })); - fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { + fillTable('Firmware', fwTable, fwDict.sort(function (a, b) { if (b[0] < a[0]) { return -1; } @@ -148,32 +147,32 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], } return 0; })); - fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { + fillTable('Hardware', hwTable, hwDict.sort(function (a, b) { return b[1] - a[1]; })); - fillTable("Koordinaten", geoTable, geoDict.sort(function (a, b) { + fillTable('Koordinaten', geoTable, geoDict.sort(function (a, b) { return b[1] - a[1]; })); - fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { + fillTable('Autom. Updates', autoTable, autoDict.sort(function (a, b) { return b[1] - a[1]; })); - fillTable("Site", siteTable, siteDict.sort(function (a, b) { + fillTable('Site', siteTable, siteDict.sort(function (a, b) { return b[1] - a[1]; })); }; - self.render = function (el) { + self.render = function render(el) { var h2; - self.renderSingle(el, "Status", statusTable); - self.renderSingle(el, "Firmwareversionen", fwTable); - self.renderSingle(el, "Hardwaremodelle", hwTable); - self.renderSingle(el, "Auf der Karte sichtbar", geoTable); - self.renderSingle(el, "Autoupdater", autoTable); - self.renderSingle(el, "Site", siteTable); + self.renderSingle(el, 'Status', statusTable); + self.renderSingle(el, 'Firmwareversionen', fwTable); + self.renderSingle(el, 'Hardwaremodelle', hwTable); + self.renderSingle(el, 'Auf der Karte sichtbar', geoTable); + self.renderSingle(el, 'Autoupdater', autoTable); + self.renderSingle(el, 'Site', siteTable); if (config.globalInfos) { config.globalInfos.forEach(function (globalInfo) { - h2 = document.createElement("h2"); + h2 = document.createElement('h2'); h2.textContent = globalInfo.name; el.appendChild(h2); el.appendChild(showStatGlobal(globalInfo)); @@ -181,12 +180,12 @@ define(["chroma-js", "virtual-dom", "filters/genericnode", "helper"], } }; - self.renderSingle = function (el, heading, table) { + self.renderSingle = function renderSingle(el, heading, table) { var h2; - h2 = document.createElement("h2"); + h2 = document.createElement('h2'); h2.textContent = heading; - h2.onclick = function () { - table.classList.toggle("hidden"); + h2.onclick = function onclick() { + table.classList.toggle('hidden'); }; el.appendChild(h2); el.appendChild(table); diff --git a/lib/router.js b/lib/router.js index 849ad8e..f6e58ff 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,9 +1,9 @@ -define(["helper"], function (helper) { - "use strict"; +define(['helper'], function (helper) { + 'use strict'; return function () { var self = this; - var objects = {nodes: {}, links: {}}; + var objects = { nodes: {}, links: {} }; var targets = []; var views = {}; var currentView; @@ -14,20 +14,20 @@ define(["helper"], function (helper) { var e = []; if (currentView) { - e.push("v:" + currentView); + e.push('v:' + currentView); } if (currentObject) { - if ("node" in currentObject) { - e.push("n:" + encodeURIComponent(currentObject.node.nodeinfo.node_id)); + if ('node' in currentObject) { + e.push('n:' + encodeURIComponent(currentObject.node.nodeinfo.node_id)); } - if ("link" in currentObject) { - e.push("l:" + encodeURIComponent(currentObject.link.id)); + if ('link' in currentObject) { + e.push('l:' + encodeURIComponent(currentObject.link.id)); } } - var s = "#!" + e.join(";"); + var s = '#!' + e.join(';'); window.history.pushState(s, undefined, s); } @@ -76,7 +76,7 @@ define(["helper"], function (helper) { targets.forEach(function (t) { if (!t.gotoLocation) { - console.warn("has no gotoLocation", t); + console.warn('has no gotoLocation', t); } t.gotoLocation(d); }); @@ -91,35 +91,35 @@ define(["helper"], function (helper) { s = decodeURIComponent(s); - if (!s.startsWith("#!")) { + if (!s.startsWith('#!')) { return false; } var targetSet = false; - s.slice(2).split(";").forEach(function (d) { - var args = d.split(":"); + s.slice(2).split(';').forEach(function (d) { + var args = d.split(':'); - if (update !== true && args[0] === "v" && args[1] in views) { + if (update !== true && args[0] === 'v' && args[1] in views) { currentView = args[1]; views[args[1]](); } var id; - if (args[0] === "n") { + if (args[0] === 'n') { id = args[1]; if (id in objects.nodes) { - currentObject = {node: objects.nodes[id]}; + currentObject = { node: objects.nodes[id] }; gotoNode(objects.nodes[id], update); targetSet = true; } } - if (args[0] === "l") { + if (args[0] === 'l') { id = args[1]; if (id in objects.links) { - currentObject = {link: objects.links[id]}; + currentObject = { link: objects.links[id] }; gotoLink(objects.links[id], update); targetSet = true; } @@ -129,21 +129,21 @@ define(["helper"], function (helper) { return targetSet; } - self.start = function () { + self.start = function start() { running = true; if (!loadState(window.location.hash)) { resetView(false); } - window.onpopstate = function (d) { + window.onpopstate = function onpopstate(d) { if (!loadState(d.state)) { resetView(false); } }; }; - self.view = function (d) { + self.view = function view(d) { if (d in views) { views[d](); @@ -162,20 +162,20 @@ define(["helper"], function (helper) { return; } - if ("node" in currentObject) { + if ('node' in currentObject) { gotoNode(currentObject.node); } - if ("link" in currentObject) { + if ('link' in currentObject) { gotoLink(currentObject.link); } } }; - self.node = function (d) { + self.node = function node(d) { return function () { if (gotoNode(d)) { - currentObject = {node: d}; + currentObject = { node: d }; saveState(); } @@ -183,10 +183,10 @@ define(["helper"], function (helper) { }; }; - self.link = function (d) { + self.link = function link(d) { return function () { if (gotoLink(d)) { - currentObject = {link: d}; + currentObject = { link: d }; saveState(); } @@ -196,25 +196,25 @@ define(["helper"], function (helper) { self.gotoLocation = gotoLocation; - self.reset = function () { + self.reset = function reset() { resetView(); }; - self.addTarget = function (d) { + self.addTarget = function addTarget(d) { targets.push(d); }; - self.removeTarget = function (d) { + self.removeTarget = function removeTarget(d) { targets = targets.filter(function (e) { return d !== e; }); }; - self.addView = function (k, d) { + self.addView = function addView(k, d) { views[k] = d; }; - self.setData = function (data) { + self.setData = function setData(data) { objects.nodes = {}; objects.links = {}; @@ -225,10 +225,9 @@ define(["helper"], function (helper) { data.graph.links.forEach(function (d) { objects.links[d.id] = d; }); - }; - self.update = function () { + self.update = function update() { loadState(window.location.hash, true); }; diff --git a/lib/sidebar.js b/lib/sidebar.js index c303bc7..1924c88 100644 --- a/lib/sidebar.js +++ b/lib/sidebar.js @@ -1,48 +1,48 @@ define(function () { - "use strict"; + 'use strict'; return function (el) { var self = this; - var sidebar = document.createElement("div"); - sidebar.classList.add("sidebar"); + var sidebar = document.createElement('div'); + sidebar.classList.add('sidebar'); el.appendChild(sidebar); - var button = document.createElement("button"); + var button = document.createElement('button'); sidebar.appendChild(button); - button.classList.add("sidebarhandle", "shadow"); - button.onclick = function () { - sidebar.classList.toggle("hidden"); + button.classList.add('sidebarhandle', 'shadow'); + button.onclick = function onclick() { + sidebar.classList.toggle('hidden'); }; - var container = document.createElement("div"); - container.classList.add("container"); + var container = document.createElement('div'); + container.classList.add('container'); sidebar.appendChild(container); - self.getWidth = function () { - if (sidebar.classList.contains("hidden")) { + self.getWidth = function getWidth() { + if (sidebar.classList.contains('hidden')) { return 0; } - var small = window.matchMedia("(max-width: 630pt)"); + var small = window.matchMedia('(max-width: 630pt)'); return small.matches ? 0 : sidebar.offsetWidth; }; - self.add = function (d) { + self.add = function add(d) { d.render(container); }; - self.ensureVisible = function () { - sidebar.classList.remove("hidden"); + self.ensureVisible = function ensureVisible() { + sidebar.classList.remove('hidden'); }; - self.hide = function () { - container.classList.add("hidden"); + self.hide = function hide() { + container.classList.add('hidden'); }; - self.reveal = function () { - container.classList.remove("hidden"); + self.reveal = function reveal() { + container.classList.remove('hidden'); }; self.container = sidebar; diff --git a/lib/simplenodelist.js b/lib/simplenodelist.js index 528fae4..26c4f5b 100644 --- a/lib/simplenodelist.js +++ b/lib/simplenodelist.js @@ -1,15 +1,16 @@ -define(["moment/moment", "virtual-dom", "helper", "moment/locale/de"], function (moment, V, helper) { - "use strict"; +define(['moment/moment', 'virtual-dom', 'helper', 'moment/locale/de'], function (moment, V, helper) { + 'use strict'; return function (nodes, field, router, title) { var self = this; - var el, tbody; + var el; + var tbody; - self.render = function (d) { + self.render = function render(d) { el = d; }; - self.setData = function (data) { + self.setData = function setData(data) { var list = data.nodes[nodes]; if (list.length === 0) { @@ -18,16 +19,16 @@ define(["moment/moment", "virtual-dom", "helper", "moment/locale/de"], function } if (!tbody) { - var h2 = document.createElement("h2"); + var h2 = document.createElement('h2'); h2.textContent = title; el.appendChild(h2); - var table = document.createElement("table"); - table.classList.add("node-list"); + var table = document.createElement('table'); + table.classList.add('node-list'); el.appendChild(table); - tbody = document.createElement("tbody"); - tbody.last = V.h("tbody"); + tbody = document.createElement('tbody'); + tbody.last = V.h('tbody'); table.appendChild(tbody); } @@ -36,26 +37,26 @@ define(["moment/moment", "virtual-dom", "helper", "moment/locale/de"], function var td0Content = []; var td1Content = []; - var aClass = ["hostname", d.flags.online ? "online" : "offline"]; + var aClass = ['hostname', d.flags.online ? 'online' : 'offline']; - td1Content.push(V.h("a", { - className: aClass.join(" "), + td1Content.push(V.h('a', { + className: aClass.join(' '), onclick: router.node(d), - href: "#" + href: '#' }, d.nodeinfo.hostname)); if (helper.hasLocation(d)) { - td0Content.push(V.h("span", {className: "icon ion-location"})); + td0Content.push(V.h('span', { className: 'icon ion-location' })); } - var td0 = V.h("td", td0Content); - var td1 = V.h("td", td1Content); - var td2 = V.h("td", time); + var td0 = V.h('td', td0Content); + var td1 = V.h('td', td1Content); + var td2 = V.h('td', time); - return V.h("tr", [td0, td1, td2]); + return V.h('tr', [td0, td1, td2]); }); - var tbodyNew = V.h("tbody", items); + var tbodyNew = V.h('tbody', items); tbody = V.patch(tbody, V.diff(tbody.last, tbodyNew)); tbody.last = tbodyNew; }; diff --git a/lib/sorttable.js b/lib/sorttable.js index 2fc7353..2fa43d3 100644 --- a/lib/sorttable.js +++ b/lib/sorttable.js @@ -1,11 +1,11 @@ -define(["virtual-dom"], function (V) { - "use strict"; +define(['virtual-dom'], function (V) { + 'use strict'; return function (headings, sortIndex, renderRow) { var data; var sortReverse = false; - var el = document.createElement("table"); - var elLast = V.h("table"); + var el = document.createElement('table'); + var elLast = V.h('table'); function sortTable(i) { sortReverse = i === sortIndex ? !sortReverse : false; @@ -27,14 +27,14 @@ define(["virtual-dom"], function (V) { var th = headings.map(function (d, i) { var properties = { onclick: sortTableHandler(i), - className: "sort-header" + className: 'sort-header' }; if (sortIndex === i) { - properties.className += sortReverse ? " sort-up" : " sort-down"; + properties.className += sortReverse ? ' sort-up' : ' sort-down'; } - return V.h("th", properties, d.name); + return V.h('th', properties, d.name); }); var links = data.slice(0).sort(headings[sortIndex].sort); @@ -43,16 +43,16 @@ define(["virtual-dom"], function (V) { links = links.reverse(); } - children.push(V.h("thead", V.h("tr", th))); - children.push(V.h("tbody", links.map(renderRow))); + children.push(V.h('thead', V.h('tr', th))); + children.push(V.h('tbody', links.map(renderRow))); } - var elNew = V.h("table", children); + var elNew = V.h('table', children); el = V.patch(el, V.diff(elLast, elNew)); elLast = elNew; } - this.setData = function (d) { + this.setData = function setData(d) { data = d; updateView(); }; diff --git a/lib/tabs.js b/lib/tabs.js index 701af29..9d8220e 100644 --- a/lib/tabs.js +++ b/lib/tabs.js @@ -1,27 +1,27 @@ define(function () { - "use strict"; + 'use strict'; return function () { var self = this; - var tabs = document.createElement("ul"); - tabs.classList.add("tabs"); + var tabs = document.createElement('ul'); + tabs.classList.add('tabs'); - var container = document.createElement("div"); + var container = document.createElement('div'); function gotoTab(li) { for (var i = 0; i < tabs.children.length; i++) { - tabs.children[i].classList.remove("visible"); + tabs.children[i].classList.remove('visible'); } while (container.firstChild) { container.removeChild(container.firstChild); } - li.classList.add("visible"); + li.classList.add('visible'); - var tab = document.createElement("div"); - tab.classList.add("tab"); + var tab = document.createElement('div'); + tab.classList.add('tab'); container.appendChild(tab); li.child.render(tab); } @@ -32,8 +32,8 @@ define(function () { return false; } - self.add = function (title, d) { - var li = document.createElement("li"); + self.add = function add(title, d) { + var li = document.createElement('li'); li.textContent = title; li.onclick = switchTab; li.child = d; @@ -42,7 +42,7 @@ define(function () { var anyVisible = false; for (var i = 0; i < tabs.children.length; i++) { - if (tabs.children[i].classList.contains("visible")) { + if (tabs.children[i].classList.contains('visible')) { anyVisible = true; break; } @@ -53,7 +53,7 @@ define(function () { } }; - self.render = function (el) { + self.render = function render(el) { el.appendChild(tabs); el.appendChild(container); }; diff --git a/lib/title.js b/lib/title.js index 243c6bd..c1ee542 100644 --- a/lib/title.js +++ b/lib/title.js @@ -1,5 +1,5 @@ define(function () { - "use strict"; + 'use strict'; return function (config) { function setTitle(d) { @@ -9,30 +9,30 @@ define(function () { title.push(d); } - document.title = title.join(": "); + document.title = title.join(': '); } - this.resetView = function () { + this.resetView = function resetView() { setTitle(); }; - this.gotoNode = function (d) { + this.gotoNode = function gotoNode(d) { if (d) { setTitle(d.nodeinfo.hostname); } }; - this.gotoLink = function (d) { + this.gotoLink = function gotoLink(d) { if (d) { - setTitle((d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + " – " + d.target.node.nodeinfo.hostname); + setTitle((d.source.node ? d.source.node.nodeinfo.hostname : d.source.id) + ' – ' + d.target.node.nodeinfo.hostname); } }; - this.gotoLocation = function () { - //ignore + this.gotoLocation = function gotoLocation() { + // ignore }; - this.destroy = function () { + this.destroy = function destroy() { }; return this; diff --git a/lib/utils/helper.js b/lib/utils/helper.js index 6a31932..003b06b 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -1,74 +1,73 @@ -"use strict"; +'use strict'; define({ - get: function (url) { + get: function get(url) { return new Promise(function (resolve, reject) { var req = new XMLHttpRequest(); - req.open("GET", url); + req.open('GET', url); - req.onload = function () { - if (req.status == 200) { + req.onload = function onload() { + if (req.status === 200) { resolve(req.response); - } - else { + } else { reject(Error(req.statusText)); } }; - req.onerror = function () { - reject(Error("Network Error")); + req.onerror = function onerror() { + reject(Error('Network Error')); }; req.send(); }); }, - getJSON: function (url) { - return require("helper").get(url).then(JSON.parse); + getJSON: function getJSON(url) { + return require('helper').get(url).then(JSON.parse); }, - sortByKey: function (key, d) { + sortByKey: function sortByKey(key, d) { return d.slice().sort(function (a, b) { return a[key] - b[key]; }).reverse(); }, - limit: function (key, m, d) { - return d.filter(function (d) { - return d[key].isAfter(m); + limit: function limit(key, m, d) { + return d.filter(function (n) { + return n[key].isAfter(m); }); }, - sum: function (a) { - return a.reduce(function (a, b) { - return a + b; + sum: function sum(a) { + return a.reduce(function (b, c) { + return b + c; }, 0); }, - one: function () { + one: function one() { return 1; }, - trueDefault: function (d) { + trueDefault: function trueDefault(d) { return d === undefined ? true : d; }, - dictGet: function (dict, key) { + dictGet: function dictGet(dict, key) { var k = key.shift(); if (!(k in dict)) { return null; } - if (key.length == 0) { + if (key.length === 0) { return dict[k]; } return this.dictGet(dict[k], key); }, - localStorageTest: function () { - var test = "test"; + localStorageTest: function localStorageTest() { + var test = 'test'; try { localStorage.setItem(test, test); localStorage.removeItem(test); @@ -78,9 +77,9 @@ define({ } }, - listReplace: function (s, subst) { + listReplace: function listReplace(s, subst) { for (var key in subst) { - var re = new RegExp(key, "g"); + var re = new RegExp(key, 'g'); s = s.replace(re, subst[key]); } return s; @@ -88,21 +87,21 @@ define({ /* Helpers working with nodes */ - offline: function (d) { + offline: function offline(d) { return !d.flags.online; }, - online: function (d) { + online: function online(d) { return d.flags.online; }, - hasLocation: function (d) { - return "location" in d.nodeinfo && + hasLocation: function hasLocation(d) { + return 'location' in d.nodeinfo && Math.abs(d.nodeinfo.location.latitude) < 90 && Math.abs(d.nodeinfo.location.longitude) < 180; }, - subtract: function (a, b) { + subtract: function subtract(a, b) { var ids = {}; b.forEach(function (d) { @@ -116,31 +115,31 @@ define({ /* Helpers working with links */ - showDistance: function (d) { + showDistance: function showDistance(d) { if (isNaN(d.distance)) { - return; + return ''; } - return d.distance.toFixed(0) + " m"; + return d.distance.toFixed(0) + ' m'; }, - showTq: function (d) { - return (1 / d.tq * 100).toFixed(0) + "%"; + showTq: function showTq(d) { + return (1 / d.tq * 100).toFixed(0) + '%'; }, - attributeEntry: function (el, label, value) { - if (value === null || value == undefined) { - return; + attributeEntry: function attributeEntry(el, label, value) { + if (value === null || value === undefined) { + return ''; } - var tr = document.createElement("tr"); - var th = document.createElement("th"); + var tr = document.createElement('tr'); + var th = document.createElement('th'); th.textContent = label; tr.appendChild(th); - var td = document.createElement("td"); + var td = document.createElement('td'); - if (typeof value == "function") { + if (typeof value === 'function') { value(td); } else { td.appendChild(document.createTextNode(value)); @@ -153,10 +152,10 @@ define({ return td; }, - createIframe: function (opt, width, height) { - var el = document.createElement("iframe"); - width = typeof width !== "undefined" ? width : "525px"; - height = typeof height !== "undefined" ? height : "350px"; + createIframe: function createIframe(opt, width, height) { + var el = document.createElement('iframe'); + width = typeof width !== 'undefined' ? width : '525px'; + height = typeof height !== 'undefined' ? height : '350px'; if (opt.src) { el.src = opt.src; @@ -182,23 +181,24 @@ define({ el.height = height; } - el.scrolling = "no"; - el.seamless = "seamless"; + el.scrolling = 'no'; + el.seamless = 'seamless'; return el; }, - showStat: function (o, subst) { - var content, caption; - subst = typeof subst !== "undefined" ? subst : {}; + showStat: function showStat(o, subst) { + var content; + var caption; + subst = typeof subst !== 'undefined' ? subst : {}; if (o.thumbnail) { - content = document.createElement("img"); - content.src = require("helper").listReplace(o.thumbnail, subst); + content = document.createElement('img'); + content.src = require('helper').listReplace(o.thumbnail, subst); } if (o.caption) { - caption = require("helper").listReplace(o.caption, subst); + caption = require('helper').listReplace(o.caption, subst); if (!content) { content = document.createTextNode(caption); @@ -206,20 +206,20 @@ define({ } if (o.iframe) { - content = require("helper").createIframe(o.iframe, o.width, o.height); + content = require('helper').createIframe(o.iframe, o.width, o.height); if (o.iframe.src) { - content.src = require("helper").listReplace(o.iframe.src, subst); + content.src = require('helper').listReplace(o.iframe.src, subst); } else { - content.src = require("helper").listReplace(o.iframe, subst); + content.src = require('helper').listReplace(o.iframe, subst); } } - var p = document.createElement("p"); + var p = document.createElement('p'); if (o.href) { - var link = document.createElement("a"); - link.target = "_blank"; - link.href = require("helper").listReplace(o.href, subst); + var link = document.createElement('a'); + link.target = '_blank'; + link.href = require('helper').listReplace(o.href, subst); link.appendChild(content); if (caption && o.thumbnail) { diff --git a/package.json b/package.json index c3221d1..bf68067 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,11 @@ }, "dependencies": { "almond": "^0.3.3", + "babel-eslint": "6.x", "chroma-js": "^1.2.1", "d3": "3.5", + "eslint-config-airbnb-es5": "^1.1.0", + "eslint-plugin-react": "^6.9.0", "leaflet": "https://github.com/davojta/Leaflet.git#stable_0_7_7_1_release", "leaflet-label": "^0.2.1-0", "moment": "^2.17.1", diff --git a/tasks/build.js b/tasks/build.js index a3fcd4b..ec0f4de 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -1,58 +1,58 @@ -module.exports = function (grunt) { - "use strict"; +module.exports = function exports(grunt) { + 'use strict'; grunt.config.merge({ - nodedir: "node_modules", + nodedir: 'node_modules', copy: { html: { - src: ["*.html"], + src: ['*.html'], expand: true, - cwd: "html/", - dest: "build/" + cwd: 'html/', + dest: 'build/' }, vendorjs: { - src: ["promise-polyfill/promise.js"], + src: ['promise-polyfill/promise.js'], expand: true, - cwd: "<%=nodedir%>/", - dest: "build/vendor/" + cwd: '<%=nodedir%>/', + dest: 'build/vendor/' }, config: { - src: ["config.json"], + src: ['config.json'], expand: true, - cwd: ".", - dest: "build/" + cwd: '.', + dest: 'build/' }, ionicons: { - src: ["fonts/*"], + src: ['fonts/*'], expand: true, - dest: "build/", - cwd: "assets/icons/" + dest: 'build/', + cwd: 'assets/icons/' }, assistantFont: { - src: ["fonts/*"], + src: ['fonts/*'], expand: true, - dest: "build/", - cwd: "assets/" + dest: 'build/', + cwd: 'assets/' } }, sass: { dev: { options: { sourceMap: true, - outputStyle: "expanded" + outputStyle: 'expanded' }, files: { - "build/style.css": "scss/main.scss", - "build/night.css": "scss/night.scss" + 'build/style.css': 'scss/main.scss', + 'build/night.css': 'scss/night.scss' } }, dist: { options: { - outputStyle: "compressed" + outputStyle: 'compressed' }, files: { - "build/style.css": "scss/main.scss", - "build/night.css": "scss/night.scss" + 'build/style.css': 'scss/main.scss', + 'build/night.css': 'scss/night.scss' } } }, @@ -60,13 +60,13 @@ module.exports = function (grunt) { options: { map: false, processors: [ - require("autoprefixer")({ - browsers: ["> 1% in DE"] + require('autoprefixer')({ + browsers: ['> 1% in DE'] }) ] }, dist: { - src: "build/*.css" + src: 'build/*.css' } }, inline: { @@ -75,8 +75,8 @@ module.exports = function (grunt) { cssmin: true, uglify: true }, - src: "build/index.html", - dest: "build/index.html" + src: 'build/index.html', + dest: 'build/index.html' } }, htmlmin: { @@ -94,30 +94,30 @@ module.exports = function (grunt) { inlinedata: { injs: { expand: true, - cwd: ".", - src: ["build/*.html"], - ext: ".html" + cwd: '.', + src: ['build/*.html'], + ext: '.html' } }, requirejs: { default: { options: { - baseUrl: "lib", - name: "../<%=nodedir%>/almond/almond", - mainConfigFile: "app.js", - include: "../app", - out: "build/app.js", + baseUrl: 'lib', + name: '../<%=nodedir%>/almond/almond', + mainConfigFile: 'app.js', + include: '../app', + out: 'build/app.js', build: true } }, dev: { options: { - baseUrl: "lib", - name: "../<%=nodedir%>/almond/almond", - mainConfigFile: "app.js", - include: "../app", - optimize: "none", - out: "build/app.js", + baseUrl: 'lib', + name: '../<%=nodedir%>/almond/almond', + mainConfigFile: 'app.js', + include: '../app', + optimize: 'none', + out: 'build/app.js', build: false, generateSourceMaps: true } @@ -126,21 +126,21 @@ module.exports = function (grunt) { cachebreaker: { default: { options: { - match: ["app.js"] + match: ['app.js'] }, files: { - src: ["build/index.html"] + src: ['build/index.html'] } } } }); - grunt.loadNpmTasks("grunt-contrib-copy"); - grunt.loadNpmTasks("grunt-contrib-requirejs"); - grunt.loadNpmTasks("grunt-sass"); - grunt.loadNpmTasks("grunt-postcss"); - grunt.loadNpmTasks("grunt-inline"); - grunt.loadNpmTasks("grunt-inline-data"); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-requirejs'); + grunt.loadNpmTasks('grunt-sass'); + grunt.loadNpmTasks('grunt-postcss'); + grunt.loadNpmTasks('grunt-inline'); + grunt.loadNpmTasks('grunt-inline-data'); grunt.loadNpmTasks('grunt-contrib-htmlmin'); - grunt.loadNpmTasks("grunt-cache-breaker"); + grunt.loadNpmTasks('grunt-cache-breaker'); }; diff --git a/tasks/clean.js b/tasks/clean.js index db51c10..1691e13 100644 --- a/tasks/clean.js +++ b/tasks/clean.js @@ -1,12 +1,12 @@ -module.exports = function (grunt) { - "use strict"; +module.exports = function exports(grunt) { + 'use strict'; grunt.config.merge({ clean: { - build: ["build/**/*", "node_modules/grunt-newer/.cache"], - release: ["build/vendor", "build/*.map", "build/config.json", "build/style.css"] + build: ['build/**/*', 'node_modules/grunt-newer/.cache'], + release: ['build/vendor', 'build/*.map', 'build/config.json', 'build/style.css'] } }); - grunt.loadNpmTasks("grunt-contrib-clean"); + grunt.loadNpmTasks('grunt-contrib-clean'); }; diff --git a/tasks/development.js b/tasks/development.js index f214b6d..24dc74c 100644 --- a/tasks/development.js +++ b/tasks/development.js @@ -1,43 +1,43 @@ -module.exports = function (grunt) { - "use strict"; +module.exports = function exports(grunt) { + 'use strict'; grunt.config.merge({ - "browserSync": { + 'browserSync': { dev: { bsFiles: { src: [ - "build/*.css", - "build/*.js", - "build/*.html" + 'build/*.css', + 'build/*.js', + 'build/*.html' ] }, options: { - open: "local", + open: 'local', watchTask: true, injectChanges: true, server: { - baseDir: "build", - index: "index.html" + baseDir: 'build', + index: 'index.html' } } } }, watch: { html: { - files: ["html/index.html", "config.json"], - tasks: ["copy", "inlinedata", "htmlmin"] + files: ['html/index.html', 'config.json'], + tasks: ['copy', 'inlinedata', 'htmlmin'] }, sass: { - files: ["scss/**/*.scss"], - tasks: ["sasslint", "sass", "postcss"] + files: ['scss/**/*.scss'], + tasks: ['sasslint', 'sass', 'postcss'] }, js: { - files: ["app.js", "lib/**/*.js"], - tasks: ["eslint", "requirejs:dev"] + files: ['app.js', 'lib/**/*.js'], + tasks: ['eslint', 'requirejs:dev'] } } }); - grunt.loadNpmTasks("grunt-browser-sync"); - grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks('grunt-browser-sync'); + grunt.loadNpmTasks('grunt-contrib-watch'); }; diff --git a/tasks/linting.js b/tasks/linting.js index 0fc946a..049b4c3 100644 --- a/tasks/linting.js +++ b/tasks/linting.js @@ -1,5 +1,5 @@ -module.exports = function (grunt) { - "use strict"; +module.exports = function exports(grunt) { + 'use strict'; grunt.config.merge({ checkDependencies: { @@ -9,20 +9,20 @@ module.exports = function (grunt) { }, sasslint: { options: { - configFile: ".sass-lint.yml" + configFile: '.sass-lint.yml' }, target: ['scss/main.scss', 'scss/night.scss', 'scss/*/*.scss'] }, eslint: { sources: { - src: ["app.js", "!Gruntfile.js", "lib/**/*.js", "tasks/**/*.js"] + src: ['app.js', '!Gruntfile.js', 'lib/**/*.js', 'tasks/**/*.js'] }, grunt: { - src: ["Gruntfile.js", "tasks/*.js"] + src: ['Gruntfile.js', 'tasks/*.js'] } } }); grunt.loadNpmTasks('grunt-sass-lint'); - grunt.loadNpmTasks("grunt-eslint"); + grunt.loadNpmTasks('grunt-eslint'); }; diff --git a/yarn.lock b/yarn.lock index 6a895b8..6fc33d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -38,12 +38,12 @@ after@0.8.1: resolved "https://registry.yarnpkg.com/after/-/after-0.8.1.tgz#ab5d4fb883f596816d3515f8f791c0af486dd627" ajv-keywords@^1.0.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.0.tgz#c11e6859eafff83e0dafc416929472eca946aa2c" + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" ajv@^4.7.0: - version "4.10.4" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.10.4.tgz#c0974dd00b3464984892d6010aa9c2c945933254" + version "4.11.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.2.tgz#f166c3c11cbc6cb9dcc102a5bcfe5b72c95287e6" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -136,6 +136,13 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" +array.prototype.find@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.3.tgz#08c3ec33e32ec4bab362a2958e686ae92f59271d" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.7.0" + arraybuffer.slice@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" @@ -181,14 +188,14 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" autoprefixer@^6.6.1: - version "6.6.1" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.6.1.tgz#11a4077abb4b313253ec2f6e1adb91ad84253519" + version "6.7.0" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.7.0.tgz#88992cf04df141e7b8293550f2ee716c565d1cae" dependencies: - browserslist "~1.5.1" - caniuse-db "^1.0.30000604" + browserslist "~1.6.0" + caniuse-db "^1.0.30000613" normalize-range "^0.1.2" num2fraction "^1.2.2" - postcss "^5.2.8" + postcss "^5.2.11" postcss-value-parser "^3.2.3" aws-sign2@~0.6.0: @@ -199,13 +206,63 @@ aws4@^1.2.1: version "1.5.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" -babel-code-frame@^6.16.0: - version "6.20.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" +babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" dependencies: chalk "^1.1.0" esutils "^2.0.2" - js-tokens "^2.0.0" + js-tokens "^3.0.0" + +babel-eslint@6.x: + version "6.1.2" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-6.1.2.tgz#5293419fe3672d66598d327da9694567ba6a5f2f" + dependencies: + babel-traverse "^6.0.20" + babel-types "^6.0.19" + babylon "^6.0.18" + lodash.assign "^4.0.0" + lodash.pickby "^4.0.0" + +babel-messages@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.22.0.tgz#36066a214f1217e4ed4164867669ecb39e3ea575" + dependencies: + babel-runtime "^6.22.0" + +babel-runtime@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-traverse@^6.0.20: + version "6.22.1" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.22.1.tgz#3b95cd6b7427d6f1f757704908f2fc9748a5f59f" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + babylon "^6.15.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.0.19, babel-types@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.22.0.tgz#2a447e8d0ea25d2512409e4175479fd78cc8b1db" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.0.18, babylon@^6.15.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" backo2@1.0.2: version "1.0.2" @@ -342,11 +399,12 @@ browser-sync@^2.6.4: ua-parser-js "0.7.12" yargs "6.4.0" -browserslist@~1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.5.2.tgz#1c82fde0ee8693e6d15c49b7bff209dc06298c56" +browserslist@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.6.0.tgz#85fb7c993540d3fda31c282baf7f5aee698ac9ee" dependencies: - caniuse-db "^1.0.30000604" + caniuse-db "^1.0.30000613" + electron-to-chromium "^1.2.0" bs-recipes@1.3.4: version "1.3.4" @@ -437,9 +495,9 @@ camelize@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" -caniuse-db@^1.0.30000604: - version "1.0.30000611" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000611.tgz#1075d14d9b3cc153caf5e9e35f45565b03304c37" +caniuse-db@^1.0.30000613: + version "1.0.30000617" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000617.tgz#9b7fd81f58a35526315c83e60cb5f076f0beb392" caseless@~0.11.0: version "0.11.0" @@ -502,8 +560,8 @@ clean-css@1.1.7: commander "2.0.x" clean-css@3.4.x: - version "3.4.23" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-3.4.23.tgz#604fbbca24c12feb59b02f00b84f1fb7ded6d001" + version "3.4.24" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-3.4.24.tgz#89f5a5e9da37ae02394fe049a41388abbe72c3b5" dependencies: commander "2.8.x" source-map "0.4.x" @@ -633,6 +691,10 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -686,7 +748,7 @@ dateformat@~1.0.12: get-stdin "^4.0.1" meow "^3.3.0" -debug@2.2.0, debug@^2.1.1, debug@^2.2.0, debug@~2.2.0: +debug@2.2.0, debug@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" dependencies: @@ -698,6 +760,12 @@ debug@2.3.3: dependencies: ms "0.7.2" +debug@^2.1.1, debug@^2.2.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" + dependencies: + ms "0.7.2" + decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -710,6 +778,13 @@ deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" +define-properties@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" + dependencies: + foreach "^2.0.5" + object-keys "^1.0.8" + del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" @@ -786,6 +861,10 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" +electron-to-chromium@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.2.1.tgz#63ac7579a1c5bedb296c8607621f2efc9a54b968" + emitter-steward@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/emitter-steward/-/emitter-steward-1.0.0.tgz#f3411ade9758a7565df848b2da0cbbd1b46cbd64" @@ -847,6 +926,23 @@ error@^4.3.0: string-template "~0.2.0" xtend "~4.0.0" +es-abstract@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c" + dependencies: + es-to-primitive "^1.1.1" + function-bind "^1.1.0" + is-callable "^1.1.3" + is-regex "^1.0.3" + +es-to-primitive@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" + dependencies: + is-callable "^1.1.1" + is-date-object "^1.0.1" + is-symbol "^1.0.1" + es5-ext@^0.10.7, es5-ext@^0.10.8, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.7: version "0.10.12" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047" @@ -916,10 +1012,24 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" +eslint-config-airbnb-es5@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-es5/-/eslint-config-airbnb-es5-1.1.0.tgz#f342474fe7c8e02745707d1c5e3bca0a3ab9e968" + dependencies: + strip-json-comments "1.0.2" + eslint-config-defaults@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/eslint-config-defaults/-/eslint-config-defaults-9.0.0.tgz#a090adc13b2935e3f43b3cd048a92701654e5ad5" +eslint-plugin-react@^6.9.0: + version "6.9.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.9.0.tgz#54c2e9906b76f9d10142030bdc34e9d6840a0bb2" + dependencies: + array.prototype.find "^2.0.1" + doctrine "^1.2.2" + jsx-ast-utils "^1.3.4" + eslint@^2.7.0: version "2.13.1" resolved "https://registry.yarnpkg.com/eslint/-/eslint-2.13.1.tgz#e4cc8fa0f009fb829aaae23855a29360be1f6c11" @@ -959,8 +1069,8 @@ eslint@^2.7.0: user-home "^2.0.0" eslint@^3.0.0, eslint@^3.14.0: - version "3.14.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.14.0.tgz#2c617e5f782fda5cbee5bc8be7ef5053af8e63a3" + version "3.14.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.14.1.tgz#8a62175f2255109494747a1b25128d97b8eb3d97" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" @@ -1186,6 +1296,10 @@ for-own@^0.1.4: dependencies: for-in "^0.1.5" +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -1248,6 +1362,10 @@ fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: mkdirp ">=0.5 0" rimraf "2" +function-bind@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" + gauge@~2.7.1: version "2.7.2" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.2.tgz#15cecc31b02d05345a5d6b0e171cdb3ad2307774" @@ -1348,7 +1466,7 @@ global@^4.3.0: min-document "^2.19.0" process "~0.5.1" -globals@^9.14.0, globals@^9.2.0: +globals@^9.0.0, globals@^9.14.0, globals@^9.2.0: version "9.14.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" @@ -1596,8 +1714,8 @@ hawk@~3.1.3: sntp "1.x.x" he@1.1.x: - version "1.1.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.1.0.tgz#29319d49beec13a9b1f3c4f9b2a6dde4859bb2a7" + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" hoek@2.x.x: version "2.16.3" @@ -1663,8 +1781,8 @@ iconv-lite@~0.4.13: resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" ignore@^3.1.2, ignore@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.0.tgz#8d88f03c3002a0ac52114db25d2c673b0bf1e435" + version "3.2.2" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.2.tgz#1c51e1ef53bab6ddc15db4d9ac4ec139eceb3410" immutable@3.8.1, immutable@^3.7.6: version "3.8.1" @@ -1733,6 +1851,12 @@ interpret@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -1757,6 +1881,14 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" +is-callable@^1.1.1, is-callable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" + +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + is-dotfile@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" @@ -1851,12 +1983,20 @@ is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" +is-regex@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.3.tgz#0d55182bddf9f2fde278220aec3a75642c908637" + is-resolvable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" dependencies: tryit "^1.0.1" +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -1897,9 +2037,9 @@ js-base64@^2.1.9: version "2.1.9" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.1.9.tgz#f0e80ae039a4bd654b5f281fc93f04a914a7fcce" -js-tokens@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" +js-tokens@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.0.tgz#a2f2a969caae142fb3cd56228358c89366957bd1" js-yaml@^3.4.6, js-yaml@^3.5.1, js-yaml@^3.5.4, js-yaml@~3.5.2: version "3.5.5" @@ -1952,6 +2092,13 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" +jsx-ast-utils@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.3.5.tgz#9ba6297198d9f754594d62e59496ffb923778dd4" + dependencies: + acorn-jsx "^3.0.1" + object-assign "^4.1.0" + kind-of@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" @@ -2058,7 +2205,7 @@ lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" -lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.2.0: +lodash.assign@^4.0.0, lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" @@ -2105,6 +2252,10 @@ lodash.mergewith@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55" +lodash.pickby@^4.0.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff" + lodash@2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.2.1.tgz#ca935fd14ab3c0c872abacf198b9cda501440867" @@ -2113,18 +2264,28 @@ lodash@^3.10.1, lodash@~3.10.1: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.3.0, lodash@~4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4" +lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" lodash@~4.16.4: version "4.16.6" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777" +lodash@~4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" +loose-envify@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -2267,8 +2428,8 @@ mute-stream@0.0.5: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" nan@^2.3.0, nan@^2.3.2: - version "2.5.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.0.tgz#aa8f1e34531d807e9e27755b234b4a6ec0c152a8" + version "2.5.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" natural-compare@^1.4.0: version "1.4.0" @@ -2327,8 +2488,8 @@ node-pre-gyp@^0.6.29: tar-pack "~3.3.0" node-sass@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.3.0.tgz#d014f64595d77b26af99e9f7a7e74704d9976bda" + version "4.4.0" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.4.0.tgz#ff08ff2fded2a1d0bee270e8ed1275f7bc9c5a16" dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -2409,6 +2570,10 @@ object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" +object-keys@^1.0.8: + version "1.0.11" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" + object-path@^0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.9.2.tgz#0fd9a74fc5fad1ae3968b586bda5c632bd6c05a5" @@ -2589,14 +2754,14 @@ postcss-value-parser@^3.2.3: version "3.3.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15" -postcss@^5.0.0, postcss@^5.2.8: - version "5.2.10" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.10.tgz#b58b64e04f66f838b7bc7cb41f7dac168568a945" +postcss@^5.0.0, postcss@^5.2.11: + version "5.2.11" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.11.tgz#ff29bcd6d2efb98bfe08a022055ec599bbe7b761" dependencies: chalk "^1.1.3" js-base64 "^2.1.9" source-map "^0.5.6" - supports-color "^3.1.2" + supports-color "^3.2.3" prelude-ls@~1.1.2: version "1.1.2" @@ -2755,6 +2920,10 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" +regenerator-runtime@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" + regex-cache@^0.4.2: version "0.4.3" resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" @@ -3181,6 +3350,10 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" +strip-json-comments@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.2.tgz#5a48ab96023dbac1b7b8d0ffabf6f63f1677be9f" + strip-json-comments@~1.0.1, strip-json-comments@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" @@ -3197,7 +3370,7 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.2: +supports-color@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: @@ -3273,6 +3446,10 @@ to-array@0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + tough-cookie@~2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a"