[TASK] Improve code, remove unsed code

This commit is contained in:
Xaver Maierhofer 2017-01-20 15:06:06 +01:00
parent 3b4896f0da
commit 7d838dd7a1
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8
6 changed files with 37 additions and 81 deletions

View File

@ -3,42 +3,40 @@ define(function () {
return function () {
this.render = function (d) {
var s = "<h2>Über Meshviewer</h2>";
d.innerHTML = "<h2>Über Meshviewer</h2>" +
s += "<p>Mit Doppelklick und Shift+Doppelklick kann man in der Karte ";
s += "auch zoomen.</p>";
"<p>Mit Doppelklick und Shift+Doppelklick kann man in der Karte " +
"auch zoomen.</p>" +
s += "<h3>AGPL 3</h3>";
"<h3>AGPL 3</h3>" +
s += "<p>Copyright (C) Milan Pässler</p>";
s += "<p>Copyright (C) Nils Schneider</p>";
"<p>Copyright (C) Milan Pässler</p>" +
"<p>Copyright (C) Nils Schneider</p>" +
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 += "License as published by the Free Software Foundation, either ";
s += "version 3 of the License, or (at your option) any later version.</p>";
"<p>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.</p>" +
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 += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ";
s += "GNU Affero General Public License for more details.</p>";
"<p>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.</p>" +
s += "<p>You should have received a copy of the GNU Affero General ";
s += "Public License along with this program. If not, see ";
s += "<a href=\"https://www.gnu.org/licenses/\">";
s += "https://www.gnu.org/licenses/</a>.</p>";
"<p>You should have received a copy of the GNU Affero General " +
"Public License along with this program. If not, see " +
"<a href=\"https://www.gnu.org/licenses/\">" +
"https://www.gnu.org/licenses/</a>.</p>" +
s += "<p>The source code is available at ";
s += "<a href=\"https://github.com/ffrgb/meshviewer\">";
s += "https://github.com/ffrgb/meshviewer</a>.";
"<p>The source code is available at " +
"<a href=\"https://github.com/ffrgb/meshviewer\">" +
"https://github.com/ffrgb/meshviewer</a>." +
s += "<p>Forked and based on ";
s += "<a href=\"https://github.com/ffnord/meshviewer\">";
s += "https://github.com/ffnord/meshviewer</a> and ";
s += "<a href=\"https://github.com/plumpudding/hopglass\">";
s += "https://github.com/plumpudding/hopglass</a>.</p>";
d.innerHTML = s;
"<p>Forked and based on " +
"<a href=\"https://github.com/ffnord/meshviewer\">" +
"https://github.com/ffnord/meshviewer</a> and " +
"<a href=\"https://github.com/plumpudding/hopglass\">" +
"https://github.com/plumpudding/hopglass</a>.</p>";
};
};
});

View File

@ -33,22 +33,6 @@ define(["helper"], function (helper) {
el.appendChild(createBox("uci", "Uci", editUci));
var linkPlain = document.createElement("a");
linkPlain.textContent = "plain";
linkPlain.onclick = function () {
switch2plain();
return false;
};
linkPlain.href = "#";
var linkUci = document.createElement("a");
linkUci.textContent = "uci";
linkUci.onclick = function () {
switch2uci();
return false;
};
linkUci.href = "#";
function createBox(name, title, inputElem) {
var box = document.createElement("div");
var heading = document.createElement("h3");

View File

@ -9,7 +9,7 @@ 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.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);
};

View File

@ -6,35 +6,11 @@ define(function () {
self.render = function (el) {
var p = document.createElement("p");
p.setAttribute("class", "legend");
p.classList.add("legend");
p.innerHTML = '<span class="legend-new"><span class="symbol"></span> Neuer Knoten</span>' +
'<span class="legend-online"><span class="symbol"></span> Knoten ist online</span>' +
'<span class="legend-offline"><span class="symbol"></span> Knoten ist offline</span>';
el.appendChild(p);
var spanNew = document.createElement("span");
spanNew.setAttribute("class", "legend-new");
var symbolNew = document.createElement("span");
symbolNew.setAttribute("class", "symbol");
var textNew = document.createTextNode(" Neuer Knoten");
spanNew.appendChild(symbolNew);
spanNew.appendChild(textNew);
p.appendChild(spanNew);
var spanOnline = document.createElement("span");
spanOnline.setAttribute("class", "legend-online");
var symbolOnline = document.createElement("span");
symbolOnline.setAttribute("class", "symbol");
var textOnline = document.createTextNode(" Knoten ist online");
spanOnline.appendChild(symbolOnline);
spanOnline.appendChild(textOnline);
p.appendChild(spanOnline);
var spanOffline = document.createElement("span");
spanOffline.setAttribute("class", "legend-offline");
var symbolOffline = document.createElement("span");
symbolOffline.setAttribute("class", "symbol");
var textOffline = document.createTextNode(" Knoten ist offline");
spanOffline.appendChild(symbolOffline);
spanOffline.appendChild(textOffline);
p.appendChild(spanOffline);
};
return self;

View File

@ -333,14 +333,14 @@ define(["map/clientlayer", "map/labelslayer",
if (cssMode) {
cssMode.parentNode.removeChild(cssMode);
document.querySelector("html").className = '';
labelsLayer.updateColor();
labelsLayer.updateLayer();
}
if (e.layer.options.mode) {
document.querySelector("head").innerHTML += "<link rel='stylesheet' class='css-mode' href='" + e.layer.options.mode + ".css'>";
document.querySelector("html").classList.add(e.layer.options.mode);
var cssInterval = setInterval(function () {
if (typeof document.querySelector(".css-mode").sheet.cssRules != 'undefined') {
labelsLayer.updateColor();
labelsLayer.updateLayer();
clearInterval(cssInterval);
}
}, 10);

View File

@ -84,12 +84,10 @@ define(["leaflet", "rbush"],
},
setData: function (d) {
this.data = d;
if (this._map) {
this.prepareLabels();
}
this.updateLayer();
},
updateColor: function() {
if(this._map) {
updateLayer: function () {
if (this._map) {
this.prepareLabels();
}
},
@ -108,7 +106,7 @@ define(["leaflet", "rbush"],
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)');
labelShadow = bodyStyle.backgroundColor.replace(/rgb/i, "rgba").replace(/\)/i, ',0.7)');
var labels = []
.concat(labelsNew)