Revert some ES6 stuff for a while

This commit is contained in:
Dave Conway-Jones 2019-06-16 15:57:30 +01:00
parent f3c356bf7d
commit ca8cd8e24e
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 62 additions and 31 deletions

View File

@ -1,6 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.0.14 - Revert use of ES6 import. - v2.0.16 - Revert use of ES6 import. Keep IE11 happy for while.
- v2.0.13 - Fix tracks colour. - v2.0.13 - Fix tracks colour.
- v2.0.12 - Ensure default icon is in place if not specified (regression) - v2.0.12 - Ensure default icon is in place if not specified (regression)
- v2.0.9 - Only update maxage on screen once it exists - v2.0.9 - Only update maxage on screen once it exists

View File

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

View File

@ -56,7 +56,7 @@
<script src="leaflet/Leaflet.Dialog.js"></script> <script src="leaflet/Leaflet.Dialog.js"></script>
<script src="leaflet/l.ellipse.min.js"></script> <script src="leaflet/l.ellipse.min.js"></script>
<script src="leaflet/milsymbol.js"></script> <script src="leaflet/milsymbol.js"></script>
<script src="leaflet/nvg.js"></script> <script src="leaflet/nvg.js" async></script>
<script src="leaflet/leaflet-heat.js"></script> <script src="leaflet/leaflet-heat.js"></script>
<script src="leaflet/TileLayer.Grayscale.js"></script> <script src="leaflet/TileLayer.Grayscale.js"></script>
<script src="leaflet/TileLayer.GrayscaleWMS.js"></script> <script src="leaflet/TileLayer.GrayscaleWMS.js"></script>

View File

@ -43,6 +43,37 @@ var iconSz = {
"Command": 44 "Command": 44
}; };
// Polyfill assign for IE11 for now
if (typeof Object.assign !== 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target === null || target === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource !== null && nextSource !== undefined) {
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
// Create the socket // Create the socket
var connect = function() { var connect = function() {
ws = new SockJS(location.pathname.split("index")[0] + 'socket'); ws = new SockJS(location.pathname.split("index")[0] + 'socket');
@ -174,16 +205,16 @@ else {
}, "Clears the current heatmap", "bottomright"); }, "Clears the current heatmap", "bottomright");
} }
var helpText = `<table> var helpMenu = '<table>'
<tr><td><input type='text' name='search' id='search' size='20' style="width:150px;"/>&nbsp;<span onclick='doSearch();'><i class="fa fa-search fa-lg"></i></span></td></tr> helpMenu += '<tr><td><input type="text" name="search" id="search" size="20" style="width:150px;"/>&nbsp;<span onclick=\'doSearch();\'><i class="fa fa-search fa-lg"></i></span></td></tr>';
<tr><td style="cursor:default"><i class="fa fa-spinner fa-lg fa-fw"></i> Set Max Age <input type='text' name='maxage' id='maxage' value="600" size="5" onchange='setMaxAge();'/>s</td></tr> helpMenu += '<tr><td style="cursor:default"><i class="fa fa-spinner fa-lg fa-fw"></i> Set Max Age <input type="text" name="maxage" id="maxage" value="600" size="5" onchange=\'setMaxAge();\'/>s</td></tr>';
<tr><td style="cursor:default"><i class="fa fa-search-plus fa-lg fa-fw"></i> Cluster at zoom &lt;<input type='text' name='setclus' id='setclus' size="2" onchange='setCluster(this.value);'/></td></tr> helpMenu += '<tr><td style="cursor:default"><i class="fa fa-search-plus fa-lg fa-fw"></i> Cluster at zoom &lt;<input type="text" name="setclus" id="setclus" size="2" onchange=\'setCluster(this.value);\'/></td></tr>';
<tr><td style="cursor:default"><input type='checkbox' id='panit' onclick='doPanit(this.checked);'/> Auto Pan Map</td></tr> helpMenu += '<tr><td style="cursor:default"><input type="checkbox" id="panit" onclick=\'doPanit(this.checked);\'/> Auto Pan Map</td></tr>';
<tr><td style="cursor:default"><input type='checkbox' id='lockit' onclick='doLock(this.checked);'/> Lock Map</td></tr> helpMenu += '<tr><td style="cursor:default"><input type="checkbox" id="lockit" onclick=\'doLock(this.checked);\'/> Lock Map</td></tr>';
<tr><td style="cursor:default"><input type='checkbox' id='heatall' onclick='doHeatAll(this.checked);'/> Heatmap all layers</td></tr>` helpMenu += '<tr><td style="cursor:default"><input type="checkbox" id="heatall" onclick=\'doHeatAll(this.checked);\'/> Heatmap all layers</td></tr>';
if (!inIframe) { helpText += `<tr><td style="cursor:default"><span id="showHelp" onclick='doDialog(helpText);'><i class="fa fa-info fa-lg fa-fw"></i>Help</span></td></tr></table>`; } if (!inIframe) { helpMenu += '<tr><td style="cursor:default"><span id="showHelp" onclick=\'doDialog(helpText);\'><i class="fa fa-info fa-lg fa-fw"></i>Help</span></td></tr></table>'; }
else { helpText += `</table>` } else { helpMenu += '</table>' }
document.getElementById('menu').innerHTML = helpText; document.getElementById('menu').innerHTML = helpMenu;
if (showUserMenu) { if (showUserMenu) {
if ( window.localStorage.hasOwnProperty("lastpos") ) { if ( window.localStorage.hasOwnProperty("lastpos") ) {
@ -814,23 +845,23 @@ var doDialog = function(d) {
dialogue.open(); dialogue.open();
} }
var helpText = `<h3>Node-RED - Map all the things</h3><br/> var helpText = '<h3>Node-RED - Map all the things</h3><br/>';
<p><i class="fa fa-search fa-lg fa-fw"></i> <b>Search</b> - You may enter a name, or partial name, or icon name of an object to search for. helpText += '<p><i class="fa fa-search fa-lg fa-fw"></i> <b>Search</b> - You may enter a name, or partial name, or icon name of an object to search for.';
The map will then jump to centre on each of the results in turn. If nothing is found locally it will try to helpText += 'The map will then jump to centre on each of the results in turn. If nothing is found locally it will try to';
search for a place name if connected to a network.</p> helpText += 'search for a place name if connected to a network.</p>';
<p><i class="fa fa-spinner fa-lg fa-fw"></i> <b>Set Max Age</b> - You can set the time after which points helpText += '<p><i class="fa fa-spinner fa-lg fa-fw"></i> <b>Set Max Age</b> - You can set the time after which points';
that haven't been updated get removed.</p> helpText += 'that haven\'t been updated get removed.</p>';
<p><i class="fa fa-search-plus fa-lg fa-fw"></i> <b>Cluster at zoom</b> - lower numbers mean less clustering. 0 means disable totally.</p> helpText += '<p><i class="fa fa-search-plus fa-lg fa-fw"></i> <b>Cluster at zoom</b> - lower numbers mean less clustering. 0 means disable totally.</p>';
<p><i class="fa fa-arrows fa-lg fa-fw"></i> <b>Auto Pan</b> - When selected, the map will helpText += '<p><i class="fa fa-arrows fa-lg fa-fw"></i> <b>Auto Pan</b> - When selected, the map will';
automatically move to centre on each data point as they arrive.</p> helpText += 'automatically move to centre on each data point as they arrive.</p>';
<p><i class="fa fa-lock fa-lg fa-fw"></i> <b>Lock Map</b> - When selected will save the helpText += '<p><i class="fa fa-lock fa-lg fa-fw"></i> <b>Lock Map</b> - When selected will save the';
currently displayed area and basemap. helpText += 'currently displayed area and basemap.';
Reloading the map in the current browser will return to the same view. helpText += 'Reloading the map in the current browser will return to the same view.';
This can be used to set your initial start position. helpText += 'This can be used to set your initial start position.';
While active it also restricts the "auto pan" and "search" to within that area.</p> helpText += 'While active it also restricts the "auto pan" and "search" to within that area.</p>';
<p><i class="fa fa-globe fa-lg fa-fw"></i> <b>Heatmap all layers</b> - When selected helpText += '<p><i class="fa fa-globe fa-lg fa-fw"></i> <b>Heatmap all layers</b> - When selected';
all layers whether hidden or not will contribute to the heatmap. helpText += 'all layers whether hidden or not will contribute to the heatmap.';
The default is that only visible layers add to the heatmap.</p>` helpText += 'The default is that only visible layers add to the heatmap.</p>';
// Delete a marker (and notify websocket) // Delete a marker (and notify websocket)
var delMarker = function(dname,note) { var delMarker = function(dname,note) {
@ -964,7 +995,7 @@ function setMarker(data) {
} }
if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; } if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; }
delete data.action; delete data.action;
Object.keys(data).forEach(key => { Object.keys(data).forEach(function(key) {
if (data[key] == null) { delete allData[data.name][key]; } if (data[key] == null) { delete allData[data.name][key]; }
else { allData[data.name][key] = data[key]; } else { allData[data.name][key] = data[key]; }
}); });