diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..40b878d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules/
\ No newline at end of file
diff --git a/examples/feedback.json b/examples/feedback.json
new file mode 100644
index 0000000..907eefc
--- /dev/null
+++ b/examples/feedback.json
@@ -0,0 +1,129 @@
+[
+ {
+ "id": "46f4b9ae1c66c1ba",
+ "type": "tab",
+ "label": "Flow 4",
+ "disabled": false,
+ "info": "",
+ "env": []
+ },
+ {
+ "id": "c643e022.1816c",
+ "type": "worldmap",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "",
+ "lat": "30",
+ "lon": "0",
+ "zoom": "3",
+ "layer": "OSMG",
+ "cluster": "",
+ "maxage": "",
+ "usermenu": "show",
+ "layers": "show",
+ "panit": "false",
+ "panlock": "false",
+ "zoomlock": "false",
+ "hiderightclick": "false",
+ "coords": "deg",
+ "showgrid": "false",
+ "showruler": "false",
+ "allowFileDrop": "false",
+ "path": "worldmap",
+ "overlist": "DR,CO,RA,DN",
+ "maplist": "OSMG,OSMH,EsriS",
+ "mapname": "",
+ "mapurl": "",
+ "mapopt": "",
+ "mapwms": false,
+ "x": 1000,
+ "y": 480,
+ "wires": []
+ },
+ {
+ "id": "4966f5218c3fe1df",
+ "type": "inject",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "",
+ "repeat": "",
+ "crontab": "",
+ "once": false,
+ "topic": "",
+ "payload": "",
+ "payloadType": "none",
+ "x": 530,
+ "y": 480,
+ "wires": [
+ [
+ "87dff974113c8c54"
+ ]
+ ]
+ },
+ {
+ "id": "87dff974113c8c54",
+ "type": "function",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "add new rectangle",
+ "func": "\nmsg.payload = {\"command\":{\"bounds\":[[49.83682820280039,-4.019763692204326],[51.4723362586149,1.1741268015945219]]}};\nnode.send(msg);\nmsg.payload = {\"command\":{\"zoom\":9.7}};\nnode.send(msg);\n\n\nvar popup = \"\";\npopup += \"\";\n\nvar points = [ { \"lat\": 50.66, \"lng\": -1.59 }, { \"lat\": 50.60, \"lng\": -1.47 } ] ;\nmsg.payload = {\n popup: popup.replace(/\\{x\\}/,\"popup\"),\n contextmenu: popup.replace(/\\{x\\}/, \"context\"),\n name: \"myShape\",\n area: points,\n clickable:true,\n };\nnode.send(msg);\n\nmsg.payload = {\n popup: popup,\n contextmenu: popup,\n name: \"myMarker\",\n lat: 50.40,\n lon: -1.0,\n weight: 1,\n};\nnode.send(msg);\nreturn msg;",
+ "outputs": 1,
+ "timeout": "",
+ "noerr": 0,
+ "initialize": "",
+ "finalize": "",
+ "libs": [],
+ "x": 770,
+ "y": 480,
+ "wires": [
+ [
+ "c643e022.1816c",
+ "34ad8daae96efd3e"
+ ]
+ ]
+ },
+ {
+ "id": "32d7cc4d4db67f66",
+ "type": "worldmap in",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "",
+ "path": "/worldmap",
+ "events": "connect,disconnect,point,layer,bounds,files,draw,other",
+ "x": 500,
+ "y": 540,
+ "wires": [
+ [
+ "32a2b83008623990"
+ ]
+ ]
+ },
+ {
+ "id": "32a2b83008623990",
+ "type": "debug",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "debug 14",
+ "active": true,
+ "tosidebar": true,
+ "console": false,
+ "tostatus": false,
+ "complete": "false",
+ "statusVal": "",
+ "statusType": "auto",
+ "x": 680,
+ "y": 540,
+ "wires": []
+ },
+ {
+ "id": "34ad8daae96efd3e",
+ "type": "debug",
+ "z": "46f4b9ae1c66c1ba",
+ "name": "debug 15",
+ "active": true,
+ "tosidebar": true,
+ "console": false,
+ "tostatus": false,
+ "complete": "false",
+ "statusVal": "",
+ "statusType": "auto",
+ "x": 980,
+ "y": 400,
+ "wires": []
+ }
+]
\ No newline at end of file
diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js
index fc78edc..68a442a 100644
--- a/worldmap/worldmap.js
+++ b/worldmap/worldmap.js
@@ -865,6 +865,10 @@ var addThing = function() {
var form = {};
var addToForm = function(n,v) { form[n] = v; }
var feedback = function(n,v,a,c) {
+/*
+// suggest to reove all the special handling for simplification, no reason to send information
+// about entities that the backend generaed, the need is only to get recognizable actions from the frontend
+//
if (v === "_form") { v = form; }
if (markers[n]) {
console.log("FB1",n,v,a,c)
@@ -875,8 +879,10 @@ var feedback = function(n,v,a,c) {
setMarker(allData[n]);
}
else if (polygons[n]) {
- console.log("FB2",n,v,a)
- sendDrawing(n,v,a)
+ console.log("FB2", n, v, a);
+ const polyData = { "name": n, "action": a || "feedback", "value": v || null };
+ //sendDrawing(n,v,a)
+ ws.send(JSON.stringify(polyData));
}
else {
if (n === undefined) { n = "map"; }
@@ -884,6 +890,10 @@ var feedback = function(n,v,a,c) {
rmenudata = v;
ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
}
+*/
+
+ const dataToSend = { "name": n, "action": a || "feedback", "value": v || null };
+ ws.send(JSON.stringify(dataToSend));
if (c === true) { map.closePopup(); }
}
@@ -1188,7 +1198,7 @@ var addOverlays = function(overlist) {
rightmenuMarker = L.popup({offset:[0,-12]}).setContent(drawcontextmenu.replace(/\${name}/g,name).replace(/\${.*?}/g,'') || "
");
}
rightmenuMarker.setLatLng(cent);
- setTimeout(function() {map.openPopup(rightmenuMarker)},25);
+ setTimeout(function() {map.openPopup(rightmenuMarker).replace(/\${name}/g,name)},25);
});
sendDrawing = function(n,v,a) {
@@ -1529,7 +1539,7 @@ function setMarker(data) {
rightcontext = rightcontext.replace(new RegExp("\\${"+item+"}","g"),allData[data["name"]].value[item]);
}
}
- rightcontext = rightcontext.replace(/\${.*?}/g,'')
+ rightcontext = rightcontext.replace(/\${.*?}/g,'').replace(/\${name}/g,data["name"])
if (rightcontext.length > 0) {
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent(""+data["name"]+"
"+rightcontext);
if (hiderightclick !== true) {
@@ -1698,7 +1708,7 @@ function setMarker(data) {
// if clickable then add popup
if (opt.clickable === true) {
var words = ""+data["name"]+"";
- if (data.popup) { words = words + "
" + data.popup; }
+ if (data.popup) { words = words + "
" + data.popup.replace(/\${name}/g,data["name"]); }
polygons[data["name"]].bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:true, minWidth:200});
}
// add a tooltip (if supplied)