Skip to content

Commit 9e8d63c

Browse files
committed
fix display of longer line popups
1 parent 3bdd7ac commit 9e8d63c

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Change Log for Node-RED Worldmap
22

3+
- v5.1.2 - Fix for longer line msg properties.
34
- v5.1.1 - Fix CoT inline image.
45
- v5.1.0 - Let special icons be sizeable using iconSize property.
56
- v5.0.9 - Slight tidy on flags, bump turf dep.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
1313

1414
### Updates
1515

16+
- v5.1.2 - Fix for longer line msg properties.
1617
- v5.1.1 - Fix CoT inline image.
1718
- v5.1.0 - Let special icons be sizeable using iconSize property.
1819
- v5.0.9 - Slight tidy on flags, bump turf dep.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-web-worldmap",
3-
"version": "5.1.1",
3+
"version": "5.1.2",
44
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
55
"dependencies": {
66
"@turf/bezier-spline": "~7.2.0",

worldmap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(RED) {
88
var compression = require("compression");
99
var sockjs = require('sockjs');
1010
var sockets = {};
11-
RED.log.info("Worldmap version " + require('./package.json').version );
11+
RED.log.info("Worldmap version: " + require('./package.json').version );
1212
// add the cgi module for serving local maps.... only if mapserv exists
1313
if (fs.existsSync((__dirname + '/mapserv'))) {
1414
RED.httpNode.use("/cgi-bin/mapserv", require('cgi')(__dirname + '/mapserv'));

worldmap/worldmap.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ var readFile = function(file) {
253253
file.type.indexOf('kmz') === -1 &&
254254
file.type.indexOf('json') === -1 &&
255255
file.type.indexOf('image/jpeg') === -1 &&
256+
file.type.indexOf('image/webp') === -1 &&
256257
file.type.indexOf('image/png') === -1 &&
257258
file.type.indexOf('image/tiff') === -1) {
258-
console.log('File is not text, kml, kmz, jpeg, png, or json', file.type, file);
259+
console.log('File is not text, kml, kmz, jpeg, png, webp, or json', file.type, file);
259260
return;
260261
}
261262

@@ -2359,17 +2360,19 @@ function setMarker(data) {
23592360
if (data.hasOwnProperty("greatcircle")) { delete data.greatcircle; }
23602361

23612362
// then any remaining properties to the info box
2363+
var longline = 0;
23622364
if (data.popup) { words = data.popup; }
23632365
else {
23642366
words += '<table>';
23652367
for (var i in data) {
23662368
if ((i != "name") && (i != "length") && (i != "clickable")) {
23672369
if (typeof data[i] === "object") {
2368-
words += '<tr><td>'+ i +'</td><td>' + JSON.stringify(data[i]) + '</td></tr>';
2370+
words += '<tr><td valign="top">'+ i +'</td><td>' + JSON.stringify(data[i]) + '</td></tr>';
23692371
}
23702372
else {
23712373
// words += i +" : "+data[i]+"<br/>";
2372-
words += '<tr><td>'+ i +'</td><td>' + data[i] + '</td></tr>';
2374+
if (data[i].length > longline) { longline = data[i].length; }
2375+
words += '<tr><td valign="top">'+ i +'</td><td>' + data[i] + '</td></tr>';
23732376
}
23742377
}
23752378
}
@@ -2379,6 +2382,7 @@ function setMarker(data) {
23792382
words = "<b>"+data["name"]+"</b><br/>" + words.replace(/\${name}/g,data["name"]); //"<button style=\"border-radius:4px; float:right; background-color:lightgrey;\" onclick='popped=false;popmark.closePopup();'>X</button><br/>" + words;
23802383
var wopt = {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200};
23812384
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="640"; } // make popup wider if it has an image or video
2385+
if (longline > 100) { wopt.minWidth="640"; } // make popup wider if it has a long line
23822386
if (!data.hasOwnProperty("clickable") && data.clickable != false) {
23832387
marker.bindPopup(words, wopt);
23842388
marker._popup.dname = data["name"];

0 commit comments

Comments
 (0)