diff --git a/Lora-Map/resources/js/functions.js b/Lora-Map/resources/js/functions.js
index 8873c70..a43bc1a 100644
--- a/Lora-Map/resources/js/functions.js
+++ b/Lora-Map/resources/js/functions.js
@@ -1,43 +1,87 @@
-setInterval(timecorrectionrunner, 60000);
-timecorrectionrunner();
-
-function timecorrectionrunner() {
- var timecorrection = new XMLHttpRequest();
- timecorrection.onreadystatechange = parseAjaxTimecorrection;
- timecorrection.open("GET", "/currenttime", true);
- timecorrection.send();
-}
-
-var timeOffset = 0;
-
-function parseAjaxTimecorrection() {
- if (this.readyState === 4 && this.status === 200) {
- utcobject = JSON.parse(this.responseText);
+var FunctionsObject = {
+ _internalTimeOffset: 0,
+ Start: function () {
+ setInterval(this._Runner60000, 60000);
+ setInterval(this._Runner1000, 1000);
+ this._Runner60000();
+ this._Runner1000();
+ this._RunnerOnce();
+ return this;
+ },
+ _Runner60000: function () {
+ var get60000 = new XMLHttpRequest();
+ get60000.onreadystatechange = function () {
+ if (get60000.readyState === 4 && get60000.status === 200) {
+ var json = JSON.parse(get60000.responseText);
+ FunctionsObject._ParseAJAX(json["currenttime"]);
+ }
+ };
+ get60000.open("GET", "/get60000", true);
+ get60000.send();
+ },
+ _Runner1000: function () {
+ var get1000 = new XMLHttpRequest();
+ get1000.onreadystatechange = function () {
+ if (get1000.readyState === 4 && get1000.status === 200) {
+ var json = JSON.parse(get1000.responseText);
+ MarkerObject._ParseAJAXLoc(json["loc"]);
+ MarkerObject._ParseAJAXPanic(json["panic"]);
+ OverlayObject._ParseAJAXCount(json["cameracount"]);
+ OverlayObject._ParseAJAXDensity(json["crowdcount"]);
+ MenuObject._ParseAJAXWeatherAlerts(json["weatherwarnings"]);
+ MapObject._ParseAJAXFightDedection(json["fightdedect"]);
+ MapObject._ParseAJAXDensity(json["crowdcount"]);
+ }
+ };
+ get1000.open("GET", "/get1000", true);
+ get1000.send();
+ },
+ _RunnerOnce: function () {
+ var getonce = new XMLHttpRequest();
+ getonce.onreadystatechange = function () {
+ if (getonce.readyState === 4 && getonce.status === 200) {
+ var json = JSON.parse(getonce.responseText);
+ MapObject._ParseAJAXLayers(json["getlayer"]);
+ MapObject._ParseAJAXGeo(json["getgeo"]);
+ MapObject._ParseAJAXSettings(json["startup"]);
+ }
+ };
+ getonce.open("GET", "/getonce", true);
+ getonce.send();
+ },
+ _ParseAJAX: function (utcobject) {
if (utcobject.hasOwnProperty("utc")) {
- timeOffset = Date.now() - Date.parse(utcobject["utc"]);
+ this._internalTimeOffset = Date.now() - Date.parse(utcobject["utc"]);
+ }
+ },
+ TimeCalculation: function (timestr, type) {
+ if (type === "diffraw" || type === "difftext" || type === "difftextn") {
+ var diff = Math.round((Date.now() - Date.parse(timestr) - this._internalTimeOffset) / 1000);
+ if (type === "diffraw") {
+ return diff;
+ }
+ if (type === "difftextn" && diff < 0) {
+ diff = diff * -1;
+ }
+ var isneg = false;
+ if (diff < 0) {
+ isneg = true;
+ diff = diff * -1;
+ }
+ if (diff < 60) {
+ return (isneg ? "-" : "") + diff + " s";
+ }
+ if (diff < 60 * 60) {
+ return (isneg ? "-" : "") + Math.floor(diff / 60) + " m";
+ }
+ if (diff < 60 * 60 * 24) {
+ return (isneg ? "-" : "") + Math.floor(diff / (60 * 60)) + " h";
+ }
+ return (isneg ? "-" : "") + Math.floor(diff / (60 * 60 * 24)) + " d";
+ } else if (type === "str") {
+ var date = new Date(Date.parse(timestr) + this._internalTimeOffset);
+ var str = date.toLocaleString();
+ return str;
}
}
-}
-
-function timeCalculation(timestr, type) {
- if (type === "diffraw" || type === "difftext") {
- var diff = Math.round((Date.now() - Date.parse(timestr) - timeOffset) / 1000);
- if (type === "diffraw") {
- return diff;
- }
- if (diff < 60) {
- return diff + " s";
- }
- if (diff < 60 * 60) {
- return Math.floor(diff / 60) + " m";
- }
- if (diff < 60 * 60 * 24) {
- return Math.floor(diff / (60 * 60)) + " h";
- }
- return Math.floor(diff / (60 * 60 * 24)) + " d";
- } else if (type === "str") {
- var date = new Date(Date.parse(timestr) + timeOffset);
- var str = date.toLocaleString();
- return str;
- }
-}
\ No newline at end of file
+}.Start();
\ No newline at end of file
diff --git a/Lora-Map/resources/js/map.js b/Lora-Map/resources/js/map.js
index 747797c..cb821fd 100644
--- a/Lora-Map/resources/js/map.js
+++ b/Lora-Map/resources/js/map.js
@@ -1,197 +1,263 @@
-var mymap = L.map('bigmap').setView(["{%START_LOCATION%}"], 16);
-
-GetMapLayers();
-function GetMapLayers() {
- var layergetter = new XMLHttpRequest();
- layergetter.onreadystatechange = function () {
- if (layergetter.readyState === 4 && layergetter.status === 200) {
- var maps = JSON.parse(layergetter.responseText);
- var i = 0;
- for (var key in maps) {
- i++;
+var MapObject = {
+ Map: {},
+ GeoJson: {},
+ _FightDedection: {},
+ _DensityAreas: {},
+ _SpecialMarkers: new Array(),
+ Start: function () {
+ this.Map = L.map('bigmap').setView([0, 0], 16);
+ this._SetupMapZoomFontsize();
+ this._SetupClickHandler();
+ return this;
+ },
+ _ParseAJAXSettings: function (settings) {
+ this.Map.panTo([settings.Startloclat, settings.Startloclon]);
+ this._GenerateGrid(settings.Grid);
+ this._GenerateFightBoxes(settings.FightDedection);
+ this._GenerateDensityBoxes(settings.DensityArea);
+ },
+ _ParseAJAXLayers: function (maps) {
+ var i = 0;
+ for (var key in maps) {
+ i++;
+ }
+ if (i === 1) {
+ L.tileLayer(maps["online"]["url"], {
+ attribution: maps["online"]["attribution"],
+ minZoom: maps["online"]["minZoom"],
+ maxZoom: maps["online"]["maxZoom"]
+ }).addTo(this.Map);
+ } else {
+ var baseMaps = {};
+ for (key in maps) {
+ if (key !== "online") {
+ var basemap = L.tileLayer(maps[key]["url"], {
+ attribution: maps[key]["attribution"],
+ minZoom: maps[key]["minZoom"],
+ maxZoom: maps[key]["maxZoom"],
+ errorTileUrl: "css/icons/failtile.png"
+ });
+ basemap.addTo(this.Map);
+ baseMaps[maps[key]["title"]] = basemap;
+ break;
+ }
}
- if (i === 1) {
- L.tileLayer(maps["online"]["url"], {
- attribution: maps["online"]["attribution"],
- minZoom: maps["online"]["minZoom"],
- maxZoom: maps["online"]["maxZoom"]
- }).addTo(mymap);
- } else {
- var baseMaps = {};
- for (key in maps) {
- if (key !== "online") {
- var basemap = L.tileLayer(maps[key]["url"], {
- attribution: maps[key]["attribution"],
- minZoom: maps[key]["minZoom"],
- maxZoom: maps[key]["maxZoom"],
- errorTileUrl: "css/icons/failtile.png"
- });
- basemap.addTo(mymap);
- baseMaps[maps[key]["title"]] = basemap;
- break;
- }
+ for (key in maps) {
+ if (!baseMaps.hasOwnProperty(maps[key]["title"])) {
+ baseMaps[maps[key]["title"]] = L.tileLayer(maps[key]["url"], {
+ attribution: maps[key]["attribution"],
+ minZoom: maps[key]["minZoom"],
+ maxZoom: maps[key]["maxZoom"],
+ errorTileUrl: "css/icons/failtile.png"
+ });
}
- for (key in maps) {
- if (!baseMaps.hasOwnProperty(maps[key]["title"])) {
- baseMaps[maps[key]["title"]] = L.tileLayer(maps[key]["url"], {
- attribution: maps[key]["attribution"],
- minZoom: maps[key]["minZoom"],
- maxZoom: maps[key]["maxZoom"],
- errorTileUrl: "css/icons/failtile.png"
- });
+ }
+ L.control.layers(baseMaps).addTo(this.Map);
+ }
+ },
+ _GenerateGrid: function (grid) {
+ for (var i = 0; i < grid.Major.length; i++) {
+ var linemajor = grid.Major[i];
+ L.polyline([[linemajor.from[0], linemajor.from[1]], [linemajor.to[0], linemajor.to[1]]], { color: "red", weight: 1 }).addTo(this.Map);
+ }
+ for (var j = 0; j < grid.Minor.length; j++) {
+ var lineminor = grid.Minor[j];
+ L.polyline([[lineminor.from[0], lineminor.from[1]], [lineminor.to[0], lineminor.to[1]]], { color: "red", weight: 0.7, opacity: 0.5 }).addTo(this.Map);
+ }
+ },
+ _GenerateFightBoxes: function (fightdedection) {
+ for (var cameraid in fightdedection) {
+ this._FightDedection[cameraid] = L.polygon(fightdedection[cameraid], { color: 'black', weight: 1 }).addTo(this.Map);
+ this._FightDedection[cameraid].bindPopup("Fightdedection für Kamera: " + cameraid);
+ }
+ },
+ _ParseAJAXFightDedection: function (json) {
+ for (var cameraid in json) {
+ if (this._FightDedection.hasOwnProperty(cameraid)) {
+ var fight = json[cameraid];
+ var box = this._FightDedection[cameraid];
+ var diff = FunctionsObject.TimeCalculation(fight["LastUpdate"], "diffraw");
+ if (diff <= 10 && box.options.color === "black") {
+ box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' });
+ } else if (diff <= 10 && box.options.color !== "black") {
+ if (diff % 2 === 0) {
+ box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' });
+ } else {
+ box.setStyle({ color: 'green' });
}
+ } else if (diff > 10 && box.options.color !== "black") {
+ box.setStyle({ color: 'black' });
}
- L.control.layers(baseMaps).addTo(mymap);
}
}
- };
- layergetter.open("GET", "/getlayer", true);
- layergetter.send();
-}
-
-var SpecialMarkers = new Array();
-GetGeoLayer();
-function GetGeoLayer() {
- var geogetter = new XMLHttpRequest();
- geogetter.onreadystatechange = function () {
- if (geogetter.readyState === 4 && geogetter.status === 200) {
- var geo = JSON.parse(geogetter.responseText);
- if (!(Object.keys(geo).length === 0 && geo.constructor === Object)) {
- L.geoJSON(geo, {
- style: function (features) {
- return {
- color: typeof features.properties["stroke"] === "undefined" ? '#000000' : features.properties["stroke"],
- weight: typeof features.properties["stroke-width"] === "undefined" ? 1 : features.properties["stroke-width"],
- opacity: typeof features.properties["stroke-opacity"] === "undefined" ? 1 : features.properties["stroke-opacity"],
- fillColor: typeof features.properties["fill"] === "undefined" ? '#ffffff' : features.properties["fill"],
- fillOpacity: typeof features.properties["fill-opacity"] === "undefined" ? 1 : features.properties["fill-opacity"]
- };
- },
- onEachFeature: function (feature, layer) {
- if (feature.geometry.type === "Polygon" || feature.geometry.type === "Point" && feature.properties.hasOwnProperty("icon")) {
- var text = "
"+feature.properties.name+"";
- if (feature.properties.hasOwnProperty("description")) {
- text = text + "
" + feature.properties.description;
- }
- layer.bindPopup(text);
- }
- },
- pointToLayer: function (geoJsonPoint, latlng) {
- if (geoJsonPoint.properties.hasOwnProperty("description") && geoJsonPoint.properties["description"] === "snumber" && !geoJsonPoint.properties.hasOwnProperty("icon")) {
- var snumbericon = L.marker(latlng, {
- icon: new L.DivIcon({
- className: "snumber-icon",
- html: geoJsonPoint.properties["name"],
- iconSize: [8, 8]
- })
- });
- SpecialMarkers.push(snumbericon);
- return snumbericon;
- } else if (geoJsonPoint.properties.hasOwnProperty("description") && geoJsonPoint.properties["description"] === "coord" && !geoJsonPoint.properties.hasOwnProperty("icon")) {
- var coordicon = L.marker(latlng, {
- icon: new L.DivIcon({
- className: "coord-icon",
- html: geoJsonPoint.properties["name"]
- })
- });
- SpecialMarkers.push(coordicon);
- return coordicon;
- } else if (geoJsonPoint.properties.hasOwnProperty("icon")) {
- return L.marker(latlng, { icon: L.icon({ iconUrl: "css/icons/cctv.png", iconSize: [32, 32] }) });
- }
- }
- }).addTo(mymap);
+ },
+ _GenerateDensityBoxes: function (densityareas) {
+ for (var cameraid in densityareas) {
+ this._DensityAreas[cameraid] = { 'Poly': L.polygon(densityareas[cameraid].Polygon, { color: 'hsl(120,100%,50%)', weight: 1 }).addTo(this.Map), 'Maximum': densityareas[cameraid].Maximum };
+ this._DensityAreas[cameraid].Poly.bindPopup("
Besuchermenge:" +
+ "Besucher
(0/" + this._DensityAreas[cameraid].Maximum + ") Personen
" +
+ "
");
+ }
+ },
+ _ParseAJAXDensity: function (json) {
+ for (var cameraid in json) {
+ if (this._DensityAreas.hasOwnProperty(cameraid)) {
+ var crowd = json[cameraid];
+ var box = this._DensityAreas[cameraid].Poly;
+ var max = this._DensityAreas[cameraid].Maximum;
+ var cur = crowd.DensityCount;
+ if (cur > max) {
+ cur = max;
+ }
+ box.setStyle({ color: this._createRGB(cur, max) });
+ var p = box.getPopup().setContent("
Besuchermenge:" +
+ "Besucher
(" + crowd.DensityCount + "/" + max + ") Personen
" +
+ "
").update();
}
}
- };
- geogetter.open("GET", "/getgeo", true);
- geogetter.send();
-}
-
-mymap.on('zoomend', function () {
- var currentZoom = mymap.getZoom();
- if (currentZoom < 14) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "0px";
- elem._icon.style.marginLeft = "0px";
- elem._icon.style.marginTop = "0px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "0px";
- }
- });
- } else if (currentZoom === 14) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "0px";
- elem._icon.style.marginLeft = "0px";
- elem._icon.style.marginTop = "0px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "6px";
- }
- });
- } else if (currentZoom === 15) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "0px";
- elem._icon.style.marginLeft = "0px";
- elem._icon.style.marginTop = "0px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "9px";
- }
- });
- } else if (currentZoom === 16) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "5px";
- elem._icon.style.marginLeft = "-4px";
- elem._icon.style.marginTop = "-4px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "13px";
- }
- });
- } else if (currentZoom === 17) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "5px";
- elem._icon.style.marginLeft = "-4px";
- elem._icon.style.marginTop = "-4px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "16px";
- }
- });
- } else if (currentZoom === 18) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "8px";
- elem._icon.style.marginLeft = "-5px";
- elem._icon.style.marginTop = "-6px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "25px";
- }
- });
- } else if (currentZoom === 19) {
- SpecialMarkers.forEach(function (elem, index) {
- if (elem.feature.properties["description"] === "snumber") {
- elem._icon.style.fontSize = "14px";
- elem._icon.style.marginLeft = "-8px";
- elem._icon.style.marginTop = "-11px";
- }
- if (elem.feature.properties["description"] === "coord") {
- elem._icon.style.fontSize = "45px";
+ },
+ _createRGB: function (current, max) {
+ return "hsl(" + 120 * (1 - current / max) + ",100%,50%)";
+ },
+ _ParseAJAXGeo: function (geo) {
+ if (!(Object.keys(geo).length === 0 && geo.constructor === Object)) {
+ this.GeoJson = geo;
+ L.geoJSON(geo, {
+ style: function (features) {
+ return {
+ color: typeof features.properties["stroke"] === "undefined" ? '#000000' : features.properties["stroke"],
+ weight: typeof features.properties["stroke-width"] === "undefined" ? 1 : features.properties["stroke-width"],
+ opacity: typeof features.properties["stroke-opacity"] === "undefined" ? 1 : features.properties["stroke-opacity"],
+ fillColor: typeof features.properties["fill"] === "undefined" ? '#ffffff' : features.properties["fill"],
+ fillOpacity: typeof features.properties["fill-opacity"] === "undefined" ? 1 : features.properties["fill-opacity"]
+ };
+ },
+ onEachFeature: function (feature, layer) {
+ if (feature.geometry.type === "Polygon" || feature.geometry.type === "Point" && feature.properties.hasOwnProperty("icon")) {
+ var text = "
" + feature.properties.name + "";
+ if (feature.properties.hasOwnProperty("description")) {
+ text = text + "
" + feature.properties.description;
+ }
+ layer.bindPopup(text);
+ }
+ },
+ pointToLayer: function (geoJsonPoint, latlng) {
+ if (geoJsonPoint.properties.hasOwnProperty("description") && geoJsonPoint.properties["description"] === "snumber" && !geoJsonPoint.properties.hasOwnProperty("icon")) {
+ var snumbericon = L.marker(latlng, {
+ icon: new L.DivIcon({
+ className: "snumber-icon",
+ html: geoJsonPoint.properties["name"],
+ iconSize: [8, 8]
+ })
+ });
+ MapObject._SpecialMarkers.push(snumbericon);
+ return snumbericon;
+ } else if (geoJsonPoint.properties.hasOwnProperty("description") && geoJsonPoint.properties["description"] === "coord" && !geoJsonPoint.properties.hasOwnProperty("icon")) {
+ var coordicon = L.marker(latlng, {
+ icon: new L.DivIcon({
+ className: "coord-icon",
+ html: geoJsonPoint.properties["name"]
+ })
+ });
+ MapObject._SpecialMarkers.push(coordicon);
+ return coordicon;
+ } else if (geoJsonPoint.properties.hasOwnProperty("icon")) {
+ return L.marker(latlng, { icon: L.icon({ iconUrl: "css/icons/cctv.png", iconSize: [32, 32] }) });
+ }
+ }
+ }).addTo(this.Map);
+ }
+ },
+ _SetupMapZoomFontsize: function () {
+ this.Map.on('zoomend', function () {
+ var currentZoom = MapObject.Map.getZoom();
+ if (currentZoom < 14) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "0px";
+ elem._icon.style.marginLeft = "0px";
+ elem._icon.style.marginTop = "0px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "0px";
+ }
+ });
+ } else if (currentZoom === 14) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "0px";
+ elem._icon.style.marginLeft = "0px";
+ elem._icon.style.marginTop = "0px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "6px";
+ }
+ });
+ } else if (currentZoom === 15) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "0px";
+ elem._icon.style.marginLeft = "0px";
+ elem._icon.style.marginTop = "0px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "9px";
+ }
+ });
+ } else if (currentZoom === 16) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "5px";
+ elem._icon.style.marginLeft = "-4px";
+ elem._icon.style.marginTop = "-4px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "13px";
+ }
+ });
+ } else if (currentZoom === 17) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "5px";
+ elem._icon.style.marginLeft = "-4px";
+ elem._icon.style.marginTop = "-4px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "16px";
+ }
+ });
+ } else if (currentZoom === 18) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "8px";
+ elem._icon.style.marginLeft = "-5px";
+ elem._icon.style.marginTop = "-6px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "25px";
+ }
+ });
+ } else if (currentZoom === 19) {
+ MapObject._SpecialMarkers.forEach(function (elem, index) {
+ if (elem.feature.properties["description"] === "snumber") {
+ elem._icon.style.fontSize = "14px";
+ elem._icon.style.marginLeft = "-8px";
+ elem._icon.style.marginTop = "-11px";
+ }
+ if (elem.feature.properties["description"] === "coord") {
+ elem._icon.style.fontSize = "45px";
+ }
+ });
}
});
+ },
+ _SetupClickHandler: function () {
+ this.Map.on("click", this._HidePanel);
+ },
+ _HidePanel: function (e) {
+ MenuObject.ShowHidePanel(null);
+ },
+ JumpTo: function (lat, lon) {
+ this.Map.flyTo([lat, lon], 19);
}
-});
-
-mymap.on("click", hidePanel);
-
-function hidePanel(e) {
- showHidePanel(null);
-}
\ No newline at end of file
+}.Start();
\ No newline at end of file
diff --git a/Lora-Map/resources/js/marker.js b/Lora-Map/resources/js/marker.js
index dea8915..44dd496 100644
--- a/Lora-Map/resources/js/marker.js
+++ b/Lora-Map/resources/js/marker.js
@@ -1,27 +1,18 @@
-setInterval(datarunner, 1000);
-function datarunner() {
- var loc = new XMLHttpRequest();
- loc.onreadystatechange = parseAjaxLoc;
- loc.open("GET", "/loc", true);
- loc.send();
-
- var panic = new XMLHttpRequest();
- panic.onreadystatechange = parseAjaxPanic;
- panic.open("GET", "/panic", true);
- panic.send();
-}
-
-var markers = {};
-var serverLocation = {};
-//https://leafletjs.com/reference-1.4.0.html#marker
-function parseAjaxLoc() {
- if (this.readyState === 4 && this.status === 200) {
- serverLocation = JSON.parse(this.responseText);
- for (var key in serverLocation) {
- if (serverLocation.hasOwnProperty(key)) {
- var positionItem = serverLocation[key];
+var MarkerObject = {
+ _Markers: {},
+ PanicData: {},
+ LocationData: {},
+ VisibleMarkers: {},
+ Start: function () {
+ return this;
+ },
+ _ParseAJAXLoc: function (serverLocation) {
+ this.LocationData = serverLocation;
+ for (var key in this.LocationData) {
+ if (this.LocationData.hasOwnProperty(key)) {
+ var positionItem = this.LocationData[key];
if (positionItem['Latitude'] !== 0 || positionItem['Longitude'] !== 0) {
- if (!markers.hasOwnProperty(key)) {
+ if (!this._Markers.hasOwnProperty(key)) {
var marker = null;
if (positionItem['Icon'] === null) {
marker = L.marker([positionItem['Latitude'], positionItem['Longitude']], { 'title': positionItem['Name'] });
@@ -34,67 +25,80 @@ function parseAjaxLoc() {
});
marker = L.marker([positionItem['Latitude'], positionItem['Longitude']], { 'title': positionItem['Name'], 'icon': myIcon });
}
- markers[key] = marker.addTo(mymap).on("click", showMarkerInfo, key);
+ this._Markers[key] = marker.addTo(MapObject.Map).on("click", function () { MenuObject.statusToDevice = this; MenuObject.ShowHidePanel("pannels_info"); }, key);
} else {
- markers[key].setLatLng([positionItem['Latitude'], positionItem['Longitude']]);
+ this._Markers[key].setLatLng([positionItem['Latitude'], positionItem['Longitude']]);
if (positionItem['Icon'] !== null) {
- if (markers[key]._icon.children.length === 0) {
- markers[key].setIcon(L.divIcon({
+ if (this._Markers[key]._icon.children.length === 0) {
+ this._Markers[key].setIcon(L.divIcon({
className: 'pos-marker',
iconSize: [56, 80],
iconAnchor: [0, 80],
html: '

'
}));
- } else if (markers[key]._icon.children[0].hasAttribute("src")) {
- var old = markers[key]._icon.children[0]["src"].substring(markers[key]._icon.children[0]["src"].indexOf("/", 7) + 1);
+ } else if (this._Markers[key]._icon.children[0].hasAttribute("src")) {
+ var old = this._Markers[key]._icon.children[0]["src"].substring(this._Markers[key]._icon.children[0]["src"].indexOf("/", 7) + 1);
if (old !== positionItem['Icon']) {
- markers[key]._icon.children[0]["src"] = positionItem['Icon'];
+ this._Markers[key]._icon.children[0]["src"] = positionItem['Icon'];
}
}
} else {
- if (markers[key]._icon.children.length === 1 && markers[key]._icon.children[0].hasAttribute("src")) {
- markers[key].removeFrom(mymap);
- markers[key] = L.marker([positionItem['Latitude'], positionItem['Longitude']], { 'title': positionItem['Name'] }).addTo(mymap).on("click", showMarkerInfo, key);
+ if (this._Markers[key]._icon.children.length === 1 && this._Markers[key]._icon.children[0].hasAttribute("src")) {
+ this._Markers[key].removeFrom(MapObject.Map);
+ this._Markers[key] = L.marker([positionItem['Latitude'], positionItem['Longitude']], { 'title': positionItem['Name'] }).addTo(MapObject.Map).on("click", function () { MenuObject.statusToDevice = this; MenuObject.ShowHidePanel("pannels_info"); }, key);
}
}
}
- var lasttime = timeCalculation(positionItem['Recievedtime'], "diffraw");
- if (lasttime <= 5 * 60) {
- markers[key]._icon.style.opacity = 1;
- } else if (lasttime > 5 * 60 && lasttime <= 15 * 60) {
- markers[key]._icon.style.opacity = 0.9 - (lasttime - 5 * 60) / (15 * 60 - 5 * 60) * (0.9 - 0.7);
- } else if (lasttime > 15 * 60 && lasttime <= 30 * 60) {
- markers[key]._icon.style.opacity = 0.7 - (lasttime - 15 * 60) / (30 * 60 - 15 * 60) * (0.7 - 0.5);
- } else if (lasttime > 30 * 60 && lasttime <= 60 * 60) {
- markers[key]._icon.style.opacity = 0.5 - (lasttime - 30 * 60) / (30 * 60 - 30 * 60) * (0.5 - 0.25);
- } else if (lasttime > 60 * 60) {
- markers[key]._icon.style.opacity = 0.25;
+ if (positionItem.Group !== null && this.VisibleMarkers.hasOwnProperty("___isset") && !this.VisibleMarkers.hasOwnProperty(positionItem.Group)) {
+ this._Markers[key]._icon.style.opacity = 0;
+ } else {
+ var lasttime = FunctionsObject.TimeCalculation(positionItem['Recievedtime'], "diffraw");
+ if (lasttime <= 5 * 60) {
+ this._Markers[key]._icon.style.opacity = 1;
+ } else if (lasttime > 5 * 60 && lasttime <= 15 * 60) {
+ this._Markers[key]._icon.style.opacity = 0.9 - (lasttime - 5 * 60) / (15 * 60 - 5 * 60) * (0.9 - 0.7);
+ } else if (lasttime > 15 * 60 && lasttime <= 30 * 60) {
+ this._Markers[key]._icon.style.opacity = 0.7 - (lasttime - 15 * 60) / (30 * 60 - 15 * 60) * (0.7 - 0.5);
+ } else if (lasttime > 30 * 60 && lasttime <= 60 * 60) {
+ this._Markers[key]._icon.style.opacity = 0.5 - (lasttime - 30 * 60) / (30 * 60 - 30 * 60) * (0.5 - 0.25);
+ } else if (lasttime > 60 * 60) {
+ this._Markers[key]._icon.style.opacity = 0.25;
+ }
}
}
}
}
- updateStatus();
- update_pannels_info();
- }
-}
-
-var serverPanic = {};
-function parseAjaxPanic() {
- if (this.readyState === 4 && this.status === 200) {
- serverPanic = JSON.parse(this.responseText);
- for (var id in serverPanic) {
- if (serverPanic.hasOwnProperty(id)) {
- var alertItem = serverPanic[id];
- if (markers.hasOwnProperty(id)) {
- var marker = markers[id];
- if (timeCalculation(alertItem["Recievedtime"], "diffraw") <= 10 && marker._icon.className.indexOf(" marker-alert") === -1) {
- marker._icon.className += " marker-alert";
- showMarkerInfoPerId(id);
- } else if (timeCalculation(alertItem["Recievedtime"], "diffraw") > 10 && marker._icon.className.indexOf(" marker-alert") !== -1) {
- marker._icon.className = marker._icon.className.replace(" marker-alert", "");
+ MenuObject.UpdateStatus();
+ MenuObject._Update_pannels_info();
+ },
+ _ParseAJAXPanic: function (serverPanic) {
+ this.PanicData = serverPanic;
+ for (var id in this.PanicData) {
+ if (this.PanicData.hasOwnProperty(id)) {
+ var alertItem = this.PanicData[id];
+ if (this._Markers.hasOwnProperty(id)) {
+ var marker = this._Markers[id];
+ if (!(this.LocationData[id].Group !== null && this.VisibleMarkers.hasOwnProperty("___isset") && !this.VisibleMarkers.hasOwnProperty(this.LocationData[id].Group))) {
+ if (FunctionsObject.TimeCalculation(alertItem["Recievedtime"], "diffraw") <= 10 && marker._icon.className.indexOf(" marker-alert") === -1) {
+ marker._icon.className += " marker-alert";
+ MenuObject.ShowMarkerInfoPerId(id);
+ } else if (FunctionsObject.TimeCalculation(alertItem["Recievedtime"], "diffraw") > 10 && marker._icon.className.indexOf(" marker-alert") !== -1) {
+ marker._icon.className = marker._icon.className.replace(" marker-alert", "");
+ }
}
}
}
}
+ },
+ ChangeFilter: function (select) {
+ this.VisibleMarkers = {};
+ if (select.selectedOptions.length > 0) {
+ for (var i = 0; i < select.selectedOptions.length; i++) {
+ this.VisibleMarkers[select.selectedOptions[i].value] = true;
+ }
+ this.VisibleMarkers["no"] = true;
+ this.VisibleMarkers["___isset"] = true;
+ }
+ this._ParseAJAXLoc(this.LocationData);
}
-}
\ No newline at end of file
+}.Start();
\ No newline at end of file
diff --git a/Lora-Map/resources/js/menu.js b/Lora-Map/resources/js/menu.js
index 871124d..62a2249 100644
--- a/Lora-Map/resources/js/menu.js
+++ b/Lora-Map/resources/js/menu.js
@@ -1,175 +1,219 @@
-var visiblePanel = null;
-function showHidePanel(name) {
- if (visiblePanel === null && name !== null) {
- document.getElementById("pannels").style.display = "block";
- document.getElementById(name).style.display = "block";
- visiblePanel = name;
- if (typeof window["update_" + name] === "function") {
- window["update_" + name]();
- }
- } else if (visiblePanel === name && name !== "pannels_info" || name === null) {
- document.getElementById("pannels").style.display = "none";
- if (visiblePanel !== null) {
- document.getElementById(visiblePanel).style.display = "none";
- }
- visiblePanel = null;
- } else {
- document.getElementById(visiblePanel).style.display = "none";
- document.getElementById(name).style.display = "block";
- visiblePanel = name;
- if (typeof window["update_" + name] === "function") {
- window["update_" + name]();
- }
- }
-}
-
-var statusToDevice = null;
-function showMarkerInfo(e) {
- statusToDevice = this;
- showHidePanel("pannels_info");
-}
-
-function showMarkerInfoPerId(id) {
- statusToDevice = id;
- showHidePanel("pannels_info");
-}
-
-function showMarkerInfoMenu() {
- statusToDevice = this.getAttribute("rel");
- showHidePanel("pannels_info");
-}
-
-function update_pannels_info() {
- document.getElementById("pannels_info").innerHTML = "";
- if (serverLocation.hasOwnProperty(statusToDevice)) {
- var positionItem = serverLocation[statusToDevice];
- var html = "
Name: " + positionItem["Name"] + "
";
- html += "
Batterie: " + positionItem["Battery"] + "V

";
- if (positionItem["Fix"]) {
- html += "
GPS-Empfang
";
+var MenuObject = {
+ statusToDevice: null,
+ _visiblePanel: null,
+ _overviewStatus: new Array(),
+ Start: function () {
+ return this;
+ },
+ ShowHidePanel: function (name) {
+ if (this._visiblePanel === null && name !== null) {
+ document.getElementById("pannels").style.display = "block";
+ document.getElementById(name).style.display = "block";
+ this._visiblePanel = name;
+ if (typeof MenuObject["_Update_" + name] === "function") {
+ MenuObject["_Update_" + name]();
+ }
+ } else if (this._visiblePanel === name && name !== "pannels_info" || name === null) {
+ document.getElementById("pannels").style.display = "none";
+ if (this._visiblePanel !== null) {
+ document.getElementById(this._visiblePanel).style.display = "none";
+ }
+ this._visiblePanel = null;
} else {
- html += "
kein GPS-Empfang
";
+ document.getElementById(this._visiblePanel).style.display = "none";
+ document.getElementById(name).style.display = "block";
+ this._visiblePanel = name;
+ if (typeof MenuObject["_Update_" + name] === "function") {
+ MenuObject["_Update_" + name]();
+ }
}
- html += "
" + positionItem["UTM"]["Base"] + " " + positionItem["UTM"]["FieldWidth"] + "" + positionItem["UTM"]["Width"] + " " + positionItem["UTM"]["FieldHeight"] + "" + positionItem["UTM"]["Height"] + "
";
- html += "
Höhe: " + positionItem["Height"].toFixed(1) + " m
";
- html += "
HDOP: " + positionItem["Hdop"].toFixed(1) + "
";
- html += "
Dezimal: " + positionItem["Latitude"].toFixed(5) + ", " + positionItem["Longitude"].toFixed(5) + "
";
- html += "
Letzter Wert: Vor: " + timeCalculation(positionItem["Lastgpspostime"], "difftext") + "
";
- html += "
Update: " + timeCalculation(positionItem["Recievedtime"], "str") + "
Vor: " + timeCalculation(positionItem["Recievedtime"], "difftext") + "
";
- html += "
RSSI: " + positionItem["Rssi"] + ", SNR: " + positionItem["Snr"] + "
";
- if (serverPanic.hasOwnProperty(statusToDevice)) {
- var panicData = serverPanic[statusToDevice];
- if (panicData["ButtonPressed"].length > 0) {
- html += "
Alerts:";
- for (var i = 0; i < panicData["ButtonPressed"].length; i++) {
- html += "" + timeCalculation(panicData["ButtonPressed"][i], "str")+" (vor " + timeCalculation(panicData["ButtonPressed"][i],"difftext")+")";
+ },
+ ShowMarkerInfoPerId: function (id) {
+ this.statusToDevice = id;
+ this.ShowHidePanel("pannels_info");
+ },
+ UpdateStatus: function () {
+ for (var id in MarkerObject.LocationData) {
+ if (MarkerObject.LocationData.hasOwnProperty(id)) {
+ var positionItem = MarkerObject.LocationData[id];
+ if (typeof this._overviewStatus[id] === "undefined") {
+ this._overviewStatus[id] = this._CreateOverviewElement(positionItem, id);
+ document.getElementById("pannels_pos").appendChild(this._overviewStatus[id]);
}
- html += "
";
+ if (positionItem.Group !== null && MarkerObject.VisibleMarkers.hasOwnProperty("___isset") && !MarkerObject.VisibleMarkers.hasOwnProperty(positionItem.Group)) {
+ if (this._overviewStatus[id].className.indexOf("filter") === -1) {
+ this._overviewStatus[id].className = "item filter";
+ }
+ } else {
+ if (this._overviewStatus[id].className.indexOf("filter") !== -1) {
+ this._overviewStatus[id].className = "item";
+ }
+ }
+ this._UpdateOverviewElement(positionItem, id);
}
}
- document.getElementById("pannels_info").innerHTML = html;
- }
-}
-
-var overviewStatus = new Array();
-
-function updateStatus() {
- for (var id in serverLocation) {
- if (serverLocation.hasOwnProperty(id)) {
- var positionItem = serverLocation[id];
- if (typeof overviewStatus[id] === "undefined") {
- overviewStatus[id] = createOverviewElement(positionItem, id);
- document.getElementById("pannels_pos").appendChild(overviewStatus[id]);
- }
- updateOverviewElement(positionItem, id);
+ },
+ _UpdateOverviewElement: function (positionItem, id) {
+ if (positionItem["Batterysimple"] === 0) {
+ document.getElementById("overview-color-id-" + id).style.backgroundColor = "red";
+ } else if (positionItem["Batterysimple"] === 1 || positionItem["Batterysimple"] === 2) {
+ document.getElementById("overview-color-id-" + id).style.backgroundColor = "yellow";
+ } else if (positionItem["Batterysimple"] === 3 || positionItem["Batterysimple"] === 4) {
+ document.getElementById("overview-color-id-" + id).style.backgroundColor = "green";
}
- }
-}
-
-function updateOverviewElement(positionItem, id) {
- if (positionItem["Batterysimple"] === 0) {
- document.getElementById("overview-color-id-" + id).style.backgroundColor = "red";
- } else if (positionItem["Batterysimple"] === 1 || positionItem["Batterysimple"] === 2) {
- document.getElementById("overview-color-id-" + id).style.backgroundColor = "yellow";
- } else if (positionItem["Batterysimple"] === 3 || positionItem["Batterysimple"] === 4) {
- document.getElementById("overview-color-id-" + id).style.backgroundColor = "green";
- }
- document.getElementById("overview-name-id-" + id).innerText = positionItem["Name"];
- document.getElementById("overview-akkuimg-id-" + id).src = "icons/akku/" + positionItem["Batterysimple"] + "-4.png";
- if (positionItem["Fix"]) {
- document.getElementById("overview-gps-id-" + id).innerText = "GPS-Empfang";
- document.getElementById("overview-gps-id-" + id).style.color = "green";
- } else {
- document.getElementById("overview-gps-id-" + id).innerText = "kein GPS-Empfang";
- document.getElementById("overview-gps-id-" + id).style.color = "red";
- }
- document.getElementById("overview-update-id-" + id).innerText = "Letzte Werte: vor " + timeCalculation(positionItem["Recievedtime"], "difftext");
- if (positionItem['Icon'] === null) {
- var icon = document.getElementById("overview-icon-id-" + id);
- if (icon.children[0].hasAttribute("rel")) {
- document.getElementById("overview-icon-id-" + id).innerHTML = "

";
+ document.getElementById("overview-name-id-" + id).innerText = positionItem["Name"];
+ document.getElementById("overview-akkuimg-id-" + id).src = "icons/akku/" + positionItem["Batterysimple"] + "-4.png";
+ if (positionItem["Fix"]) {
+ document.getElementById("overview-gps-id-" + id).innerText = "GPS-Empfang";
+ document.getElementById("overview-gps-id-" + id).style.color = "green";
+ } else {
+ document.getElementById("overview-gps-id-" + id).innerText = "kein GPS-Empfang";
+ document.getElementById("overview-gps-id-" + id).style.color = "red";
}
- } else {
- if (document.getElementById("overview-icon-id-" + id).children[0].hasAttribute("src")) {
- if (document.getElementById("overview-icon-id-" + id).children[0]["src"].substring(document.getElementById("overview-icon-id-" + id).children[0]["src"].indexOf("/", 7) + 1) !== positionItem['Icon'] + "&marker-bg=hidden") {
- document.getElementById("overview-icon-id-" + id).children[0]["src"] = positionItem['Icon'] + "&marker-bg=hidden";
+ document.getElementById("overview-update-id-" + id).innerText = "Letzte Werte: vor " + FunctionsObject.TimeCalculation(positionItem["Recievedtime"], "difftext");
+ if (positionItem['Icon'] === null) {
+ var icon = document.getElementById("overview-icon-id-" + id);
+ if (icon.children[0].hasAttribute("rel")) {
+ document.getElementById("overview-icon-id-" + id).innerHTML = "

";
}
} else {
- document.getElementById("overview-icon-id-" + id).innerHTML = "

";
+ if (document.getElementById("overview-icon-id-" + id).children[0].hasAttribute("src")) {
+ if (document.getElementById("overview-icon-id-" + id).children[0]["src"].substring(document.getElementById("overview-icon-id-" + id).children[0]["src"].indexOf("/", 7) + 1) !== positionItem['Icon'] + "&marker-bg=hidden") {
+ document.getElementById("overview-icon-id-" + id).children[0]["src"] = positionItem['Icon'] + "&marker-bg=hidden";
+ }
+ } else {
+ document.getElementById("overview-icon-id-" + id).innerHTML = "

";
+ }
}
+ },
+ _CreateOverviewElement: function (positionItem, id) {
+ var divItem = document.createElement("div");
+ divItem.className = "item";
+ divItem.onclick = function showMarkerInfoMenu() {
+ MenuObject.statusToDevice = this.getAttribute("rel");
+ MenuObject.ShowHidePanel("pannels_info");
+ };
+ divItem.setAttribute("rel", id);
+ divItem.innerHTML = "
";
+ if (positionItem['Icon'] !== null) {
+ divItem.innerHTML += "

";
+ } else {
+ divItem.innerHTML += "

";
+ }
+ divItem.innerHTML += "
" +
+ "
" +
+ "

" +
+ "
";
+ divItem.innerHTML += "
kein GPS-Empfang
";
+ divItem.innerHTML += "
Letzte Werte: vor " + FunctionsObject.TimeCalculation(positionItem["Recievedtime"], "difftext") + "
";
+ return divItem;
+ },
+ _ParseAJAXPannelAdmin: function (loggedin) {
+ if (!loggedin) {
+ var html = "
Login to Adminpannel
";
+ document.getElementById("pannels_admin").innerHTML = html;
+ } else {
+ document.getElementById("pannels_admin").innerHTML = "
Adminpannel";
+ }
+ },
+ SubmitLoginForm: function () {
+ var adminlogin = new XMLHttpRequest();
+ adminlogin.onreadystatechange = function () {
+ if (adminlogin.readyState === 4 && adminlogin.status === 200) {
+ MenuObject._Update_pannels_admin();
+ }
+ };
+ adminlogin.open("POST", "/admin/login", true);
+ adminlogin.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ adminlogin.send("user=" + encodeURI(document.getElementById("pannels_admin_name").value) + "&pass=" + encodeURI(document.getElementById("pannels_admin_pass").value));
+ },
+ _Update_pannels_info: function () {
+ document.getElementById("pannels_info").innerHTML = "";
+ if (MarkerObject.LocationData.hasOwnProperty(this.statusToDevice)) {
+ var positionItem = MarkerObject.LocationData[this.statusToDevice];
+ var html = "
Name: " + positionItem["Name"] + "
";
+ html += "
Batterie: " + positionItem["Battery"] + "V

";
+ if (positionItem["Fix"]) {
+ html += "
GPS-Empfang
";
+ } else {
+ html += "
kein GPS-Empfang
";
+ }
+ html += "
" + positionItem["UTM"]["Base"] + " " + positionItem["UTM"]["FieldWidth"] + "" + positionItem["UTM"]["Width"] + " " + positionItem["UTM"]["FieldHeight"] + "" + positionItem["UTM"]["Height"] + "
";
+ html += "
Höhe: " + positionItem["Height"].toFixed(1) + " m
";
+ html += "
HDOP: " + positionItem["Hdop"].toFixed(1) + "
";
+ html += "
Dezimal: " + positionItem["Latitude"].toFixed(5) + ", " + positionItem["Longitude"].toFixed(5) + "
";
+ html += "
Letzter Wert: Vor: " + FunctionsObject.TimeCalculation(positionItem["Lastgpspostime"], "difftext") + "
";
+ html += "
Update: " + FunctionsObject.TimeCalculation(positionItem["Recievedtime"], "str") + "
Vor: " + FunctionsObject.TimeCalculation(positionItem["Recievedtime"], "difftext") + "
";
+ html += "
RSSI: " + positionItem["Rssi"] + ", SNR: " + positionItem["Snr"] + "
";
+ if (MarkerObject.PanicData.hasOwnProperty(this.statusToDevice)) {
+ var panicData = MarkerObject.PanicData[this.statusToDevice];
+ if (panicData["ButtonPressed"].length > 0) {
+ html += "
Alerts:";
+ for (var i = 0; i < panicData["ButtonPressed"].length; i++) {
+ html += "" + FunctionsObject.TimeCalculation(panicData["ButtonPressed"][i], "str") + " (vor " + FunctionsObject.TimeCalculation(panicData["ButtonPressed"][i], "difftext") + ")";
+ }
+ html += "
";
+ }
+ }
+ document.getElementById("pannels_info").innerHTML = html;
+ }
+ },
+ _Update_pannels_admin: function () {
+ var testadmin = new XMLHttpRequest();
+ testadmin.onreadystatechange = function () {
+ if (testadmin.readyState === 4 && testadmin.status === 403) {
+ MenuObject._ParseAJAXPannelAdmin(false);
+ } else if (testadmin.readyState === 4 && testadmin.status === 200) {
+ MenuObject._ParseAJAXPannelAdmin(true);
+ }
+ };
+ testadmin.open("GET", "/admin", true);
+ testadmin.send();
+ },
+ _ParseAJAXWeatherAlerts: function (json) {
+ if (json.length > 0) {
+ var html = "";
+ for (var i = 0; i < json.length; i++) {
+ var walert = json[i];
+ html += "
" +
+ "" + walert.Headline + "" +
+ "" + walert.Location + "" +
+ "" + walert.Body + (walert.Instructions !== "" ? "
" + walert.Instructions : "") + "" +
+ "Von: ";
+ if (FunctionsObject.TimeCalculation(walert.From, "diffraw") < 0) {
+ html += "in " + FunctionsObject.TimeCalculation(walert.From, "difftextn");
+ } else {
+ html += "vor " + FunctionsObject.TimeCalculation(walert.From, "difftext");
+ }
+ html += " Bis: in " + FunctionsObject.TimeCalculation(walert.To, "difftextn") + "" +
+ "
";
+ }
+ document.getElementById("pannels_weather").innerHTML = html;
+ document.getElementById("menucol_weather_icon").className = "weather ac";
+ } else {
+ document.getElementById("pannels_weather").innerHTML = "
Keine Gefahren
";
+ document.getElementById("menucol_weather_icon").className = "weather";
+ }
+ },
+ SearchInGeoJson: function (searchtext) {
+ var html = "";
+ if (MapObject.GeoJson.features.length > 0) {
+ for (var i = 0; i < MapObject.GeoJson.features.length; i++) {
+ var feature = MapObject.GeoJson.features[i];
+ if (feature.properties.name.indexOf(searchtext) !== -1 && feature.geometry.type === "Polygon") {
+ if (feature.geometry.coordinates.length > 0 && feature.geometry.coordinates[0].length > 0 && feature.geometry.coordinates[0][0].length > 0) {
+ html += "
" +
+ "" + feature.properties.name + "" +
+ "" + (typeof feature.properties.description !== "undefined" ? feature.properties.description : "") + "" +
+ "" +
+ "
";
+ }
+ }
+ }
+ }
+ document.getElementById("search_results").innerHTML = html;
}
-}
-
-function createOverviewElement(positionItem, id) {
- var divItem = document.createElement("div");
- divItem.className = "item";
- divItem.onclick = showMarkerInfoMenu;
- divItem.setAttribute("rel", id);
- divItem.innerHTML = "
";
- if (positionItem['Icon'] !== null) {
- divItem.innerHTML += "

";
- } else {
- divItem.innerHTML += "

";
- }
- divItem.innerHTML += "
" +
- "
" +
- "

" +
- "
";
- divItem.innerHTML += "
kein GPS-Empfang
";
- divItem.innerHTML += "
Letzte Werte: vor " + timeCalculation(positionItem["Recievedtime"], "difftext") + "
";
- return divItem;
-}
-
-
-function update_pannels_admin() {
- var testadmin = new XMLHttpRequest();
- testadmin.onreadystatechange = parseAjaxPannelAdmin;
- testadmin.open("GET", "/admin", true);
- testadmin.send();
-}
-
-function parseAjaxPannelAdmin() {
- if (this.readyState === 4 && this.status === 403) {
- var html = "
Login to Adminpannel
";
- document.getElementById("pannels_admin").innerHTML = html;
- } else if (this.readyState === 4 && this.status === 200) {
- document.getElementById("pannels_admin").innerHTML = "
Adminpannel";
- }
-}
-
-function submitloginform() {
- var adminlogin = new XMLHttpRequest();
- adminlogin.onreadystatechange = parseAjaxLogin;
- adminlogin.open("POST", "/admin/login", true);
- adminlogin.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
- adminlogin.send("user=" + encodeURI(document.getElementById("pannels_admin_name").value) + "&pass=" + encodeURI(document.getElementById("pannels_admin_pass").value));
-}
-
-function parseAjaxLogin() {
- if (this.readyState === 4 && this.status === 200) {
- update_pannels_admin();
- }
-}
\ No newline at end of file
+}.Start();
\ No newline at end of file
diff --git a/Lora-Map/resources/js/overlays.js b/Lora-Map/resources/js/overlays.js
index 9aed95c..f3eceae 100644
--- a/Lora-Map/resources/js/overlays.js
+++ b/Lora-Map/resources/js/overlays.js
@@ -1,18 +1,8 @@
-setInterval(overlayrunner, 1000);
-function overlayrunner() {
- var ccount = new XMLHttpRequest();
- ccount.onreadystatechange = parseAjaxCount;
- ccount.open("GET", "/cameracount", true);
- ccount.send();
- var cdensity = new XMLHttpRequest();
- cdensity.onreadystatechange = parseAjaxDensity;
- cdensity.open("GET", "/crowdcount", true);
- cdensity.send();
-}
-
-function parseAjaxCount() {
- if (this.readyState === 4 && this.status === 200) {
- var cameracounts = JSON.parse(this.responseText);
+var OverlayObject = {
+ Start: function () {
+ return this;
+ },
+ _ParseAJAXCount: function (cameracounts) {
var camerastext = "";
for (var cameraid in cameracounts) {
if (cameracounts.hasOwnProperty(cameraid)) {
@@ -27,12 +17,8 @@ function parseAjaxCount() {
}
}
document.getElementById("cameracount").innerHTML = camerastext;
- }
-}
-
-function parseAjaxDensity() {
- if (this.readyState === 4 && this.status === 200) {
- var cameradensy = JSON.parse(this.responseText);
+ },
+ _ParseAJAXDensity: function (cameradensy) {
var densystext = "";
for (var densyid in cameradensy) {
if (cameradensy.hasOwnProperty(densyid)) {
@@ -46,4 +32,4 @@ function parseAjaxDensity() {
}
document.getElementById("crwoddensy").innerHTML = densystext;
}
-}
\ No newline at end of file
+}.Start();
\ No newline at end of file