make sure maxage exists before setting value

This commit is contained in:
Dave Conway-Jones 2019-05-22 12:27:33 +01:00
parent e1b0572170
commit 58d6662bd8
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 21 additions and 19 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
- v2.0.9 - Only update maxage on screen once it exists
- v2.0.8 - Drop beta flag, re-organise index, js and css files. Now using leaflet 1.4
- v2.0.7-beta - Switch Ruler control to be independent of Draw library.
- v2.0.6-beta - Re-enable editing of draw layer, add rectangles to lines and areas. Make individual objects editable.

View File

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates
- v2.0.9 - Only update maxage on screen once it exists
- v2.0.8 - Drop beta flag, re-organise index, js and css files. Now using leaflet 1.4
- v2.0.7-beta - Switch Ruler control to be independent of Draw library.
- v2.0.6-beta - Re-enable editing of draw layer, add rectangles to lines and areas. Make individual objects editable.

View File

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "2.0.8",
"version": "2.0.9",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",

View File

@ -104,24 +104,6 @@ document.addEventListener ("keydown", function (ev) {
}
});
if (showUserMenu) {
if ( window.localStorage.hasOwnProperty("lastpos") ) {
var sp = JSON.parse(window.localStorage.getItem("lastpos"));
startpos = [ sp.lat, sp.lng ];
}
if ( window.localStorage.hasOwnProperty("lastzoom") ) {
startzoom = window.localStorage.getItem("lastzoom");
}
// if ( window.localStorage.hasOwnProperty("clusterat") ) {
// clusterAt = window.localStorage.getItem("clusterat");
// document.getElementById("setclus").value = clusterAt;
// }
if ( window.localStorage.hasOwnProperty("maxage") ) {
maxage = window.localStorage.getItem("maxage");
document.getElementById("maxage").value = maxage;
}
}
// Create the Initial Map object.
map = new L.map('map').setView(startpos, startzoom);
@ -203,6 +185,24 @@ if (!inIframe) { helpText += `<tr><td style="cursor:default"><span id="showHelp"
else { helpText += `</table>` }
document.getElementById('menu').innerHTML = helpText;
if (showUserMenu) {
if ( window.localStorage.hasOwnProperty("lastpos") ) {
var sp = JSON.parse(window.localStorage.getItem("lastpos"));
startpos = [ sp.lat, sp.lng ];
}
if ( window.localStorage.hasOwnProperty("lastzoom") ) {
startzoom = window.localStorage.getItem("lastzoom");
}
// if ( window.localStorage.hasOwnProperty("clusterat") ) {
// clusterAt = window.localStorage.getItem("clusterat");
// document.getElementById("setclus").value = clusterAt;
// }
if ( window.localStorage.hasOwnProperty("maxage") ) {
maxage = window.localStorage.getItem("maxage");
document.getElementById("maxage").value = maxage;
}
}
// Add graticule
var showGrid = false;
var Lgrid = L.latlngGraticule({