';
+ setDialogMode(2, "Select a Node to place marker", 1, null, noMeshNodes, null);
+ } else {
+ var noNodesFound = '';
+ if (!meshExists()) {
+ noNodesFound = '
No nodes found. To create a mesh network and add devices, go to My Account page.
';
+ } else {
+ noNodesFound = '
No nodes found. To add devices, go to My Devices page.
';
+ }
+ setDialogMode(2, "Select a Node to place marker", 1, null, noNodesFound, null);
+ }
+ } else {
+ setDialogMode(2, "Select a Node to place marker", 18, placeNodeEx, x, coords);
+ }
+ }
+
+ function placeNodeEx(button, coords){
+ for (var i in xxmap.selectedNodes) {
+ var node = getNodeFromId(i);
+ if (node) {
+ var feature = markersSource.getFeatureById(i);
+ var v = ol.proj.transform(coords, 'EPSG:3857', 'EPSG:4326');
+ if (button == 2) {
+ if (feature) {
+ feature.getGeometry().setCoordinates(coords);
+ var activeInteraction = getActiveInteractions(feature);
+ if (activeInteraction) {
+ saveMarkerloc(feature);
+ } else { // If this feature is not modified, then send updated coords to server.
+ meshserver.Send({ action: 'changelocation', nodeid: node._id, value: v }); // Send them to server to save changes
+ }
+ } else {
+ meshserver.Send({ action: 'changelocation', nodeid: node._id, value: v }); // This Node is not yet added to maps.
+ }
+ }
+ else if (button == 1) {
+ if (feature) {
+ feature.getGeometry().setCoordinates(coords);
+ modifyMarkerloc(feature);
+ } else {
+ if (!node.iploc) {
+ addFeature(node, v[0], v[1]);
+ var newFeature = markersSource.getFeatureById(node._id);
+ modifyMarkerloc(newFeature);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Close place node dialog
+ function closePNDialog(id){
+ dialogclose(1);
+ switch (id) {
+ case 1:
+ Q("showselect")[0].selected = true;
+ onShowSelectChange();
+ go(1);
+ break;
+ case 2:
+ go(2);
+ break;
+ default:
+ gotoMesh(id);
+ }
+ }
+
+ // On input search change
+ function onPNSearchInputChange() {
+ QH('placenode', '');
+ var inputSearchData = Q('selectnode-search').value.toLowerCase();
+ var selectMeshElement=Q("select-mesh");
+ var selectedIndex = selectMeshElement.selectedIndex;
+ var selectedMeshValue=selectMeshElement[selectedIndex].value;
+ updatePlaceNodeTable(inputSearchData, selectedIndex, selectedMeshValue, 1);
+ }
+
+ function updatePlaceNodeTable(inputSearch, selectedIndex, selectedMeshValue, innerHtmlflag) {
+ var x = '
';
+ var count = 0;
+ for (var i in nodes) {
+ if (nodes[i].mtype == 2) {
+ if ((nodes[i].meshid == selectedMeshValue || selectedIndex == 0) && ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.toLowerCase().indexOf(inputSearch) >= 0))) {
+ count++;
+ x+='
';
+ x+='
';
+ x+='
'+ nodes[i].name + '
';
+ x+='
';
+ }
+ }
+ }
+ x+='
';
+ if (innerHtmlflag) {
+ if (count == 0) { QH('placenode', '
No Nodes found with this Search Criteria.
'); } else { QH('placenode', x);}
+ }else {
+ if (count == 0) { return 0; }
+ else { return x; }
+ }
+ }
+
+ function selectNodetoplace(id){
+ var imgeElement = Q(id + '-img');
+ if (xxmap.selectedNodes[id]) {
+ imgeElement.classList.remove('fa-check-square-o');
+ imgeElement.classList.add('fa-square');
+ delete xxmap.selectedNodes[id];
+ CheckedNodesforPN();
+ } else {
+ imgeElement.classList.remove('fa-square');
+ imgeElement.classList.add('fa-check-square-o');
+ xxmap.selectedNodes[id] = { color: Q(id+'-rowid').style.backgroundColor};
+ QE('idx_dlgPlaceandSave', true);
+ QE('idx_dlgPlaceButton', true);
+ }
+ }
+
+ function CheckedNodesforPN() {
+ var c = 0;
+ for (var i in xxmap.selectedNodes) { if (xxmap.selectedNodes[i]) { c++; } }
+ if (c == 0) {
+ QE('idx_dlgPlaceandSave', false);
+ QE('idx_dlgPlaceButton', false);
+ }
+ }
+
+ // Set selected node to null
+ function clearSelectedNode() {
+ xxmap.selectedNodes = {};
+ QE('idx_dlgPlaceandSave', false);
+ QE('idx_dlgPlaceButton', false);
+ }
+
+ // Change radio button on mouseover and out for 'select a node to place dialog'
+ function changeRadioImg(name) {
+ var index = name.indexOf("mouseout");
+ var element = name.split('!#!');
+ if (!xxmap.selectedNodes[element[0]]) {
+ var imgeElement= Q(element[0]+'-img');
+ if (index > -1) {
+ imgeElement.classList.remove('fa-square');
+ imgeElement.classList.add('fa-square-o');
+ } else {
+ imgeElement.classList.remove('fa-square-o');
+ imgeElement.classList.add('fa-square');
+ }
+ }
+ }
+
+ // Add option for available meshes in mesh Dropdown
+ function addMeshOptions(addMeshid, meshName) {
+ /*
+ var meshOptions = Q('select-mesh');
+ if (addMeshid && meshName) {
+ var option = document.createElement('option');
+ option.value =addMeshid;
+ option.text = meshName;
+ meshOptions.add(option); // Add specific option
+ }
+ else {
+ for (var i in meshes) { // Add all options
+ var option = document.createElement('option');
+ option.value = i;
+ option.text = meshes[i].name;
+ meshOptions.add(option);
+ }
+ }
+ */
+ }
+
+ // Remove/Modify options in Mesh dropdown (if modMeshname is defined then Modify else Remove)
+ function meshOptionRmvMod(delMeshid, modMeshname){
+ /*
+ var meshOptions = Q('select-mesh');
+ if (delMeshid) {
+ var index=-1;
+ for (var i = 1; i < meshOptions.options.length; i++) {
+ if (meshOptions[i].value === delMeshid) { index=i; }
+ }
+ if (index > 0) {
+ if (modMeshname) {
+ meshOptions[index].innerHTML=modMeshname; // If Mesh name is Modified
+ }
+ else { meshOptions.remove(index); }
+ }
+ }
+ */
+ }
+
+ //Check if there is any mesh created
+ function meshExists() {
+ for (var i in meshes) { if (meshes[i]) { return true; } }
+ return false;
+ }
+
+ // Reset Mesh dropdown option to 'All' when a current view mesh is deleted.
+ function setMeshView(emeshid) {
+ var selectMeshElement=Q("select-mesh");
+ var selectedIndex = selectMeshElement.selectedIndex;
+ if (selectMeshElement[selectedIndex].value == emeshid) { selectMeshElement[0].selected = true; onSelectMeshChange(); }
+ }
+
+ // Clear all mesh options except 'All'
+ function clearMeshOptions() {
+ /*
+ var meshOptions=Q('select-mesh');
+ for(var i = meshOptions.options.length - 1 ; i > 0 ; i--) { meshOptions.remove(i); }
+ */
+ }
+
+ // Make a http get call- Replace this with AJAX get if jquery is used
+ function getSearchLocation() {
+ try {
+ var searchdata = Q('mapSearchLocation').value.trim();
+ if (searchdata.length > 0) {
+ var xmlhttp = new XMLHttpRequest(); // Compatible with Chrome, Opera, Safari, IE7+, Firefox.
+ xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { formatSearchData(xmlhttp.responseText); } }
+ xmlhttp.open("GET", 'https://nominatim.openstreetmap.org/search?q=' + searchdata + '&format=json', true); // Get request
+ xmlhttp.send();
+ }
+ } catch (e) {}
+ }
+
+ // Format data recieved from nominatim API and display it on content window
+ function formatSearchData(data) {
+ try {
+ QH('xmapSearchResults','');
+ var dataInfo = JSON.parse(data), count = 0, x = '
';
+ for (var i = 0; i < dataInfo.length; i++) {
+ if (dataInfo[i].display_name && dataInfo[i].boundingbox[0] && dataInfo[i].boundingbox[1] && dataInfo[i].boundingbox[2] && dataInfo[i].boundingbox[3]) {
+ count++;
+ var color = (i % 2 == 0)?'F5F5F5':'EBEBEB';
+ x += '
';
+ if (count == 1) {
+ // If only one result is returned then zoom to that location
+ var extent = [ parseFloat(dataInfo[0].boundingbox[2]), parseFloat(dataInfo[0].boundingbox[0]), parseFloat(dataInfo[0].boundingbox[3]), parseFloat(dataInfo[0].boundingbox[1]) ];
+ zoomToExtent(extent);
+ } else {
+ if (count == 0) { x = '
No location found.
'; }
+ QV('xmapSearchResultsDlg', true);
+ }
+ QH('xmapSearchResults', x);
+ }
+ catch (e) {}
+ }
+
+ // Zoom into the bounding box
+ function mapGotoSelectedLocation(obj) {
+ var objchildren = obj.children;
+ var boundingBox = objchildren[1].innerHTML.split('!#!');
+ var extent = [parseFloat(boundingBox[2]), parseFloat(boundingBox[0]), parseFloat(boundingBox[3]), parseFloat(boundingBox[1])];
+ //Q('search-location').value = objchildren[0].innerHTML;
+ zoomToExtent(extent);
+ mapCloseSearchWindow();
+ }
+
+ // Close the search window
+ function mapCloseSearchWindow() {
+ QH('xmapSearchResults', '');
+ QV('xmapSearchResultsDlg', false);
+ }
+
+ // Zoom to specific cordinates
+ function zoomToLocation(coordinates, zoomVal) {
+ var view = xxmap.map.getView();
+ view.setCenter(coordinates);
+ view.setZoom(zoomVal);
+ }
+
+ function zoomToFitExtent() {
+ var features = xxmap.markersSource.getFeatures();
+ if (features.length > 0) {
+ var extent = xxmap.markersSource.getExtent();
+ xxmap.map.getView().fit(extent, xxmap.map.getSize());
+ }
+ }
+
+ function zoomToExtent(extent){
+ var boundingExtent = ol.proj.transformExtent(extent, ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857'));
+ xxmap.map.getView().fit(boundingExtent, xxmap.map.getSize());
+ }
+
+
//
// MY DEVICE
//
@@ -1943,18 +2633,7 @@
// Setup the device mark layer
var deviceMark = new ol.Feature({ geometry: new ol.geom.Point(ol.proj.fromLonLat([lng, lat])) });
- //deviceMark.setStyle(new ol.style.Style({ image: new ol.style.Icon(({ color: [113, 140, 0], src: 'images/dot.png' })) }));
- deviceMark.setStyle(new ol.style.Style({
-
- text: new ol.style.Text({
- //font: '12px helvetica,sans-serif',
- text: currentNode.name,
- textAlign: 'right',
- offsetX: -10,
- fill: new ol.style.Fill({ color: '#000' }),
- stroke: new ol.style.Stroke({ color: '#fff', width: 2 })
- }),
- image: new ol.style.Icon(({ color: [113, 140, 0], src: 'images/dot.png' })) }));
+ deviceMark.setStyle(markerStyle(currentNode));
var vectorSource = new ol.source.Vector({ features: [deviceMark] });
var vectorLayer = new ol.layer.Vector({ source: vectorSource });
@@ -2135,7 +2814,6 @@
}
function applyDesktopSettings() {
- console.log(desktopsettings);
d7desktopmode.value = desktopsettings.encoding;
d7showfocus.checked = desktopsettings.showfocus;
d7showcursor.checked = desktopsettings.showmouse;