From ca8cd8e24eea6898cd5e29013fc511cc533abf38 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 16 Jun 2019 15:57:30 +0100 Subject: [PATCH] Revert some ES6 stuff for a while --- CHANGELOG.md | 2 +- package.json | 2 +- worldmap/index.html | 2 +- worldmap/worldmap.js | 87 ++++++++++++++++++++++++++++++-------------- 4 files changed, 62 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 217181a..18fb0e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ### 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.12 - Ensure default icon is in place if not specified (regression) - v2.0.9 - Only update maxage on screen once it exists diff --git a/package.json b/package.json index 40a96d6..07eedd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "dependencies": { "cgi": "0.3.1", diff --git a/worldmap/index.html b/worldmap/index.html index 2367cd0..69df42a 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -56,7 +56,7 @@ - + diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index 53919eb..7e50a0c 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -43,6 +43,37 @@ var iconSz = { "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 var connect = function() { ws = new SockJS(location.pathname.split("index")[0] + 'socket'); @@ -174,16 +205,16 @@ else { }, "Clears the current heatmap", "bottomright"); } -var helpText = ` - - - - - -` -if (!inIframe) { helpText += `
 
Set Max Age s
Cluster at zoom <
Auto Pan Map
Lock Map
Heatmap all layers
Help
`; } -else { helpText += `` } -document.getElementById('menu').innerHTML = helpText; +var helpMenu = '' +helpMenu += ''; +helpMenu += ''; +helpMenu += ''; +helpMenu += ''; +helpMenu += ''; +helpMenu += ''; +if (!inIframe) { helpMenu += '
 
Set Max Age s
Cluster at zoom <
Auto Pan Map
Lock Map
Heatmap all layers
Help
'; } +else { helpMenu += '' } +document.getElementById('menu').innerHTML = helpMenu; if (showUserMenu) { if ( window.localStorage.hasOwnProperty("lastpos") ) { @@ -814,23 +845,23 @@ var doDialog = function(d) { dialogue.open(); } -var helpText = `

Node-RED - Map all the things


-

Search - 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 -search for a place name if connected to a network.

-

Set Max Age - You can set the time after which points -that haven't been updated get removed.

-

Cluster at zoom - lower numbers mean less clustering. 0 means disable totally.

-

Auto Pan - When selected, the map will -automatically move to centre on each data point as they arrive.

-

Lock Map - When selected will save the -currently displayed area and basemap. -Reloading the map in the current browser will return to the same view. -This can be used to set your initial start position. -While active it also restricts the "auto pan" and "search" to within that area.

-

Heatmap all layers - When selected -all layers whether hidden or not will contribute to the heatmap. -The default is that only visible layers add to the heatmap.

` +var helpText = '

Node-RED - Map all the things


'; +helpText += '

Search - You may enter a name, or partial name, or icon name of an object to search for.'; +helpText += 'The map will then jump to centre on each of the results in turn. If nothing is found locally it will try to'; +helpText += 'search for a place name if connected to a network.

'; +helpText += '

Set Max Age - You can set the time after which points'; +helpText += 'that haven\'t been updated get removed.

'; +helpText += '

Cluster at zoom - lower numbers mean less clustering. 0 means disable totally.

'; +helpText += '

Auto Pan - When selected, the map will'; +helpText += 'automatically move to centre on each data point as they arrive.

'; +helpText += '

Lock Map - When selected will save the'; +helpText += 'currently displayed area and basemap.'; +helpText += 'Reloading the map in the current browser will return to the same view.'; +helpText += 'This can be used to set your initial start position.'; +helpText += 'While active it also restricts the "auto pan" and "search" to within that area.

'; +helpText += '

Heatmap all layers - When selected'; +helpText += 'all layers whether hidden or not will contribute to the heatmap.'; +helpText += 'The default is that only visible layers add to the heatmap.

'; // Delete a marker (and notify websocket) var delMarker = function(dname,note) { @@ -964,7 +995,7 @@ function setMarker(data) { } if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; } delete data.action; - Object.keys(data).forEach(key => { + Object.keys(data).forEach(function(key) { if (data[key] == null) { delete allData[data.name][key]; } else { allData[data.name][key] = data[key]; } });