diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index 162d39f..6edbb61 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -266,11 +266,11 @@ var errRing; function onLocationFound(e) { if (followState === true) { map.panTo(e.latlng); } if (followMode.icon) { - var self = {name:followMode.name || "self", lat:e.latlng.lat, lon:e.latlng.lng, hdg:e.heading, speed:(e.speed*3.6 || undefined), layer:followMode.layer, icon:followMode.icon, iconColor:followMode.iconColor || "#910000" }; + var self = {name:followMode.name || "self", lat:e.latlng.lat, lon:e.latlng.lng, hdg:e.heading, speed:(e.speed*3.6 ?? undefined), layer:followMode.layer, icon:followMode.icon, iconColor:followMode.iconColor ?? "#910000" }; setMarker(self); } if (followMode.accuracy) { - errRing = L.circle(e.latlng, e.accuracy, {color:followMode.color || "cyan", weight:3, opacity:0.6, fill:false, clickable:false}); + errRing = L.circle(e.latlng, e.accuracy, {color:followMode.color ?? "cyan", weight:3, opacity:0.6, fill:false, clickable:false}); errRing.addTo(map); // if (e.hasOwnProperty("heading")) { // var lengthAsDegrees = e.speed * 60 / 110540; @@ -280,7 +280,7 @@ function onLocationFound(e) { // L.polygon([ e.latlng, lla ], {color:"cyan", weight:3, opacity:0.5, clickable:false}).addTo(map); // } } - ws.send(JSON.stringify({action:"point", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5), point:"self", hdg:e.heading, speed:(e.speed*3.6 || undefined)})); + ws.send(JSON.stringify({action:"point", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5), point:"self", hdg:e.heading, speed:(e.speed*3.6 ?? undefined)})); } function onLocationError(e) { console.log(e.message); } @@ -702,7 +702,7 @@ var addThing = function() { var bits = thing.split(","); var icon = (bits[1] || "circle").trim(); var lay = (bits[2] || "_drawing").trim(); - var colo = (bits[3] || "#910000").trim(); + var colo = (bits[3] ?? "#910000").trim(); var hdg = parseFloat(bits[4] || 0); var drag = true; var regi = /^[S,G,E,I,O][A-Z]{3}.*/i; // if it looks like a SIDC code @@ -1325,7 +1325,7 @@ var rangerings = function(latlng, options) { radius: options.ranges[i], fill: false, color: options.color, - weight: options.weight || 1 + weight: options.weight ?? 1 }).setDirection(options.pan, options.fov).addTo(rings); } return rings; @@ -1376,8 +1376,8 @@ function setMarker(data) { var ll; var lli = null; var opt = {}; - opt.color = data.color || data.lineColor || "#910000"; - opt.fillColor = data.fillColor || "#910000"; + opt.color = data.color ?? data.lineColor ?? "#910000"; + opt.fillColor = data.fillColor ?? "#910000"; opt.stroke = (data.hasOwnProperty("stroke")) ? data.stroke : true; opt.weight = data.weight; opt.opacity = data.opacity; @@ -1407,7 +1407,7 @@ function setMarker(data) { if (markers.hasOwnProperty(data.name) && markers[data.name].hasOwnProperty("lay")) { lll = markers[data.name].lay; } - var lay = data.layer || lll; + var lay = data.layer ?? lll; if (!data.hasOwnProperty("action") || data.action.indexOf("layer") === -1) { if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist if (clusterAt > 0) { @@ -1564,11 +1564,11 @@ function setMarker(data) { if (data.draggable === true) { drag = true; } if (data.hasOwnProperty("icon")) { - var dir = parseFloat(data.hdg || data.heading || data.bearing || "0"); + var dir = parseFloat(data.hdg ?? data.heading ?? data.bearing ?? "0"); if (data.icon === "ship") { marker = L.boatMarker(ll, { title: data.name, - color: (data.iconColor || "blue") + color: (data.iconColor ?? "blue") }); marker.setHeading(dir); q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"'; @@ -1592,7 +1592,7 @@ function setMarker(data) { marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag}); } else if (data.icon === "smallplane") { - data.iconColor = data.iconColor || "black"; + data.iconColor = data.iconColor ?? "black"; icon = ''; var svgplane = "data:image/svg+xml;base64," + btoa(icon); @@ -1607,7 +1607,7 @@ function setMarker(data) { dir = dir - 90; var sc = 1; if (dir < -90 || dir >= 90) { sc = -1; } - data.iconColor = data.iconColor || "#910000"; + data.iconColor = data.iconColor ?? "#910000"; var p = "m595.5 97.332-30.898-68.199c-11.141-24.223-35.344-39.762-62.004-39.801h-443.3c-32.738 0.035157-59.266 26.562-59.301 59.305v148.2c0 17.949 14.551 32.5 32.5 32.5h48.5c4.7344 23.309 25.219 40.051 49 40.051s44.266-16.742 49-40.051h242c4.7344 23.309 25.219 40.051 49 40.051s44.266-16.742 49-40.051h53.203c12.348-0.003906 23.219-8.1484 26.699-20 0.72266-2.5391 1.0898-5.1602 1.0977-7.7969v-83.5c-0.003906-7.1445-1.5391-14.203-4.5-20.703zm-545.5 12c-5.5234 0-10-4.4766-10-10v-80c0-5.5195 4.4766-10 10-10h70c5.5234 0 10 4.4805 10 10v80c0 5.5234-4.4766 10-10 10zm80 140c-16.566 0-30-13.43-30-30 0-16.566 13.434-30 30-30s30 13.434 30 30c-0.046875 16.551-13.453 29.953-30 30zm110-150c0 5.5234-4.4766 10-10 10h-70c-5.5234 0-10-4.4766-10-10v-80c0-5.5195 4.4766-10 10-10h70c5.5234 0 10 4.4805 10 10zm110 0c0 5.5234-4.4766 10-10 10h-70c-5.5234 0-10-4.4766-10-10v-80c0-5.5195 4.4766-10 10-10h70c5.5234 0 10 4.4805 10 10zm30 10c-5.5234 0-10-4.4766-10-10v-80c0-5.5195 4.4766-10 10-10h70c5.5234 0 10 4.4805 10 10v80c0 5.5234-4.4766 10-10 10zm90 140c-16.566 0-30-13.43-30-30 0-16.566 13.434-30 30-30s30 13.434 30 30c-0.046875 16.551-13.453 29.953-30 30zm19.199-140c-5.1836-0.46094-9.168-4.793-9.1992-10v-80.086c0-5.4727 4.4375-9.9141 9.9141-9.9141h12.684c18.824 0.050781 35.914 11.012 43.805 28.102l30.898 68.199c1.6133 3.5547 2.5 7.3984 2.6016 11.297z"; icon = ''; @@ -1620,7 +1620,7 @@ function setMarker(data) { marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag}); } else if (data.icon === "helicopter") { - data.iconColor = data.iconColor || "black"; + data.iconColor = data.iconColor ?? "black"; if (data.hasOwnProperty("squawk")) { if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) { data.iconColor = "red"; @@ -1772,7 +1772,7 @@ function setMarker(data) { } else if (data.icon.match(/^:.*:$/g)) { var em = emojify(data.icon); - var col = data.iconColor || "#910000"; + var col = data.iconColor ?? "#910000"; myMarker = L.divIcon({ className:"emicon", html: '