change code style to ffrgb/meshviewer fork
This commit is contained in:
parent
59ba0ba29e
commit
418b630e02
42 changed files with 3472 additions and 3121 deletions
|
|
@ -11,6 +11,6 @@ trim_trailing_whitespace = true
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.{js,html,scss,json}]
|
[*.{js,html,scss,json,yml,md}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@ node_modules/
|
||||||
build/
|
build/
|
||||||
.sass-cache/
|
.sass-cache/
|
||||||
config.json
|
config.json
|
||||||
|
.idea/
|
||||||
|
.eslintrc
|
||||||
|
|
|
||||||
24
Gruntfile.js
24
Gruntfile.js
|
|
@ -1,24 +1,24 @@
|
||||||
module.exports = function (grunt) {
|
module.exports = function (grunt) {
|
||||||
grunt.loadNpmTasks("grunt-git-describe")
|
grunt.loadNpmTasks("grunt-git-describe");
|
||||||
|
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
"git-describe": {
|
"git-describe": {
|
||||||
options: {},
|
options: {},
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
grunt.registerTask("saveRevision", function() {
|
grunt.registerTask("saveRevision", function () {
|
||||||
grunt.event.once("git-describe", function (rev) {
|
grunt.event.once("git-describe", function (rev) {
|
||||||
grunt.option("gitRevision", rev)
|
grunt.option("gitRevision", rev);
|
||||||
})
|
});
|
||||||
grunt.task.run("git-describe")
|
grunt.task.run("git-describe");
|
||||||
})
|
});
|
||||||
|
|
||||||
grunt.loadTasks("tasks")
|
grunt.loadTasks("tasks");
|
||||||
|
|
||||||
grunt.registerTask("default", ["bower-install-simple", "lint", "saveRevision", "copy", "sass", "postcss", "requirejs"])
|
grunt.registerTask("default", ["bower-install-simple", "lint", "saveRevision", "copy", "sass", "postcss", "requirejs"]);
|
||||||
grunt.registerTask("lint", ["eslint"])
|
grunt.registerTask("lint", ["eslint"]);
|
||||||
grunt.registerTask("dev", ["default", "connect:server", "watch"])
|
grunt.registerTask("dev", ["default", "connect:server", "watch"]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
||||||
6
app.js
6
app.js
|
|
@ -29,8 +29,8 @@ require.config({
|
||||||
"tablesort.numeric": ["tablesort"],
|
"tablesort.numeric": ["tablesort"],
|
||||||
"helper": ["numeral-intl"]
|
"helper": ["numeral-intl"]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
require(["main", "helper"], function (main) {
|
require(["main", "helper"], function (main) {
|
||||||
getJSON("config.json").then(main)
|
getJSON("config.json").then(main);
|
||||||
})
|
});
|
||||||
|
|
|
||||||
16
build.js
16
build.js
|
|
@ -1,9 +1,9 @@
|
||||||
({
|
({
|
||||||
baseUrl: "lib",
|
baseUrl: "lib",
|
||||||
name: "../bower_components/almond/almond",
|
name: "../bower_components/almond/almond",
|
||||||
mainConfigFile: "app.js",
|
mainConfigFile: "app.js",
|
||||||
include: "../app",
|
include: "../app",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
optimize: "uglify",
|
optimize: "uglify",
|
||||||
out: "app-combined.js"
|
out: "app-combined.js"
|
||||||
})
|
});
|
||||||
|
|
|
||||||
249
helper.js
249
helper.js
|
|
@ -1,228 +1,241 @@
|
||||||
function get(url) {
|
function get(url) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var req = new XMLHttpRequest()
|
var req = new XMLHttpRequest();
|
||||||
req.open('GET', url)
|
req.open('GET', url);
|
||||||
|
|
||||||
req.onload = function() {
|
req.onload = function () {
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
resolve(req.response)
|
resolve(req.response);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reject(Error(req.statusText))
|
reject(Error(req.statusText));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
req.onerror = function() {
|
req.onerror = function () {
|
||||||
reject(Error("Network Error"))
|
reject(Error("Network Error"));
|
||||||
}
|
};
|
||||||
|
|
||||||
req.send()
|
req.send();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJSON(url) {
|
function getJSON(url) {
|
||||||
return get(url).then(JSON.parse)
|
return get(url).then(JSON.parse);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByKey(key, d) {
|
function sortByKey(key, d) {
|
||||||
return d.slice().sort( function (a, b) {
|
return d.slice().sort(function (a, b) {
|
||||||
return a[key] - b[key]
|
return a[key] - b[key];
|
||||||
}).reverse()
|
}).reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
function limit(key, m, d) {
|
function limit(key, m, d) {
|
||||||
return d.filter( function (d) {
|
return d.filter(function (d) {
|
||||||
return d[key].isAfter(m)
|
return d[key].isAfter(m);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function sum(a) {
|
function sum(a) {
|
||||||
return a.reduce( function (a, b) {
|
return a.reduce(function (a, b) {
|
||||||
return a + b
|
return a + b;
|
||||||
}, 0)
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function one() {
|
function one() {
|
||||||
return 1
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trueDefault(d) {
|
function trueDefault(d) {
|
||||||
return d === undefined ? true : d
|
return d === undefined ? true : d;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dictGet(dict, key) {
|
function dictGet(dict, key) {
|
||||||
var k = key.shift()
|
var k = key.shift();
|
||||||
|
|
||||||
if (!(k in dict))
|
if (!(k in dict)) {
|
||||||
return null
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (key.length == 0)
|
if (key.length == 0) {
|
||||||
return dict[k]
|
return dict[k];
|
||||||
|
}
|
||||||
|
|
||||||
return dictGet(dict[k], key)
|
return dictGet(dict[k], key);
|
||||||
}
|
}
|
||||||
|
|
||||||
function localStorageTest() {
|
function localStorageTest() {
|
||||||
var test = 'test'
|
var test = 'test';
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(test, test)
|
localStorage.setItem(test, test);
|
||||||
localStorage.removeItem(test)
|
localStorage.removeItem(test);
|
||||||
return true
|
return true;
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function listReplace(s, subst) {
|
function listReplace(s, subst) {
|
||||||
for (key in subst) {
|
for (key in subst) {
|
||||||
var re = new RegExp(key, 'g')
|
var re = new RegExp(key, 'g');
|
||||||
s = s.replace(re, subst[key])
|
s = s.replace(re, subst[key]);
|
||||||
}
|
}
|
||||||
return s
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helpers working with nodes */
|
/* Helpers working with nodes */
|
||||||
|
|
||||||
function offline(d) {
|
function offline(d) {
|
||||||
return !d.flags.online
|
return !d.flags.online;
|
||||||
}
|
}
|
||||||
|
|
||||||
function online(d) {
|
function online(d) {
|
||||||
return d.flags.online
|
return d.flags.online;
|
||||||
}
|
}
|
||||||
|
|
||||||
function has_location(d) {
|
function has_location(d) {
|
||||||
return "location" in d.nodeinfo &&
|
return "location" in d.nodeinfo &&
|
||||||
Math.abs(d.nodeinfo.location.latitude) < 90 &&
|
Math.abs(d.nodeinfo.location.latitude) < 90 &&
|
||||||
Math.abs(d.nodeinfo.location.longitude) < 180
|
Math.abs(d.nodeinfo.location.longitude) < 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtract(a, b) {
|
function subtract(a, b) {
|
||||||
var ids = {}
|
var ids = {};
|
||||||
|
|
||||||
b.forEach( function (d) {
|
b.forEach(function (d) {
|
||||||
ids[d.nodeinfo.node_id] = true
|
ids[d.nodeinfo.node_id] = true;
|
||||||
})
|
});
|
||||||
|
|
||||||
return a.filter( function (d) {
|
return a.filter(function (d) {
|
||||||
return !(d.nodeinfo.node_id in ids)
|
return !(d.nodeinfo.node_id in ids);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helpers working with links */
|
/* Helpers working with links */
|
||||||
|
|
||||||
function showDistance(d) {
|
function showDistance(d) {
|
||||||
if (isNaN(d.distance))
|
if (isNaN(d.distance)) {
|
||||||
return
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return numeral(d.distance).format("0,0") + " m"
|
return numeral(d.distance).format("0,0") + " m";
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTq(d) {
|
function showTq(d) {
|
||||||
return numeral(1/d.tq).format("0%")
|
return numeral(1 / d.tq).format("0%");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Infobox stuff (XXX: move to module) */
|
/* Infobox stuff (XXX: move to module) */
|
||||||
|
|
||||||
function attributeEntry(el, label, value) {
|
function attributeEntry(el, label, value) {
|
||||||
if (value === null || value == undefined)
|
if (value === null || value == undefined) {
|
||||||
return
|
return;
|
||||||
|
|
||||||
var tr = document.createElement("tr")
|
|
||||||
var th = document.createElement("th")
|
|
||||||
if (typeof label === "string")
|
|
||||||
th.textContent = label
|
|
||||||
else {
|
|
||||||
th.appendChild(label)
|
|
||||||
tr.className = "routerpic"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.appendChild(th)
|
var tr = document.createElement("tr");
|
||||||
|
var th = document.createElement("th");
|
||||||
|
if (typeof label === "string") {
|
||||||
|
th.textContent = label;
|
||||||
|
} else {
|
||||||
|
th.appendChild(label);
|
||||||
|
tr.className = "routerpic";
|
||||||
|
}
|
||||||
|
|
||||||
var td = document.createElement("td")
|
tr.appendChild(th);
|
||||||
|
|
||||||
if (typeof value == "function")
|
var td = document.createElement("td");
|
||||||
value(td)
|
|
||||||
else
|
|
||||||
td.appendChild(document.createTextNode(value))
|
|
||||||
|
|
||||||
tr.appendChild(td)
|
if (typeof value == "function") {
|
||||||
|
value(td);
|
||||||
|
} else {
|
||||||
|
td.appendChild(document.createTextNode(value));
|
||||||
|
}
|
||||||
|
|
||||||
el.appendChild(tr)
|
tr.appendChild(td);
|
||||||
|
|
||||||
return td
|
el.appendChild(tr);
|
||||||
|
|
||||||
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createIframe(opt, width, height) {
|
function createIframe(opt, width, height) {
|
||||||
el = document.createElement("iframe")
|
el = document.createElement("iframe");
|
||||||
width = typeof width !== 'undefined' ? width : '100%'
|
width = typeof width !== 'undefined' ? width : '100%';
|
||||||
height = typeof height !== 'undefined' ? height : '350px'
|
height = typeof height !== 'undefined' ? height : '350px';
|
||||||
|
|
||||||
if (opt.src)
|
if (opt.src) {
|
||||||
el.src = opt.src
|
el.src = opt.src;
|
||||||
else
|
} else {
|
||||||
el.src = opt
|
el.src = opt;
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.frameBorder)
|
if (opt.frameBorder) {
|
||||||
el.frameBorder = opt.frameBorder
|
el.frameBorder = opt.frameBorder;
|
||||||
else
|
} else {
|
||||||
el.frameBorder = 1
|
el.frameBorder = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.width)
|
if (opt.width) {
|
||||||
el.width = opt.width
|
el.width = opt.width;
|
||||||
else
|
} else {
|
||||||
el.width = width
|
el.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.height)
|
if (opt.height) {
|
||||||
el.height = opt.height
|
el.height = opt.height;
|
||||||
else
|
} else {
|
||||||
el.height = height
|
el.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
el.scrolling = "no"
|
el.scrolling = "no";
|
||||||
el.seamless = "seamless"
|
el.seamless = "seamless";
|
||||||
|
|
||||||
return el
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showStat(o, subst) {
|
function showStat(o, subst) {
|
||||||
var content, caption
|
var content, caption;
|
||||||
subst = typeof subst !== 'undefined' ? subst : {}
|
subst = typeof subst !== 'undefined' ? subst : {};
|
||||||
|
|
||||||
if (o.thumbnail) {
|
if (o.thumbnail) {
|
||||||
content = document.createElement("img")
|
content = document.createElement("img");
|
||||||
content.src = listReplace(o.thumbnail, subst)
|
content.src = listReplace(o.thumbnail, subst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.caption) {
|
if (o.caption) {
|
||||||
caption = listReplace(o.caption, subst)
|
caption = listReplace(o.caption, subst);
|
||||||
|
|
||||||
if (!content)
|
if (!content) {
|
||||||
content = document.createTextNode(caption)
|
content = document.createTextNode(caption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.iframe) {
|
if (o.iframe) {
|
||||||
content = createIframe(o.iframe, o.width, o.height)
|
content = createIframe(o.iframe, o.width, o.height);
|
||||||
if (o.iframe.src)
|
if (o.iframe.src) {
|
||||||
content.src = listReplace(o.iframe.src, subst)
|
content.src = listReplace(o.iframe.src, subst);
|
||||||
else
|
} else {
|
||||||
content.src = listReplace(o.iframe, subst)
|
content.src = listReplace(o.iframe, subst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = document.createElement("p")
|
var p = document.createElement("p");
|
||||||
|
|
||||||
if (o.href) {
|
if (o.href) {
|
||||||
var link = document.createElement("a")
|
var link = document.createElement("a");
|
||||||
link.target = "_blank"
|
link.target = "_blank";
|
||||||
link.href = listReplace(o.href, subst)
|
link.href = listReplace(o.href, subst);
|
||||||
link.appendChild(content)
|
link.appendChild(content);
|
||||||
|
|
||||||
if (caption && o.thumbnail)
|
if (caption && o.thumbnail) {
|
||||||
link.title = caption
|
link.title = caption;
|
||||||
|
}
|
||||||
|
|
||||||
p.appendChild(link)
|
p.appendChild(link);
|
||||||
} else
|
} else {
|
||||||
p.appendChild(content)
|
p.appendChild(content);
|
||||||
|
}
|
||||||
|
|
||||||
return p
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||||
<link rel="stylesheet" href="css/ionicons.min.css">
|
<link rel="stylesheet" href="css/ionicons.min.css">
|
||||||
<link rel="stylesheet" href="roboto-slab-fontface.css">
|
<link rel="stylesheet" href="roboto-slab-fontface.css">
|
||||||
<link rel="stylesheet" href="roboto-fontface.css">
|
<link rel="stylesheet" href="roboto-fontface.css">
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<script src="vendor/es6-shim/es6-shim.min.js"></script>
|
<script src="vendor/es6-shim/es6-shim.min.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
console.log("Version: #revision#")
|
console.log("Version: #revision#");
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="loader">
|
<div class="loader">
|
||||||
<p>
|
<p>
|
||||||
Lade<br />
|
Lade<br/>
|
||||||
<span class="spinner"></span><br />
|
<span class="spinner"></span><br/>
|
||||||
Karte & Knoten...
|
Karte & Knoten...
|
||||||
</p>
|
</p>
|
||||||
<noscript>
|
<noscript>
|
||||||
<strong>JavaScript required</strong>
|
<strong>JavaScript required</strong>
|
||||||
</noscript>
|
</noscript>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
48
index.html
48
index.html
|
|
@ -1,27 +1,27 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||||
<link rel="stylesheet" href="bower_components/roboto-slab-fontface/roboto-slab-fontface.css">
|
<link rel="stylesheet" href="bower_components/roboto-slab-fontface/roboto-slab-fontface.css">
|
||||||
<link rel="stylesheet" href="bower_components/roboto-fontface/roboto-fontface.css">
|
<link rel="stylesheet" href="bower_components/roboto-fontface/roboto-fontface.css">
|
||||||
<link rel="stylesheet" href="bower_components/leaflet/dist/leaflet.css">
|
<link rel="stylesheet" href="bower_components/leaflet/dist/leaflet.css">
|
||||||
<link rel="stylesheet" href="bower_components/Leaflet.label/dist/leaflet.label.css">
|
<link rel="stylesheet" href="bower_components/Leaflet.label/dist/leaflet.label.css">
|
||||||
<link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css">
|
<link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css">
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<script src="bower_components/es6-shim/es6-shim.min.js"></script>
|
<script src="bower_components/es6-shim/es6-shim.min.js"></script>
|
||||||
<script src="bower_components/requirejs/require.js" data-main="app"></script>
|
<script src="bower_components/requirejs/require.js" data-main="app"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="loader">
|
<div class="loader">
|
||||||
<p>
|
<p>
|
||||||
Lade<br/>
|
Lade<br/>
|
||||||
<span class="spinner"></span><br \>
|
<span class="spinner"></span><br \>
|
||||||
Karte & Knoten...
|
Karte & Knoten...
|
||||||
</p>
|
</p>
|
||||||
<noscript>
|
<noscript>
|
||||||
<strong>JavaScript required</strong>
|
<strong>JavaScript required</strong>
|
||||||
</noscript>
|
</noscript>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
56
lib/about.js
56
lib/about.js
|
|
@ -1,38 +1,38 @@
|
||||||
define(function () {
|
define(function () {
|
||||||
return function() {
|
return function () {
|
||||||
this.render = function (d) {
|
this.render = function (d) {
|
||||||
var el = document.createElement("div")
|
var el = document.createElement("div");
|
||||||
d.appendChild(el)
|
d.appendChild(el);
|
||||||
var s = "<h2>Über HopGlass</h2>"
|
var s = "<h2>Über HopGlass</h2>";
|
||||||
|
|
||||||
s += "<p>Mit Doppelklick und Shift+Doppelklick kann man in der Karte "
|
s += "<p>Mit Doppelklick und Shift+Doppelklick kann man in der Karte ";
|
||||||
s += "auch zoomen.</p>"
|
s += "auch zoomen.</p>";
|
||||||
|
|
||||||
s += "<h3>AGPL 3</h3>"
|
s += "<h3>AGPL 3</h3>";
|
||||||
|
|
||||||
s += "<p>Copyright (C) Milan Pässler</p>"
|
s += "<p>Copyright (C) Milan Pässler</p>";
|
||||||
s += "<p>Copyright (C) Nils Schneider</p>"
|
s += "<p>Copyright (C) Nils Schneider</p>";
|
||||||
|
|
||||||
s += "<p>This program is free software: you can redistribute it and/or "
|
s += "<p>This program is free software: you can redistribute it and/or ";
|
||||||
s += "modify it under the terms of the GNU Affero General Public "
|
s += "modify it under the terms of the GNU Affero General Public ";
|
||||||
s += "License as published by the Free Software Foundation, either "
|
s += "License as published by the Free Software Foundation, either ";
|
||||||
s += "version 3 of the License, or (at your option) any later version.</p>"
|
s += "version 3 of the License, or (at your option) any later version.</p>";
|
||||||
|
|
||||||
s += "<p>This program is distributed in the hope that it will be useful, "
|
s += "<p>This program is distributed in the hope that it will be useful, ";
|
||||||
s += "but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
s += "but WITHOUT ANY WARRANTY; without even the implied warranty of ";
|
||||||
s += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
|
s += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ";
|
||||||
s += "GNU Affero General Public License for more details.</p>"
|
s += "GNU Affero General Public License for more details.</p>";
|
||||||
|
|
||||||
s += "<p>You should have received a copy of the GNU Affero General "
|
s += "<p>You should have received a copy of the GNU Affero General ";
|
||||||
s += "Public License along with this program. If not, see "
|
s += "Public License along with this program. If not, see ";
|
||||||
s += "<a href=\"https://www.gnu.org/licenses/\">"
|
s += "<a href=\"https://www.gnu.org/licenses/\">";
|
||||||
s += "https://www.gnu.org/licenses/</a>.</p>"
|
s += "https://www.gnu.org/licenses/</a>.</p>";
|
||||||
|
|
||||||
s += "<p>The source code is available at "
|
s += "<p>The source code is available at ";
|
||||||
s += "<a href=\"https://github.com/plumpudding/hopglass\">"
|
s += "<a href=\"https://github.com/plumpudding/hopglass\">";
|
||||||
s += "https://github.com/plumpudding/hopglass</a>."
|
s += "https://github.com/plumpudding/hopglass</a>.";
|
||||||
|
|
||||||
el.innerHTML = s
|
el.innerHTML = s;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,21 @@
|
||||||
define([], function () {
|
define([], function () {
|
||||||
return function (tag) {
|
return function (tag) {
|
||||||
if (!tag)
|
if (!tag) {
|
||||||
tag = "div"
|
tag = "div";
|
||||||
|
}
|
||||||
|
|
||||||
var self = this
|
var self = this;
|
||||||
|
|
||||||
var container = document.createElement(tag)
|
var container = document.createElement(tag);
|
||||||
|
|
||||||
self.add = function (d) {
|
self.add = function (d) {
|
||||||
d.render(container)
|
d.render(container);
|
||||||
}
|
};
|
||||||
|
|
||||||
self.render = function (el) {
|
self.render = function (el) {
|
||||||
el.appendChild(container)
|
el.appendChild(container);
|
||||||
}
|
};
|
||||||
|
|
||||||
return self
|
return self;
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,91 @@
|
||||||
define(["filters/nodefilter"], function (NodeFilter) {
|
define(["filters/nodefilter"], function (NodeFilter) {
|
||||||
return function () {
|
return function () {
|
||||||
var targets = []
|
var targets = [];
|
||||||
var filterObservers = []
|
var filterObservers = [];
|
||||||
var filters = []
|
var filters = [];
|
||||||
var filteredData
|
var filteredData;
|
||||||
var data
|
var data;
|
||||||
|
|
||||||
function remove(d) {
|
function remove(d) {
|
||||||
targets = targets.filter( function (e) { return d !== e } )
|
targets = targets.filter(function (e) {
|
||||||
|
return d !== e;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function add(d) {
|
function add(d) {
|
||||||
targets.push(d)
|
targets.push(d);
|
||||||
|
|
||||||
if (filteredData !== undefined)
|
if (filteredData !== undefined) {
|
||||||
d.setData(filteredData)
|
d.setData(filteredData);
|
||||||
}
|
|
||||||
|
|
||||||
function setData(d) {
|
|
||||||
data = d
|
|
||||||
refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
function refresh() {
|
|
||||||
if (data === undefined)
|
|
||||||
return
|
|
||||||
|
|
||||||
var filter = filters.reduce( function (a, f) {
|
|
||||||
return function (d) {
|
|
||||||
return a(d) && f.run(d)
|
|
||||||
}
|
|
||||||
}, function () { return true })
|
|
||||||
|
|
||||||
filteredData = new NodeFilter(filter)(data)
|
|
||||||
|
|
||||||
targets.forEach( function (t) {
|
|
||||||
t.setData(filteredData)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function notifyObservers() {
|
|
||||||
filterObservers.forEach( function (d) {
|
|
||||||
d.filtersChanged(filters)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function addFilter(d) {
|
|
||||||
filters.push(d)
|
|
||||||
notifyObservers()
|
|
||||||
d.setRefresh(refresh)
|
|
||||||
refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFilter(d) {
|
|
||||||
filters = filters.filter( function (e) { return d !== e } )
|
|
||||||
notifyObservers()
|
|
||||||
refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
function watchFilters(d) {
|
|
||||||
filterObservers.push(d)
|
|
||||||
|
|
||||||
d.filtersChanged(filters)
|
|
||||||
|
|
||||||
return function () {
|
|
||||||
filterObservers = filterObservers.filter( function (e) { return d !== e })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { add: add,
|
function setData(d) {
|
||||||
remove: remove,
|
data = d;
|
||||||
setData: setData,
|
refresh();
|
||||||
addFilter: addFilter,
|
}
|
||||||
removeFilter: removeFilter,
|
|
||||||
watchFilters: watchFilters,
|
function refresh() {
|
||||||
refresh: refresh
|
if (data === undefined) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
var filter = filters.reduce(function (a, f) {
|
||||||
|
return function (d) {
|
||||||
|
return a(d) && f.run(d);
|
||||||
|
};
|
||||||
|
}, function () {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
filteredData = new NodeFilter(filter)(data);
|
||||||
|
|
||||||
|
targets.forEach(function (t) {
|
||||||
|
t.setData(filteredData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function notifyObservers() {
|
||||||
|
filterObservers.forEach(function (d) {
|
||||||
|
d.filtersChanged(filters);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFilter(d) {
|
||||||
|
filters.push(d);
|
||||||
|
notifyObservers();
|
||||||
|
d.setRefresh(refresh);
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFilter(d) {
|
||||||
|
filters = filters.filter(function (e) {
|
||||||
|
return d !== e;
|
||||||
|
});
|
||||||
|
notifyObservers();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function watchFilters(d) {
|
||||||
|
filterObservers.push(d);
|
||||||
|
|
||||||
|
d.filtersChanged(filters);
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
filterObservers = filterObservers.filter(function (e) {
|
||||||
|
return d !== e;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
add: add,
|
||||||
|
remove: remove,
|
||||||
|
setData: setData,
|
||||||
|
addFilter: addFilter,
|
||||||
|
removeFilter: removeFilter,
|
||||||
|
watchFilters: watchFilters,
|
||||||
|
refresh: refresh
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,43 @@
|
||||||
define([], function () {
|
define([], function () {
|
||||||
return function (distributor) {
|
return function (distributor) {
|
||||||
var container = document.createElement("ul")
|
var container = document.createElement("ul");
|
||||||
container.classList.add("filters")
|
container.classList.add("filters");
|
||||||
var div = document.createElement("div")
|
var div = document.createElement("div");
|
||||||
|
|
||||||
function render(el) {
|
function render(el) {
|
||||||
el.appendChild(div)
|
el.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filtersChanged(filters) {
|
function filtersChanged(filters) {
|
||||||
while (container.firstChild)
|
while (container.firstChild) {
|
||||||
container.removeChild(container.firstChild)
|
container.removeChild(container.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
filters.forEach( function (d) {
|
filters.forEach(function (d) {
|
||||||
var li = document.createElement("li")
|
var li = document.createElement("li");
|
||||||
var div = document.createElement("div")
|
var div = document.createElement("div");
|
||||||
container.appendChild(li)
|
container.appendChild(li);
|
||||||
li.appendChild(div)
|
li.appendChild(div);
|
||||||
d.render(div)
|
d.render(div);
|
||||||
|
|
||||||
var button = document.createElement("button")
|
var button = document.createElement("button");
|
||||||
button.textContent = ""
|
button.textContent = "";
|
||||||
button.onclick = function () {
|
button.onclick = function () {
|
||||||
distributor.removeFilter(d)
|
distributor.removeFilter(d);
|
||||||
}
|
};
|
||||||
li.appendChild(button)
|
li.appendChild(button);
|
||||||
})
|
});
|
||||||
|
|
||||||
if (container.parentNode === div && filters.length === 0)
|
if (container.parentNode === div && filters.length === 0) {
|
||||||
div.removeChild(container)
|
div.removeChild(container);
|
||||||
else if (filters.length > 0)
|
} else if (filters.length > 0) {
|
||||||
div.appendChild(container)
|
div.appendChild(container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { render: render,
|
return {
|
||||||
filtersChanged: filtersChanged
|
render: render,
|
||||||
}
|
filtersChanged: filtersChanged
|
||||||
}
|
};
|
||||||
})
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,56 @@
|
||||||
define([], function () {
|
define([], function () {
|
||||||
return function (name, key, value, f) {
|
return function (name, key, value, f) {
|
||||||
var negate = false
|
var negate = false;
|
||||||
var refresh
|
var refresh;
|
||||||
|
|
||||||
var label = document.createElement("label")
|
var label = document.createElement("label");
|
||||||
var strong = document.createElement("strong")
|
var strong = document.createElement("strong");
|
||||||
label.textContent = name + " "
|
label.textContent = name + " ";
|
||||||
label.appendChild(strong)
|
label.appendChild(strong);
|
||||||
|
|
||||||
function run(d) {
|
function run(d) {
|
||||||
var o = dictGet(d, key.slice(0))
|
var o = dictGet(d, key.slice(0));
|
||||||
|
|
||||||
if (f)
|
if (f) {
|
||||||
o = f(o)
|
o = f(o);
|
||||||
|
}
|
||||||
|
|
||||||
return o === value ? !negate : negate
|
return o === value ? !negate : negate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRefresh(f) {
|
function setRefresh(f) {
|
||||||
refresh = f
|
refresh = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(el) {
|
function draw(el) {
|
||||||
if (negate)
|
if (negate) {
|
||||||
el.parentNode.classList.add("not")
|
el.parentNode.classList.add("not");
|
||||||
else
|
} else {
|
||||||
el.parentNode.classList.remove("not")
|
el.parentNode.classList.remove("not");
|
||||||
|
}
|
||||||
|
|
||||||
strong.textContent = (negate ? "¬" : "" ) + value
|
strong.textContent = (negate ? "¬" : "" ) + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(el) {
|
function render(el) {
|
||||||
el.appendChild(label)
|
el.appendChild(label);
|
||||||
draw(el)
|
draw(el);
|
||||||
|
|
||||||
label.onclick = function () {
|
label.onclick = function () {
|
||||||
negate = !negate
|
negate = !negate;
|
||||||
|
|
||||||
draw(el)
|
draw(el);
|
||||||
|
|
||||||
if (refresh)
|
if (refresh) {
|
||||||
refresh()
|
refresh();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { run: run,
|
return {
|
||||||
setRefresh: setRefresh,
|
run: run,
|
||||||
render: render
|
setRefresh: setRefresh,
|
||||||
}
|
render: render
|
||||||
}
|
};
|
||||||
})
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,36 @@
|
||||||
define([], function () {
|
define([], function () {
|
||||||
return function (filter) {
|
return function (filter) {
|
||||||
return function (data) {
|
return function (data) {
|
||||||
var n = Object.create(data)
|
var n = Object.create(data);
|
||||||
n.nodes = {}
|
n.nodes = {};
|
||||||
|
|
||||||
for (var key in data.nodes)
|
for (var key in data.nodes) {
|
||||||
n.nodes[key] = data.nodes[key].filter(filter)
|
n.nodes[key] = data.nodes[key].filter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
var filteredIds = new Set()
|
var filteredIds = new Set();
|
||||||
|
|
||||||
n.graph = {}
|
n.graph = {};
|
||||||
n.graph.nodes = data.graph.nodes.filter( function (d) {
|
n.graph.nodes = data.graph.nodes.filter(function (d) {
|
||||||
var r
|
var r;
|
||||||
if (d.node)
|
if (d.node) {
|
||||||
r = filter(d.node)
|
r = filter(d.node);
|
||||||
else
|
} else {
|
||||||
r = filter({})
|
r = filter({});
|
||||||
|
}
|
||||||
|
|
||||||
if (r)
|
if (r) {
|
||||||
filteredIds.add(d.id)
|
filteredIds.add(d.id);
|
||||||
|
}
|
||||||
|
|
||||||
return r
|
return r;
|
||||||
})
|
});
|
||||||
|
|
||||||
n.graph.links = data.graph.links.filter( function (d) {
|
n.graph.links = data.graph.links.filter(function (d) {
|
||||||
return filteredIds.has(d.source.id) && filteredIds.has(d.target.id)
|
return filteredIds.has(d.source.id) && filteredIds.has(d.target.id);
|
||||||
})
|
});
|
||||||
|
|
||||||
return n
|
return n;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
1072
lib/forcegraph.js
1072
lib/forcegraph.js
File diff suppressed because it is too large
Load diff
200
lib/gui.js
200
lib/gui.js
|
|
@ -1,125 +1,127 @@
|
||||||
define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
define(["chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
||||||
"legend", "linklist", "nodelist", "simplenodelist", "infobox/main",
|
"legend", "linklist", "nodelist", "simplenodelist", "infobox/main",
|
||||||
"proportions", "forcegraph", "title", "about", "datadistributor",
|
"proportions", "forcegraph", "title", "about", "datadistributor",
|
||||||
"filters/filtergui" ],
|
"filters/filtergui"],
|
||||||
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Legend, Linklist,
|
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Legend, Linklist,
|
||||||
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
||||||
Title, About, DataDistributor, FilterGUI) {
|
Title, About, DataDistributor, FilterGUI) {
|
||||||
return function (config, router) {
|
return function (config, router) {
|
||||||
var self = this
|
var self = this;
|
||||||
var content
|
var content;
|
||||||
var contentDiv
|
var contentDiv;
|
||||||
|
|
||||||
var linkScale = chroma.scale(chroma.interpolate.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5])
|
var linkScale = chroma.scale(chroma.interpolate.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5]);
|
||||||
var sidebar
|
var sidebar;
|
||||||
|
|
||||||
var buttons = document.createElement("div")
|
var buttons = document.createElement("div");
|
||||||
buttons.classList.add("buttons")
|
buttons.classList.add("buttons");
|
||||||
|
|
||||||
var fanout = new DataDistributor()
|
var fanout = new DataDistributor();
|
||||||
var fanoutUnfiltered = new DataDistributor()
|
var fanoutUnfiltered = new DataDistributor();
|
||||||
fanoutUnfiltered.add(fanout)
|
fanoutUnfiltered.add(fanout);
|
||||||
|
|
||||||
function removeContent() {
|
function removeContent() {
|
||||||
if (!content)
|
if (!content) {
|
||||||
return
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
router.removeTarget(content)
|
router.removeTarget(content);
|
||||||
fanout.remove(content)
|
fanout.remove(content);
|
||||||
|
|
||||||
content.destroy()
|
content.destroy();
|
||||||
|
|
||||||
content = null
|
content = null;
|
||||||
}
|
|
||||||
|
|
||||||
function addContent(K) {
|
|
||||||
removeContent()
|
|
||||||
|
|
||||||
content = new K(config, linkScale, sidebar.getWidth, router, buttons)
|
|
||||||
content.render(contentDiv)
|
|
||||||
|
|
||||||
fanout.add(content)
|
|
||||||
router.addTarget(content)
|
|
||||||
}
|
|
||||||
|
|
||||||
function mkView(K) {
|
|
||||||
return function () {
|
|
||||||
addContent(K)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var loader = document.getElementsByClassName("loader")[0]
|
function addContent(K) {
|
||||||
loader.classList.add("hide")
|
removeContent();
|
||||||
|
|
||||||
contentDiv = document.createElement("div")
|
content = new K(config, linkScale, sidebar.getWidth, router, buttons);
|
||||||
contentDiv.classList.add("content")
|
content.render(contentDiv);
|
||||||
document.body.appendChild(contentDiv)
|
|
||||||
|
|
||||||
sidebar = new Sidebar(document.body)
|
fanout.add(content);
|
||||||
|
router.addTarget(content);
|
||||||
|
}
|
||||||
|
|
||||||
contentDiv.appendChild(buttons)
|
function mkView(K) {
|
||||||
|
return function () {
|
||||||
|
addContent(K);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var buttonToggle = document.createElement("button")
|
var loader = document.getElementsByClassName("loader")[0];
|
||||||
buttonToggle.textContent = "\uF133"
|
loader.classList.add("hide");
|
||||||
buttonToggle.onclick = function () {
|
|
||||||
if (content.constructor === Map)
|
|
||||||
router.view("g")
|
|
||||||
else
|
|
||||||
router.view("m")
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons.appendChild(buttonToggle)
|
contentDiv = document.createElement("div");
|
||||||
|
contentDiv.classList.add("content");
|
||||||
|
document.body.appendChild(contentDiv);
|
||||||
|
|
||||||
var title = new Title(config)
|
sidebar = new Sidebar(document.body);
|
||||||
|
|
||||||
var header = new Container("header")
|
contentDiv.appendChild(buttons);
|
||||||
var infobox = new Infobox(config, sidebar, router)
|
|
||||||
var tabs = new Tabs()
|
|
||||||
var overview = new Container()
|
|
||||||
var meshstats = new Meshstats(config)
|
|
||||||
var legend = new Legend()
|
|
||||||
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)
|
|
||||||
var about = new About()
|
|
||||||
|
|
||||||
fanoutUnfiltered.add(meshstats)
|
var buttonToggle = document.createElement("button");
|
||||||
fanoutUnfiltered.add(newnodeslist)
|
buttonToggle.textContent = "\uF133";
|
||||||
fanoutUnfiltered.add(lostnodeslist)
|
buttonToggle.onclick = function () {
|
||||||
fanout.add(nodelist)
|
if (content.constructor === Map) {
|
||||||
fanout.add(linklist)
|
router.view("g");
|
||||||
fanout.add(statistics)
|
} else {
|
||||||
|
router.view("m");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
sidebar.add(header)
|
buttons.appendChild(buttonToggle);
|
||||||
header.add(meshstats)
|
|
||||||
header.add(legend)
|
|
||||||
|
|
||||||
overview.add(newnodeslist)
|
var title = new Title(config);
|
||||||
overview.add(lostnodeslist)
|
|
||||||
|
|
||||||
var filterGUI = new FilterGUI(fanout)
|
var header = new Container("header");
|
||||||
fanout.watchFilters(filterGUI)
|
var infobox = new Infobox(config, sidebar, router);
|
||||||
header.add(filterGUI)
|
var tabs = new Tabs();
|
||||||
|
var overview = new Container();
|
||||||
|
var meshstats = new Meshstats(config);
|
||||||
|
var legend = new Legend();
|
||||||
|
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);
|
||||||
|
var about = new About();
|
||||||
|
|
||||||
sidebar.add(tabs)
|
fanoutUnfiltered.add(meshstats);
|
||||||
tabs.add("Aktuelles", overview)
|
fanoutUnfiltered.add(newnodeslist);
|
||||||
tabs.add("Knoten", nodelist)
|
fanoutUnfiltered.add(lostnodeslist);
|
||||||
tabs.add("Verbindungen", linklist)
|
fanout.add(nodelist);
|
||||||
tabs.add("Statistiken", statistics)
|
fanout.add(linklist);
|
||||||
tabs.add("Über", about)
|
fanout.add(statistics);
|
||||||
|
|
||||||
router.addTarget(title)
|
sidebar.add(header);
|
||||||
router.addTarget(infobox)
|
header.add(meshstats);
|
||||||
|
header.add(legend);
|
||||||
|
|
||||||
router.addView("m", mkView(Map))
|
overview.add(newnodeslist);
|
||||||
router.addView("g", mkView(ForceGraph))
|
overview.add(lostnodeslist);
|
||||||
|
|
||||||
router.view("m")
|
var filterGUI = new FilterGUI(fanout);
|
||||||
|
fanout.watchFilters(filterGUI);
|
||||||
|
header.add(filterGUI);
|
||||||
|
|
||||||
self.setData = fanoutUnfiltered.setData
|
sidebar.add(tabs);
|
||||||
|
tabs.add("Aktuelles", overview);
|
||||||
|
tabs.add("Knoten", nodelist);
|
||||||
|
tabs.add("Verbindungen", linklist);
|
||||||
|
tabs.add("Statistiken", statistics);
|
||||||
|
tabs.add("Über", about);
|
||||||
|
|
||||||
return self
|
router.addTarget(title);
|
||||||
}
|
router.addTarget(infobox);
|
||||||
})
|
|
||||||
|
router.addView("m", mkView(Map));
|
||||||
|
router.addView("g", mkView(ForceGraph));
|
||||||
|
|
||||||
|
router.view("m");
|
||||||
|
|
||||||
|
self.setData = fanoutUnfiltered.setData;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,49 @@
|
||||||
define(function () {
|
define(function () {
|
||||||
function showStatImg(o, d) {
|
function showStatImg(o, d) {
|
||||||
var subst = {}
|
var subst = {};
|
||||||
subst["{SOURCE}"] = d.source.node_id
|
subst["{SOURCE}"] = d.source.node_id;
|
||||||
subst["{SOURCE_NAME}"] = d.source.node.nodeinfo.hostname ? d.source.node.nodeinfo.hostname : "unknown"
|
subst["{SOURCE_NAME}"] = d.source.node.nodeinfo.hostname ? d.source.node.nodeinfo.hostname : "unknown";
|
||||||
subst["{TARGET}"] = d.target.node_id
|
subst["{TARGET}"] = d.target.node_id;
|
||||||
subst["{TARGET_NAME}"] = d.target.node.nodeinfo.hostname ? d.target.node.nodeinfo.hostname : "unknown"
|
subst["{TARGET_NAME}"] = d.target.node.nodeinfo.hostname ? d.target.node.nodeinfo.hostname : "unknown";
|
||||||
return showStat(o, subst)
|
return showStat(o, subst);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (config, el, router, d) {
|
return function (config, el, router, d) {
|
||||||
var unknown = !(d.source.node)
|
var unknown = !(d.source.node);
|
||||||
var h2 = document.createElement("h2")
|
var h2 = document.createElement("h2");
|
||||||
var a1 = document.createElement("a")
|
var a1 = document.createElement("a");
|
||||||
if (!unknown) {
|
if (!unknown) {
|
||||||
a1.href = "#"
|
a1.href = "#";
|
||||||
a1.onclick = router.node(d.source.node)
|
a1.onclick = router.node(d.source.node);
|
||||||
}
|
}
|
||||||
a1.textContent = unknown ? d.source.id : d.source.node.nodeinfo.hostname
|
a1.textContent = unknown ? d.source.id : d.source.node.nodeinfo.hostname;
|
||||||
h2.appendChild(a1)
|
h2.appendChild(a1);
|
||||||
h2.appendChild(document.createTextNode(" → "))
|
h2.appendChild(document.createTextNode(" → "));
|
||||||
var a2 = document.createElement("a")
|
var a2 = document.createElement("a");
|
||||||
a2.href = "#"
|
a2.href = "#";
|
||||||
a2.onclick = router.node(d.target.node)
|
a2.onclick = router.node(d.target.node);
|
||||||
a2.textContent = d.target.node.nodeinfo.hostname
|
a2.textContent = d.target.node.nodeinfo.hostname;
|
||||||
h2.appendChild(a2)
|
h2.appendChild(a2);
|
||||||
el.appendChild(h2)
|
el.appendChild(h2);
|
||||||
|
|
||||||
var attributes = document.createElement("table")
|
var attributes = document.createElement("table");
|
||||||
attributes.classList.add("attributes")
|
attributes.classList.add("attributes");
|
||||||
|
|
||||||
attributeEntry(attributes, "TQ", showTq(d))
|
attributeEntry(attributes, "TQ", showTq(d));
|
||||||
attributeEntry(attributes, "Entfernung", showDistance(d))
|
attributeEntry(attributes, "Entfernung", showDistance(d));
|
||||||
attributeEntry(attributes, "Typ", d.type)
|
attributeEntry(attributes, "Typ", d.type);
|
||||||
var hw1 = unknown ? null : dictGet(d.source.node.nodeinfo, ["hardware", "model"])
|
var hw1 = unknown ? null : dictGet(d.source.node.nodeinfo, ["hardware", "model"]);
|
||||||
var hw2 = dictGet(d.target.node.nodeinfo, ["hardware", "model"])
|
var hw2 = dictGet(d.target.node.nodeinfo, ["hardware", "model"]);
|
||||||
attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " – " + (hw2 != null ? hw2 : "unbekannt"))
|
attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " – " + (hw2 != null ? hw2 : "unbekannt"));
|
||||||
el.appendChild(attributes)
|
el.appendChild(attributes);
|
||||||
|
|
||||||
if (config.linkInfos)
|
if (config.linkInfos) {
|
||||||
config.linkInfos.forEach( function (linkInfo) {
|
config.linkInfos.forEach(function (linkInfo) {
|
||||||
var h4 = document.createElement("h4")
|
var h4 = document.createElement("h4");
|
||||||
h4.textContent = linkInfo.name
|
h4.textContent = linkInfo.name;
|
||||||
el.appendChild(h4)
|
el.appendChild(h4);
|
||||||
el.appendChild(showStatImg(linkInfo, d))
|
el.appendChild(showStatImg(linkInfo, d));
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,100 +1,103 @@
|
||||||
define(function () {
|
define(function () {
|
||||||
return function (config, el, router, d) {
|
return function (config, el, router, d) {
|
||||||
var sidebarTitle = document.createElement("h2")
|
var sidebarTitle = document.createElement("h2");
|
||||||
sidebarTitle.textContent = "Location: " + d.toString()
|
sidebarTitle.textContent = "Location: " + d.toString();
|
||||||
el.appendChild(sidebarTitle)
|
el.appendChild(sidebarTitle);
|
||||||
|
|
||||||
getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat=" + d.lat + "&lon=" + d.lng + "&zoom=18&addressdetails=0")
|
getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat=" + d.lat + "&lon=" + d.lng + "&zoom=18&addressdetails=0")
|
||||||
.then(function(result) {
|
.then(function (result) {
|
||||||
if(result.display_name)
|
if (result.display_name) {
|
||||||
sidebarTitle.textContent = result.display_name
|
sidebarTitle.textContent = result.display_name;
|
||||||
})
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var editLat = document.createElement("input")
|
var editLat = document.createElement("input");
|
||||||
editLat.type = "text"
|
editLat.type = "text";
|
||||||
editLat.value = d.lat.toFixed(9)
|
editLat.value = d.lat.toFixed(9);
|
||||||
el.appendChild(createBox("lat", "Breitengrad", editLat))
|
el.appendChild(createBox("lat", "Breitengrad", editLat));
|
||||||
|
|
||||||
var editLng = document.createElement("input")
|
var editLng = document.createElement("input");
|
||||||
editLng.type = "text"
|
editLng.type = "text";
|
||||||
editLng.value = d.lng.toFixed(9)
|
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 =
|
editUci.value =
|
||||||
"uci set gluon-node-info.@location[0]='location'; " +
|
"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].share_location='1';" +
|
||||||
"uci set gluon-node-info.@location[0].latitude='" + d.lat.toFixed(9) + "';" +
|
"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 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", "Befehl", editUci, false))
|
el.appendChild(createBox("uci", "Befehl", editUci, false));
|
||||||
|
|
||||||
var linkPlain = document.createElement("a")
|
var linkPlain = document.createElement("a");
|
||||||
linkPlain.textContent = "plain"
|
linkPlain.textContent = "plain";
|
||||||
linkPlain.onclick = function() {
|
linkPlain.onclick = function () {
|
||||||
switch2plain()
|
switch2plain();
|
||||||
return false
|
return false;
|
||||||
}
|
};
|
||||||
linkPlain.href = "#"
|
linkPlain.href = "#";
|
||||||
|
|
||||||
var linkUci = document.createElement("a")
|
var linkUci = document.createElement("a");
|
||||||
linkUci.textContent = "uci"
|
linkUci.textContent = "uci";
|
||||||
linkUci.onclick = function() {
|
linkUci.onclick = function () {
|
||||||
switch2uci()
|
switch2uci();
|
||||||
return false
|
return false;
|
||||||
}
|
};
|
||||||
linkUci.href = "#"
|
linkUci.href = "#";
|
||||||
|
|
||||||
var hintText = document.createElement("p")
|
var hintText = document.createElement("p");
|
||||||
hintText.appendChild(document.createTextNode("Du kannst zwischen "))
|
hintText.appendChild(document.createTextNode("Du kannst zwischen "));
|
||||||
hintText.appendChild(linkPlain)
|
hintText.appendChild(linkPlain);
|
||||||
hintText.appendChild(document.createTextNode(" und "))
|
hintText.appendChild(document.createTextNode(" und "));
|
||||||
hintText.appendChild(linkUci)
|
hintText.appendChild(linkUci);
|
||||||
hintText.appendChild(document.createTextNode(" wechseln."))
|
hintText.appendChild(document.createTextNode(" wechseln."));
|
||||||
el.appendChild(hintText)
|
el.appendChild(hintText);
|
||||||
|
|
||||||
function createBox(name, title, inputElem, isVisible) {
|
function createBox(name, title, inputElem, isVisible) {
|
||||||
var visible = typeof isVisible !== "undefined" ? isVisible : true
|
var visible = typeof isVisible !== "undefined" ? isVisible : true;
|
||||||
var box = document.createElement("div")
|
var box = document.createElement("div");
|
||||||
var heading = document.createElement("h3")
|
var heading = document.createElement("h3");
|
||||||
heading.textContent = title
|
heading.textContent = title;
|
||||||
box.appendChild(heading)
|
box.appendChild(heading);
|
||||||
var btn = document.createElement("button")
|
var btn = document.createElement("button");
|
||||||
btn.className = "ion-ios-copy"
|
btn.className = "ion-ios-copy";
|
||||||
btn.title = "Kopieren"
|
btn.title = "Kopieren";
|
||||||
btn.onclick = function() { copy2clip(inputElem.id) }
|
btn.onclick = function () {
|
||||||
inputElem.id = "location-" + name
|
copy2clip(inputElem.id);
|
||||||
inputElem.readOnly = true
|
};
|
||||||
var line = document.createElement("p")
|
inputElem.id = "location-" + name;
|
||||||
line.appendChild(inputElem)
|
inputElem.readOnly = true;
|
||||||
line.appendChild(btn)
|
var line = document.createElement("p");
|
||||||
box.appendChild(line)
|
line.appendChild(inputElem);
|
||||||
box.id = "box-" + name
|
line.appendChild(btn);
|
||||||
box.style.display = visible ? "block" : "none"
|
box.appendChild(line);
|
||||||
return box
|
box.id = "box-" + name;
|
||||||
|
box.style.display = visible ? "block" : "none";
|
||||||
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy2clip(id) {
|
function copy2clip(id) {
|
||||||
var copyField = document.querySelector("#" + id)
|
var copyField = document.querySelector("#" + id);
|
||||||
copyField.select()
|
copyField.select();
|
||||||
try {
|
try {
|
||||||
document.execCommand("copy")
|
document.execCommand("copy");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch2plain() {
|
function switch2plain() {
|
||||||
document.getElementById("box-uci").style.display = "none"
|
document.getElementById("box-uci").style.display = "none";
|
||||||
document.getElementById("box-lat").style.display = "block"
|
document.getElementById("box-lat").style.display = "block";
|
||||||
document.getElementById("box-lng").style.display = "block"
|
document.getElementById("box-lng").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch2uci() {
|
function switch2uci() {
|
||||||
document.getElementById("box-uci").style.display = "block"
|
document.getElementById("box-uci").style.display = "block";
|
||||||
document.getElementById("box-lat").style.display = "none"
|
document.getElementById("box-lat").style.display = "none";
|
||||||
document.getElementById("box-lng").style.display = "none"
|
document.getElementById("box-lng").style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,51 @@
|
||||||
define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Node, Location) {
|
define(["infobox/link", "infobox/node", "infobox/location"], function (Link, Node, Location) {
|
||||||
return function (config, sidebar, router) {
|
return function (config, sidebar, router) {
|
||||||
var self = this
|
var self = this;
|
||||||
var el
|
var el;
|
||||||
|
|
||||||
function destroy() {
|
function destroy() {
|
||||||
if (el && el.parentNode) {
|
if (el && el.parentNode) {
|
||||||
el.parentNode.removeChild(el)
|
el.parentNode.removeChild(el);
|
||||||
el = undefined
|
el = undefined;
|
||||||
sidebar.reveal()
|
sidebar.reveal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
destroy()
|
destroy();
|
||||||
sidebar.ensureVisible()
|
sidebar.ensureVisible();
|
||||||
sidebar.hide()
|
sidebar.hide();
|
||||||
|
|
||||||
el = document.createElement("div")
|
el = document.createElement("div");
|
||||||
sidebar.container.insertBefore(el, sidebar.container.firstChild)
|
sidebar.container.insertBefore(el, sidebar.container.firstChild);
|
||||||
|
|
||||||
el.scrollIntoView(false)
|
el.scrollIntoView(false);
|
||||||
el.classList.add("infobox")
|
el.classList.add("infobox");
|
||||||
el.destroy = destroy
|
el.destroy = destroy;
|
||||||
|
|
||||||
var closeButton = document.createElement("button")
|
var closeButton = document.createElement("button");
|
||||||
closeButton.classList.add("close")
|
closeButton.classList.add("close");
|
||||||
closeButton.onclick = router.reset
|
closeButton.onclick = router.reset;
|
||||||
el.appendChild(closeButton)
|
el.appendChild(closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.resetView = destroy
|
self.resetView = destroy;
|
||||||
|
|
||||||
self.gotoNode = function (d) {
|
self.gotoNode = function (d) {
|
||||||
create()
|
create();
|
||||||
new Node(config, el, router, d)
|
new Node(config, el, router, d);
|
||||||
}
|
};
|
||||||
|
|
||||||
self.gotoLink = function (d) {
|
self.gotoLink = function (d) {
|
||||||
create()
|
create();
|
||||||
new Link(config, el, router, d)
|
new Link(config, el, router, d);
|
||||||
}
|
};
|
||||||
|
|
||||||
self.gotoLocation = function (d) {
|
self.gotoLocation = function (d) {
|
||||||
create()
|
create();
|
||||||
new Location(config, el, router, d)
|
new Location(config, el, router, d);
|
||||||
}
|
};
|
||||||
|
|
||||||
return self
|
return self;
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
|
||||||
1190
lib/infobox/node.js
1190
lib/infobox/node.js
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue