1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-26 01:35:23 +03:00

Initial build

This commit is contained in:
breadoven 2021-09-23 10:35:35 +01:00
parent df1ba5a324
commit c6b54fa98c
3 changed files with 173 additions and 173 deletions

View file

@ -302,7 +302,7 @@
.tab-mission-control .safehomesTable { .tab-mission-control .safehomesTable {
width: 100%; width: 100%;
text-align: center; text-align: center;
font-size: 8px; font-size: 12px;
} }
.tab-mission-control .safehomesTable input[type="text"] { .tab-mission-control .safehomesTable input[type="text"] {
@ -311,7 +311,7 @@
} }
.tab-mission-control .safehomesTable input[type="number"] { .tab-mission-control .safehomesTable input[type="number"] {
font-size: 8px; font-size: 10px;
width: 100%; width: 100%;
-moz-appearance: textfield; -moz-appearance: textfield;
} }
@ -498,8 +498,8 @@
width:20px; width:20px;
} }
.tab-mission-control .textLegend{ .tab-mission-control .textLegend{
margin:2px; margin:2px;
} }
.tab-mission-control .valueLegend{ .tab-mission-control .valueLegend{
float:right; float:right;

View file

@ -13,7 +13,7 @@
</div> </div>
</div> </div>
<div class="spacer" id="ActionContent"> <div class="spacer" id="ActionContent">
<div class="btn save_btn"> <div class="btn save_btn">
<a id="loadFileMissionButton" class="btnicon ic_loadFromFile" href="#" title="Load Mission File"></a> <a id="loadFileMissionButton" class="btnicon ic_loadFromFile" href="#" title="Load Mission File"></a>
<a id="saveFileMissionButton" class="btnicon ic_save2File" href="#" title="Save Mission File"></a> <a id="saveFileMissionButton" class="btnicon ic_save2File" href="#" title="Save Mission File"></a>
@ -86,7 +86,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="missionPlanerHome" class="gui_box grey" style="display: none"> <div id="missionPlanerHome" class="gui_box grey" style="display: none">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">
<div class="spacer_box_title i18n-replaced" data-i18n="missionHomeHead">Take Off home</div> <div class="spacer_box_title i18n-replaced" data-i18n="missionHomeHead">Take Off home</div>
@ -102,20 +102,20 @@
<table class="safehomesTable"> <table class="safehomesTable">
<thead> <thead>
<tr> <tr>
<th style="width: 50px" data-i18n="SafehomeSelected"></th> <th style="width: 40px" data-i18n="SafehomeSelected"></th>
<th style="width: 120px" data-i18n="SafehomeLon"></th> <th style="width: 140px" data-i18n="SafehomeLat"></th>
<th style="width: 120px" data-i18n="SafehomeLat"></th> <th style="width: 140px" data-i18n="SafehomeLon"></th>
<th style="width: 120px" data-i18n="SafehomeAlt"></th> <th style="width: 100px" data-i18n="SafehomeAlt"></th>
</tr> </tr>
</thead> </thead>
<tbody id="homeTableBody"> <tbody id="homeTableBody">
<tr> <tr>
<td><div id="viewHomePoint" class="btnTable btnTableIcon"> <td><div id="viewHomePoint" class="btnTable btnTableIcon">
<a class="ic_center" data-role="home-center" href="#" title="move to center view"></a> <a class="ic_center" data-role="home-center" href="#" title="move to center view"></a>
</div> </div>
</td> </td>
<td><input type="number" class="home-lon" /></td>
<td><input type="number" class="home-lat" /></td> <td><input type="number" class="home-lat" /></td>
<td><input type="number" class="home-lon" /></td>
<td><span id="elevationValueAtHome">NA</span></td> <td><span id="elevationValueAtHome">NA</span></td>
</tr> </tr>
</tbody> </tbody>
@ -123,7 +123,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="missionPlanerSafehome" class="gui_box grey" style="display: none"> <div id="missionPlanerSafehome" class="gui_box grey" style="display: none">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">
<div class="spacer_box_title i18n-replaced" data-i18n="missionSafehomeHead">Safe Home manager</div> <div class="spacer_box_title i18n-replaced" data-i18n="missionSafehomeHead">Safe Home manager</div>
@ -141,11 +141,11 @@
<table class="safehomesTable"> <table class="safehomesTable">
<thead> <thead>
<tr> <tr>
<th style="width: 80px" data-i18n="SafehomeSelected"></th> <th style="width: 40px" data-i18n="SafehomeSelected"></th>
<th style="width: 50px" data-i18n="SafehomeId"></th> <th style="width: 40px" data-i18n="SafehomeId"></th>
<th style="width: 80px" data-i18n="SafehomeEnabled"></th> <th style="width: 60px" data-i18n="SafehomeEnabled"></th>
<th style="width: 120px" data-i18n="SafehomeLon"></th> <th style="width: 140px" data-i18n="SafehomeLat"></th>
<th style="width: 120px" data-i18n="SafehomeLat"></th> <th style="width: 140px" data-i18n="SafehomeLon"></th>
</tr> </tr>
</thead> </thead>
<tbody id="safehomesTableBody"> <tbody id="safehomesTableBody">
@ -244,7 +244,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- <div class="point-radio" id="pointOptionclass" style="display: none"> <!-- <div class="point-radio" id="pointOptionclass" style="display: none">
<div class="radio-line"> <div class="radio-line">
<input type="radio" id="Options_None" name="Options" value="None" checked> <input type="radio" id="Options_None" name="Options" value="None" checked>
@ -256,7 +256,7 @@
<input type="checkbox" id="Options_LandRTH"> <input type="checkbox" id="Options_LandRTH">
<label for="Options_LandRTH">Land after RTH</label><br> <label for="Options_LandRTH">Land after RTH</label><br>
</div> </div>
<div class="radio-line"> <div class="radio-line">
<input type="radio" id="Options_JUMP" name="Options" value="JUMP"> <input type="radio" id="Options_JUMP" name="Options" value="JUMP">
<label class="radio-options" for="Options_JUMP">JUMP</label> <label class="radio-options" for="Options_JUMP">JUMP</label>
<label for="Options_TargetJUMP">Target WP: </label> <label for="Options_TargetJUMP">Target WP: </label>
@ -264,14 +264,14 @@
<label for="Options_NumberJUMP">Repeat: </label> <label for="Options_NumberJUMP">Repeat: </label>
<input id="Options_NumberJUMP" type="text" value="0" required><br> <input id="Options_NumberJUMP" type="text" value="0" required><br>
</div> </div>
<div class="radio-line"> <div class="radio-line">
<input type="radio" id="Options_HEAD" name="Options" value="SET_HEAD"> <input type="radio" id="Options_HEAD" name="Options" value="SET_HEAD">
<label class="radio-options" for="Options_HEAD">HEAD</label> <label class="radio-options" for="Options_HEAD">HEAD</label>
<label for="Options_HeadingHead">Heading: </label> <label for="Options_HeadingHead">Heading: </label>
<input id="Options_HeadingHead" type="text" value="-1" required><br> <input id="Options_HeadingHead" type="text" value="-1" required><br>
</div> </div>
</div> --> </div> -->
</div> </div>
</div> </div>
</div> </div>

View file

@ -108,7 +108,7 @@ TABS.mission_control.initialize = function (callback) {
$('#saveEepromMissionButton').hide(); $('#saveEepromMissionButton').hide();
isOffline = true; isOffline = true;
} }
$safehomesTable = $('.safehomesTable'); $safehomesTable = $('.safehomesTable');
$safehomesTableBody = $('#safehomesTableBody'); $safehomesTableBody = $('#safehomesTableBody');
$waypointOptionsTable = $('.waypointOptionsTable'); $waypointOptionsTable = $('.waypointOptionsTable');
@ -140,7 +140,7 @@ TABS.mission_control.initialize = function (callback) {
function get_attitude_data() { function get_attitude_data() {
MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, update_gpsTrack); MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, update_gpsTrack);
} }
function update_gpsTrack() { function update_gpsTrack() {
let lat = GPS_DATA.lat / 10000000; let lat = GPS_DATA.lat / 10000000;
@ -338,29 +338,29 @@ TABS.mission_control.initialize = function (callback) {
/////////////////////////////////////////////// ///////////////////////////////////////////////
// //
// define & init parameters // define & init parameters
// //
/////////////////////////////////////////////// ///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init parameters for Map Layer // define & init parameters for Map Layer
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
var markers = []; // Layer for Waypoints var markers = []; // Layer for Waypoints
var lines = []; // Layer for lines between waypoints var lines = []; // Layer for lines between waypoints
var safehomeMarkers =[]; // layer for Safehome points var safehomeMarkers =[]; // layer for Safehome points
var map; var map;
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init parameters for Selected Marker // define & init parameters for Selected Marker
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
var selectedMarker = null; var selectedMarker = null;
var selectedFeature = null; var selectedFeature = null;
var tempMarker = null; var tempMarker = null;
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init parameters for default Settings // define & init parameters for default Settings
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
var vMaxDistSH = 0; var vMaxDistSH = 0;
var settings = {}; var settings = {};
if (CONFIGURATOR.connectionValid) { if (CONFIGURATOR.connectionValid) {
@ -381,23 +381,23 @@ TABS.mission_control.initialize = function (callback) {
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init Waypoints parameters // define & init Waypoints parameters
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
var mission = new WaypointCollection(); var mission = new WaypointCollection();
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init home parameters // define & init home parameters
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
var HOME = new Waypoint(0,0,0,0); var HOME = new Waypoint(0,0,0,0);
var homeMarkers =[]; // layer for home point var homeMarkers =[]; // layer for home point
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// define & init Safehome parameters // define & init Safehome parameters
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
//var SAFEHOMES = new SafehomeCollection(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG //var SAFEHOMES = new SafehomeCollection(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
//SAFEHOMES.inflate(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG //SAFEHOMES.inflate(); // TO COMMENT FOR RELEASE : DECOMMENT FOR DEBUG
//var safehomeRangeRadius = 200; //meters //var safehomeRangeRadius = 200; //meters
//var safehomeSafeRadius = 50; //meters //var safehomeSafeRadius = 50; //meters
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Reinit Jquery Form // Reinit Jquery Form
@ -413,11 +413,11 @@ TABS.mission_control.initialize = function (callback) {
$('#missionDistance').text(0); $('#missionDistance').text(0);
$('#MPeditPoint').fadeOut(300); $('#MPeditPoint').fadeOut(300);
} }
function clearFilename() { function clearFilename() {
$('#missionFilename').text(''); $('#missionFilename').text('');
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Manage Settings // Manage Settings
@ -441,21 +441,21 @@ TABS.mission_control.initialize = function (callback) {
$('#MPdefaultPointSpeed').val(String(settings.speed)); $('#MPdefaultPointSpeed').val(String(settings.speed));
$('#MPdefaultSafeRangeSH').val(String(settings.safeRadiusSH)); $('#MPdefaultSafeRangeSH').val(String(settings.safeRadiusSH));
} }
function closeSettingsPanel() { function closeSettingsPanel() {
$('#missionPlanerSettings').hide(); $('#missionPlanerSettings').hide();
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Manage Safehome // Manage Safehome
// //
///////////////////////////////////////////// /////////////////////////////////////////////
function closeSafehomePanel() { function closeSafehomePanel() {
$('#missionPlanerSafehome').hide(); $('#missionPlanerSafehome').hide();
cleanSafehomeLayers(); cleanSafehomeLayers();
} }
function renderSafehomesTable() { function renderSafehomesTable() {
/* /*
* Process safehome table UI * Process safehome table UI
@ -474,16 +474,16 @@ TABS.mission_control.initialize = function (callback) {
</td> \ </td> \
<td><span class="safehome-number"/></td>\ <td><span class="safehome-number"/></td>\
<td class="safehome-enabled"><input type="checkbox" class="togglesmall safehome-enabled-value"/></td> \ <td class="safehome-enabled"><input type="checkbox" class="togglesmall safehome-enabled-value"/></td> \
<td><input type="number" class="safehome-lon" /></td>\
<td><input type="number" class="safehome-lat" /></td>\ <td><input type="number" class="safehome-lat" /></td>\
<td><input type="number" class="safehome-lon" /></td>\
</tr>\ </tr>\
'); ');
const $row = $safehomesTableBody.find('tr:last'); const $row = $safehomesTableBody.find('tr:last');
$row.find(".safehome-number").text(safehome.getNumber()+1); $row.find(".safehome-number").text(safehome.getNumber()+1);
$row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).change(function () { $row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).change(function () {
safehome.setEnabled((($(this).prop('checked')) ? 1 : 0)); safehome.setEnabled((($(this).prop('checked')) ? 1 : 0));
SAFEHOMES.updateSafehome(safehome); SAFEHOMES.updateSafehome(safehome);
@ -497,7 +497,7 @@ TABS.mission_control.initialize = function (callback) {
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
}); });
$row.find(".safehome-lat").val(safehome.getLatMap()).change(function () { $row.find(".safehome-lat").val(safehome.getLatMap()).change(function () {
safehome.setLat(Math.round(Number($(this).val()) * 10000000)); safehome.setLat(Math.round(Number($(this).val()) * 10000000));
SAFEHOMES.updateSafehome(safehome); SAFEHOMES.updateSafehome(safehome);
@ -511,8 +511,8 @@ TABS.mission_control.initialize = function (callback) {
GUI.switchery(); GUI.switchery();
localize(); localize();
} }
function renderSafehomesOnMap() { function renderSafehomesOnMap() {
/* /*
* Process safehome on Map * Process safehome on Map
@ -521,14 +521,14 @@ TABS.mission_control.initialize = function (callback) {
map.addLayer(addSafeHomeMarker(safehome)); map.addLayer(addSafeHomeMarker(safehome));
}); });
} }
function cleanSafehomeLayers() { function cleanSafehomeLayers() {
for (var i in safehomeMarkers) { for (var i in safehomeMarkers) {
map.removeLayer(safehomeMarkers[i]); map.removeLayer(safehomeMarkers[i]);
} }
safehomeMarkers = []; safehomeMarkers = [];
} }
function getSafehomeIcon(safehome) { function getSafehomeIcon(safehome) {
/* /*
* Process Safehome Icon * Process Safehome Icon
@ -554,7 +554,7 @@ TABS.mission_control.initialize = function (callback) {
})) }))
}); });
} }
function addSafeHomeMarker(safehome) { function addSafeHomeMarker(safehome) {
/* /*
* add safehome on Map * add safehome on Map
@ -566,7 +566,7 @@ TABS.mission_control.initialize = function (callback) {
}); });
//iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed())); //iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
let circleStyle = new ol.style.Style({ let circleStyle = new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: 'rgba(144, 12, 63, 0.5)', color: 'rgba(144, 12, 63, 0.5)',
@ -577,7 +577,7 @@ TABS.mission_control.initialize = function (callback) {
// color: 'rgba(251, 225, 155, 0.1)' // color: 'rgba(251, 225, 155, 0.1)'
// }) // })
}); });
let circleSafeStyle = new ol.style.Style({ let circleSafeStyle = new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: 'rgba(136, 204, 62, 1)', color: 'rgba(136, 204, 62, 1)',
@ -588,7 +588,7 @@ TABS.mission_control.initialize = function (callback) {
color: 'rgba(136, 204, 62, 0.1)' color: 'rgba(136, 204, 62, 0.1)'
}) */ }) */
}); });
var vectorLayer = new ol.layer.Vector({ var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
features: [iconFeature] features: [iconFeature]
@ -608,9 +608,9 @@ TABS.mission_control.initialize = function (callback) {
vectorLayer.kind = "safehome"; vectorLayer.kind = "safehome";
vectorLayer.number = safehome.getNumber(); vectorLayer.number = safehome.getNumber();
vectorLayer.selection = false; vectorLayer.selection = false;
safehomeMarkers.push(vectorLayer); safehomeMarkers.push(vectorLayer);
return vectorLayer; return vectorLayer;
} }
@ -621,7 +621,7 @@ TABS.mission_control.initialize = function (callback) {
let radiusProjected = (radius / ol.proj.METERS_PER_UNIT.m) * resolutionRate; let radiusProjected = (radius / ol.proj.METERS_PER_UNIT.m) * resolutionRate;
return radiusProjected; return radiusProjected;
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Manage Take Off Home // Manage Take Off Home
@ -632,47 +632,47 @@ TABS.mission_control.initialize = function (callback) {
$('#missionPlanerElevation').hide(); $('#missionPlanerElevation').hide();
cleanHomeLayers(); cleanHomeLayers();
} }
function cleanHomeLayers() { function cleanHomeLayers() {
for (var i in homeMarkers) { for (var i in homeMarkers) {
map.removeLayer(homeMarkers[i]); map.removeLayer(homeMarkers[i]);
} }
homeMarkers = []; homeMarkers = [];
} }
function renderHomeTable() { function renderHomeTable() {
/* /*
* Process home table UI * Process home table UI
*/ */
$(".home-lat").val(HOME.getLatMap()).change(function () {
HOME.setLat(Math.round(Number($(this).val()) * 10000000));
cleanHomeLayers();
renderHomeOnMap();
});
$(".home-lon").val(HOME.getLonMap()).change(function () { $(".home-lon").val(HOME.getLonMap()).change(function () {
HOME.setLon(Math.round(Number($(this).val()) * 10000000)); HOME.setLon(Math.round(Number($(this).val()) * 10000000));
cleanHomeLayers(); cleanHomeLayers();
renderHomeOnMap(); renderHomeOnMap();
}); });
$(".home-lat").val(HOME.getLatMap()).change(function () {
HOME.setLat(Math.round(Number($(this).val()) * 10000000));
cleanHomeLayers();
renderHomeOnMap();
});
(async () => { (async () => {
const elevationAtHome = await HOME.getElevation(globalSettings); const elevationAtHome = await HOME.getElevation(globalSettings);
$('#elevationValueAtHome').text(elevationAtHome+' m'); $('#elevationValueAtHome').text(elevationAtHome+' m');
HOME.setAlt(elevationAtHome); HOME.setAlt(elevationAtHome);
})() })()
} }
function renderHomeOnMap() { function renderHomeOnMap() {
/* /*
* Process home on Map * Process home on Map
*/ */
map.addLayer(addHomeMarker(HOME)); map.addLayer(addHomeMarker(HOME));
} }
function addHomeMarker(home) { function addHomeMarker(home) {
/* /*
* add safehome on Map * add safehome on Map
@ -684,7 +684,7 @@ TABS.mission_control.initialize = function (callback) {
}); });
//iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed())); //iconFeature.setStyle(getSafehomeIcon(safehome, safehome.isUsed()));
var vectorLayer = new ol.layer.Vector({ var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
features: [iconFeature] features: [iconFeature]
@ -698,12 +698,12 @@ TABS.mission_control.initialize = function (callback) {
vectorLayer.kind = "home"; vectorLayer.kind = "home";
vectorLayer.number = home.getNumber(); vectorLayer.number = home.getNumber();
vectorLayer.selection = false; vectorLayer.selection = false;
homeMarkers.push(vectorLayer); homeMarkers.push(vectorLayer);
return vectorLayer; return vectorLayer;
} }
function getHomeIcon(home) { function getHomeIcon(home) {
/* /*
* Process Safehome Icon * Process Safehome Icon
@ -722,23 +722,23 @@ TABS.mission_control.initialize = function (callback) {
function updateHome() { function updateHome() {
renderHomeTable(); renderHomeTable();
cleanHomeLayers(); cleanHomeLayers();
renderHomeOnMap(); renderHomeOnMap();
plotElevation(); plotElevation();
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Manage Waypoint // Manage Waypoint
// //
///////////////////////////////////////////// /////////////////////////////////////////////
function removeAllWaypoints() { function removeAllWaypoints() {
mission.reinit(); mission.reinit();
cleanLayers(); cleanLayers();
clearEditForm(); clearEditForm();
updateTotalInfo(); updateTotalInfo();
clearFilename(); clearFilename();
} }
function addWaypointMarker(waypoint, isEdit=false) { function addWaypointMarker(waypoint, isEdit=false) {
let coord = ol.proj.fromLonLat([waypoint.getLonMap(), waypoint.getLatMap()]); let coord = ol.proj.fromLonLat([waypoint.getLonMap(), waypoint.getLatMap()]);
@ -756,7 +756,7 @@ TABS.mission_control.initialize = function (callback) {
var vectorLayer = new ol.layer.Vector({ var vectorLayer = new ol.layer.Vector({
source: vectorSource source: vectorSource
}); });
vectorLayer.kind = "waypoint"; vectorLayer.kind = "waypoint";
vectorLayer.number = waypoint.getNumber(); vectorLayer.number = waypoint.getNumber();
vectorLayer.layerNumber = waypoint.getLayerNumber(); vectorLayer.layerNumber = waypoint.getLayerNumber();
@ -774,7 +774,7 @@ TABS.mission_control.initialize = function (callback) {
5: 'POI', 5: 'POI',
8: 'LDG' 8: 'LDG'
}; };
return new ol.style.Style({ return new ol.style.Style({
image: new ol.style.Icon(({ image: new ol.style.Icon(({
anchor: [0.5, 1], anchor: [0.5, 1],
@ -796,8 +796,8 @@ TABS.mission_control.initialize = function (callback) {
})) }))
}); });
} }
function repaintLine4Waypoints(mission) { function repaintLine4Waypoints(mission) {
let oldPos, let oldPos,
oldAction, oldAction,
@ -809,7 +809,7 @@ TABS.mission_control.initialize = function (callback) {
cleanLines(); cleanLines();
mission.get().forEach(function (element) { mission.get().forEach(function (element) {
if (!element.isAttached()) { if (!element.isAttached()) {
let coord = ol.proj.fromLonLat([element.getLonMap(), element.getLatMap()]); let coord = ol.proj.fromLonLat([element.getLonMap(), element.getLatMap()]);
if (element.getAction() == 5) { if (element.getAction() == 5) {
// If action is Set_POI, increment counter of POI // If action is Set_POI, increment counter of POI
poiList.push(element.getNumber()); poiList.push(element.getNumber());
@ -817,7 +817,7 @@ TABS.mission_control.initialize = function (callback) {
activateHead = false; activateHead = false;
} }
else { else {
// If classic WPs, draw standard line in-between // If classic WPs, draw standard line in-between
if (typeof oldPos !== 'undefined' && activatePoi != true && activateHead != true){ if (typeof oldPos !== 'undefined' && activatePoi != true && activateHead != true){
paintLine(oldPos, coord, element.getNumber()); paintLine(oldPos, coord, element.getNumber());
} }
@ -839,7 +839,7 @@ TABS.mission_control.initialize = function (callback) {
} }
else if (element.isAttached()) { else if (element.isAttached()) {
if (element.getAction() == MWNP.WPTYPE.JUMP) { if (element.getAction() == MWNP.WPTYPE.JUMP) {
let coord = ol.proj.fromLonLat([mission.getWaypoint(element.getP1()).getLonMap(), mission.getWaypoint(element.getP1()).getLatMap()]); let coord = ol.proj.fromLonLat([mission.getWaypoint(element.getP1()).getLonMap(), mission.getWaypoint(element.getP1()).getLatMap()]);
paintLine(oldPos, coord, element.getNumber(), color='#e935d6', lineDash=5, lineText="Repeat x"+(element.getP2() == -1 ? " infinite" : String(element.getP2())), selection=false, arrow=true); paintLine(oldPos, coord, element.getNumber(), color='#e935d6', lineDash=5, lineText="Repeat x"+(element.getP2() == -1 ? " infinite" : String(element.getP2())), selection=false, arrow=true);
} }
// If classic WPs is defined with a heading = -1, change Boolean for POI to false. If it is defined with a value different from -1, activate Heading boolean // If classic WPs is defined with a heading = -1, change Boolean for POI to false. If it is defined with a value different from -1, activate Heading boolean
@ -864,14 +864,14 @@ TABS.mission_control.initialize = function (callback) {
let lengthMission = mission.getDistance(true); let lengthMission = mission.getDistance(true);
$('#missionDistance').text(lengthMission[lengthMission.length -1] != -1 ? lengthMission[lengthMission.length -1].toFixed(1) : 'infinite'); $('#missionDistance').text(lengthMission[lengthMission.length -1] != -1 ? lengthMission[lengthMission.length -1].toFixed(1) : 'infinite');
} }
function paintLine(pos1, pos2, pos2ID, color='#1497f1', lineDash=0, lineText="", selection=true, arrow=false) { function paintLine(pos1, pos2, pos2ID, color='#1497f1', lineDash=0, lineText="", selection=true, arrow=false) {
var line = new ol.geom.LineString([pos1, pos2]); var line = new ol.geom.LineString([pos1, pos2]);
var feature = new ol.Feature({ var feature = new ol.Feature({
geometry: line geometry: line
}); });
feature.setStyle( feature.setStyle(
new ol.style.Style({ new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
@ -890,7 +890,7 @@ TABS.mission_control.initialize = function (callback) {
}), }),
}), }),
); );
if (arrow) { if (arrow) {
let dx = pos2[0] - pos1[0]; let dx = pos2[0] - pos1[0];
let dy = pos2[1] - pos1[1]; let dy = pos2[1] - pos1[1];
@ -910,7 +910,7 @@ TABS.mission_control.initialize = function (callback) {
}) })
); );
} }
if (arrow) { if (arrow) {
var vectorSource = new ol.source.Vector({ var vectorSource = new ol.source.Vector({
@ -931,7 +931,7 @@ TABS.mission_control.initialize = function (callback) {
vectorLayer.kind = "line"; vectorLayer.kind = "line";
vectorLayer.selection = selection; vectorLayer.selection = selection;
vectorLayer.number = pos2ID; vectorLayer.number = pos2ID;
lines.push(vectorLayer); lines.push(vectorLayer);
/* var length = ol.Sphere.getLength(line) + parseFloat($('#missionDistance').text()); /* var length = ol.Sphere.getLength(line) + parseFloat($('#missionDistance').text());
@ -939,26 +939,26 @@ TABS.mission_control.initialize = function (callback) {
map.addLayer(vectorLayer); map.addLayer(vectorLayer);
} }
function cleanLayers() { function cleanLayers() {
for (var i in lines) { for (var i in lines) {
map.removeLayer(lines[i]); map.removeLayer(lines[i]);
} }
lines = []; lines = [];
for (var i in markers) { for (var i in markers) {
map.removeLayer(markers[i]); map.removeLayer(markers[i]);
} }
markers = []; markers = [];
} }
function cleanLines() { function cleanLines() {
for (var i in lines) { for (var i in lines) {
map.removeLayer(lines[i]); map.removeLayer(lines[i]);
} }
lines = []; lines = [];
} }
function redrawLayers() { function redrawLayers() {
if (!mission.isEmpty()) { if (!mission.isEmpty()) {
mission.get().forEach(function (element) { mission.get().forEach(function (element) {
@ -969,15 +969,15 @@ TABS.mission_control.initialize = function (callback) {
} }
repaintLine4Waypoints(mission); repaintLine4Waypoints(mission);
} }
function redrawLayer() { function redrawLayer() {
if (selectedFeature && selectedMarker) { if (selectedFeature && selectedMarker) {
selectedFeature.setStyle(getWaypointIcon(selectedMarker, true)); selectedFeature.setStyle(getWaypointIcon(selectedMarker, true));
} }
repaintLine4Waypoints(mission); repaintLine4Waypoints(mission);
} }
function renderWaypointOptionsTable(waypoint) { function renderWaypointOptionsTable(waypoint) {
/* /*
* Process Waypoint Options table UI * Process Waypoint Options table UI
@ -998,7 +998,7 @@ TABS.mission_control.initialize = function (callback) {
'); ');
const $row = $waypointOptionsTableBody.find('tr:last'); const $row = $waypointOptionsTableBody.find('tr:last');
for (var i = 1; i <= 3; i++) { for (var i = 1; i <= 3; i++) {
if (dictOfLabelParameterPoint[element.getAction()]['parameter'+String(i)] != '') { if (dictOfLabelParameterPoint[element.getAction()]['parameter'+String(i)] != '') {
$row.find(".waypointOptions-p"+String(i)).prop("disabled", false); $row.find(".waypointOptions-p"+String(i)).prop("disabled", false);
@ -1007,9 +1007,9 @@ TABS.mission_control.initialize = function (callback) {
$row.find(".waypointOptions-p"+String(i)).prop("disabled", true); $row.find(".waypointOptions-p"+String(i)).prop("disabled", true);
} }
} }
GUI.fillSelect($row.find(".waypointOptions-action"), waypointOptions, waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])); GUI.fillSelect($row.find(".waypointOptions-action"), waypointOptions, waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()]));
$row.find(".waypointOptions-action").val(waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])).change(function () { $row.find(".waypointOptions-action").val(waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])).change(function () {
element.setAction(MWNP.WPTYPE[waypointOptions[$(this).val()]]); element.setAction(MWNP.WPTYPE[waypointOptions[$(this).val()]]);
for (var i = 1; i <= 3; i++) { for (var i = 1; i <= 3; i++) {
@ -1024,7 +1024,7 @@ TABS.mission_control.initialize = function (callback) {
cleanLines(); cleanLines();
redrawLayer(); redrawLayer();
}); });
$row.find(".waypointOptions-number").text(element.getAttachedNumber()+1); $row.find(".waypointOptions-number").text(element.getAttachedNumber()+1);
@ -1061,7 +1061,7 @@ TABS.mission_control.initialize = function (callback) {
cleanLines(); cleanLines();
redrawLayer(); redrawLayer();
}); });
$row.find(".waypointOptions-p2").val(element.getP2()).change(function () { $row.find(".waypointOptions-p2").val(element.getP2()).change(function () {
if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") { if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1)) if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1))
@ -1077,13 +1077,13 @@ TABS.mission_control.initialize = function (callback) {
}); });
$row.find("[data-role='waypointOptions-delete']").attr("data-index", element.getAttachedNumber()+1); $row.find("[data-role='waypointOptions-delete']").attr("data-index", element.getAttachedNumber()+1);
}); });
GUI.switchery(); GUI.switchery();
localize(); localize();
return waypoint; return waypoint;
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// //
// Manage Map construction // Manage Map construction
@ -1091,10 +1091,10 @@ TABS.mission_control.initialize = function (callback) {
///////////////////////////////////////////// /////////////////////////////////////////////
function initMap() { function initMap() {
var app = {}; var app = {};
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// Drag behavior definition // Drag behavior definition
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
/** /**
* @constructor * @constructor
@ -1171,8 +1171,8 @@ TABS.mission_control.initialize = function (callback) {
}; };
ol.inherits(app.PlannerSettingsControl, ol.control.Control); ol.inherits(app.PlannerSettingsControl, ol.control.Control);
/** /**
* @constructor * @constructor
* @extends {ol.control.Control} * @extends {ol.control.Control}
@ -1211,7 +1211,7 @@ TABS.mission_control.initialize = function (callback) {
}; };
ol.inherits(app.PlannerSafehomeControl, ol.control.Control); ol.inherits(app.PlannerSafehomeControl, ol.control.Control);
/** /**
* @constructor * @constructor
* @extends {ol.control.Control} * @extends {ol.control.Control}
@ -1248,7 +1248,7 @@ TABS.mission_control.initialize = function (callback) {
}; };
ol.inherits(app.PlannerElevationControl, ol.control.Control); ol.inherits(app.PlannerElevationControl, ol.control.Control);
/** /**
* @param {ol.MapBrowserEvent} evt Map browser event. * @param {ol.MapBrowserEvent} evt Map browser event.
* @return {boolean} `true` to start the drag sequence. * @return {boolean} `true` to start the drag sequence.
@ -1293,7 +1293,7 @@ TABS.mission_control.initialize = function (callback) {
if (tempMarker.kind == "waypoint" ||tempMarker.kind == "safehome" || tempMarker.kind == "home") { if (tempMarker.kind == "waypoint" ||tempMarker.kind == "safehome" || tempMarker.kind == "home") {
geometry.translate(deltaX, deltaY); geometry.translate(deltaX, deltaY);
this.coordinate_[0] = evt.coordinate[0]; this.coordinate_[0] = evt.coordinate[0];
this.coordinate_[1] = evt.coordinate[1]; this.coordinate_[1] = evt.coordinate[1];
} }
let coord = ol.proj.toLonLat(geometry.getCoordinates()); let coord = ol.proj.toLonLat(geometry.getCoordinates());
@ -1306,7 +1306,7 @@ TABS.mission_control.initialize = function (callback) {
mission.updateWaypoint(tempWp); mission.updateWaypoint(tempWp);
repaintLine4Waypoints(mission); repaintLine4Waypoints(mission);
} }
else if (tempMarker.kind == "safehome") { else if (tempMarker.kind == "safehome") {
let tempSH = SAFEHOMES.getSafehome(tempMarker.number); let tempSH = SAFEHOMES.getSafehome(tempMarker.number);
tempSH.setLon(Math.round(coord[0] * 10000000)); tempSH.setLon(Math.round(coord[0] * 10000000));
tempSH.setLat(Math.round(coord[1] * 10000000)); tempSH.setLat(Math.round(coord[1] * 10000000));
@ -1314,13 +1314,13 @@ TABS.mission_control.initialize = function (callback) {
$safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lon').val(Math.round(coord[0] * 10000000) / 10000000); $safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lon').val(Math.round(coord[0] * 10000000) / 10000000);
$safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lat').val(Math.round(coord[1] * 10000000) / 10000000); $safehomesTableBody.find('tr:nth-child('+String(tempMarker.number+1)+') > td > .safehome-lat').val(Math.round(coord[1] * 10000000) / 10000000);
} }
else if (tempMarker.kind == "home") { else if (tempMarker.kind == "home") {
HOME.setLon(Math.round(coord[0] * 10000000)); HOME.setLon(Math.round(coord[0] * 10000000));
HOME.setLat(Math.round(coord[1] * 10000000)); HOME.setLat(Math.round(coord[1] * 10000000));
$('.home-lon').val(Math.round(coord[0] * 10000000) / 10000000); $('.home-lon').val(Math.round(coord[0] * 10000000) / 10000000);
$('.home-lat').val(Math.round(coord[1] * 10000000) / 10000000); $('.home-lat').val(Math.round(coord[1] * 10000000) / 10000000);
} }
}; };
/** /**
@ -1392,7 +1392,7 @@ TABS.mission_control.initialize = function (callback) {
} else { } else {
mapLayer = new ol.source.OSM(); mapLayer = new ol.source.OSM();
} }
if (CONFIGURATOR.connectionValid) { if (CONFIGURATOR.connectionValid) {
control_list = [ control_list = [
new app.PlannerSettingsControl(), new app.PlannerSettingsControl(),
@ -1410,7 +1410,7 @@ TABS.mission_control.initialize = function (callback) {
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// Map object definition // Map object definition
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
map = new ol.Map({ map = new ol.Map({
controls: ol.control.defaults({ controls: ol.control.defaults({
attributionOptions: { attributionOptions: {
@ -1456,7 +1456,7 @@ TABS.mission_control.initialize = function (callback) {
} }
}); });
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Map on-click behavior definition // Map on-click behavior definition
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
map.on('click', function (evt) { map.on('click', function (evt) {
if (selectedMarker != null && selectedFeature != null) { if (selectedMarker != null && selectedFeature != null) {
@ -1497,8 +1497,8 @@ TABS.mission_control.initialize = function (callback) {
$('#pointP1').val(selectedMarker.getP1()); $('#pointP1').val(selectedMarker.getP1());
$('#pointP2').val(selectedMarker.getP2()); $('#pointP2').val(selectedMarker.getP2());
changeSwitchery($('#pointP3'), selectedMarker.getP3() == 1); changeSwitchery($('#pointP3'), selectedMarker.getP3() == 1);
// Selection box update depending on choice of type of waypoint // Selection box update depending on choice of type of waypoint
for (var j in dictOfLabelParameterPoint[selectedMarker.getAction()]) { for (var j in dictOfLabelParameterPoint[selectedMarker.getAction()]) {
if (dictOfLabelParameterPoint[selectedMarker.getAction()][j] != '') { if (dictOfLabelParameterPoint[selectedMarker.getAction()][j] != '') {
@ -1578,7 +1578,7 @@ TABS.mission_control.initialize = function (callback) {
let altitudeMeters = app.ConvertCentimetersToMeters($(this).val()); let altitudeMeters = app.ConvertCentimetersToMeters($(this).val());
$('#altitudeInMeters').text(` ${altitudeMeters}m`); $('#altitudeInMeters').text(` ${altitudeMeters}m`);
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback to show/hide menu boxes // Callback to show/hide menu boxes
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1594,7 +1594,7 @@ TABS.mission_control.initialize = function (callback) {
$('#ActionContent').fadeOut(300); $('#ActionContent').fadeOut(300);
} }
}); });
$('#showHideInfoButton').on('click', function () { $('#showHideInfoButton').on('click', function () {
var src = ($(this).children().attr('class') === 'ic_hide') var src = ($(this).children().attr('class') === 'ic_hide')
? 'ic_show' ? 'ic_show'
@ -1607,7 +1607,7 @@ TABS.mission_control.initialize = function (callback) {
$('#InfoContent').fadeOut(300); $('#InfoContent').fadeOut(300);
} }
}); });
$('#showHideSafehomeButton').on('click', function () { $('#showHideSafehomeButton').on('click', function () {
var src = ($(this).children().attr('class') === 'ic_hide') var src = ($(this).children().attr('class') === 'ic_hide')
? 'ic_show' ? 'ic_show'
@ -1620,7 +1620,7 @@ TABS.mission_control.initialize = function (callback) {
$('#SafehomeContent').fadeOut(300); $('#SafehomeContent').fadeOut(300);
} }
}); });
$('#showHideHomeButton').on('click', function () { $('#showHideHomeButton').on('click', function () {
var src = ($(this).children().attr('class') === 'ic_hide') var src = ($(this).children().attr('class') === 'ic_hide')
? 'ic_show' ? 'ic_show'
@ -1633,7 +1633,7 @@ TABS.mission_control.initialize = function (callback) {
$('#HomeContent').fadeOut(300); $('#HomeContent').fadeOut(300);
} }
}); });
$('#showHideWPeditButton').on('click', function () { $('#showHideWPeditButton').on('click', function () {
var src = ($(this).children().attr('class') === 'ic_hide') var src = ($(this).children().attr('class') === 'ic_hide')
? 'ic_show' ? 'ic_show'
@ -1646,7 +1646,7 @@ TABS.mission_control.initialize = function (callback) {
$('#WPeditContent').fadeOut(300); $('#WPeditContent').fadeOut(300);
} }
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for Waypoint edition // Callback for Waypoint edition
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1670,7 +1670,7 @@ TABS.mission_control.initialize = function (callback) {
redrawLayer(); redrawLayer();
} }
}); });
$('#pointLat').on('change', function (event) { $('#pointLat').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setLat(Math.round(Number($('#pointLat').val()) * 10000000)); selectedMarker.setLat(Math.round(Number($('#pointLat').val()) * 10000000));
@ -1683,7 +1683,7 @@ TABS.mission_control.initialize = function (callback) {
plotElevation(); plotElevation();
} }
}); });
$('#pointLon').on('change', function (event) { $('#pointLon').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setLon(Math.round(Number($('#pointLon').val()) * 10000000)); selectedMarker.setLon(Math.round(Number($('#pointLon').val()) * 10000000));
@ -1696,7 +1696,7 @@ TABS.mission_control.initialize = function (callback) {
plotElevation(); plotElevation();
} }
}); });
$('#pointAlt').on('change', function (event) { $('#pointAlt').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setAlt(Number($('#pointAlt').val())); selectedMarker.setAlt(Number($('#pointAlt').val()));
@ -1706,7 +1706,7 @@ TABS.mission_control.initialize = function (callback) {
plotElevation(); plotElevation();
} }
}); });
$('#pointP1').on('change', function (event) { $('#pointP1').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setP1(Number($('#pointP1').val())); selectedMarker.setP1(Number($('#pointP1').val()));
@ -1715,7 +1715,7 @@ TABS.mission_control.initialize = function (callback) {
redrawLayer(); redrawLayer();
} }
}); });
$('#pointP2').on('change', function (event) { $('#pointP2').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setP2(Number($('#pointP2').val())); selectedMarker.setP2(Number($('#pointP2').val()));
@ -1724,7 +1724,7 @@ TABS.mission_control.initialize = function (callback) {
redrawLayer(); redrawLayer();
} }
}); });
$('#pointP3').on('change', function (event) { $('#pointP3').on('change', function (event) {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setP3( $('#pointP3').prop("checked") ? 1.0 : 0.0); selectedMarker.setP3( $('#pointP3').prop("checked") ? 1.0 : 0.0);
@ -1734,7 +1734,7 @@ TABS.mission_control.initialize = function (callback) {
$('#elevationValueAtWP').text(elevationAtWP); $('#elevationValueAtWP').text(elevationAtWP);
$('#elevationAtWP').fadeIn(300); $('#elevationAtWP').fadeIn(300);
})() })()
} }
else { else {
$('#elevationAtWP').fadeOut(300); $('#elevationAtWP').fadeOut(300);
@ -1745,7 +1745,7 @@ TABS.mission_control.initialize = function (callback) {
plotElevation(); plotElevation();
} }
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for Waypoint Options Table // Callback for Waypoint Options Table
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1760,7 +1760,7 @@ TABS.mission_control.initialize = function (callback) {
selectedFeature.setStyle(getWaypointIcon(selectedMarker, true)); selectedFeature.setStyle(getWaypointIcon(selectedMarker, true));
} }
}); });
$("[data-role='waypointOptions-add']").click(function () { $("[data-role='waypointOptions-add']").click(function () {
if (selectedMarker) { if (selectedMarker) {
mission.addAttachedFromWaypoint(selectedMarker); mission.addAttachedFromWaypoint(selectedMarker);
@ -1772,7 +1772,7 @@ TABS.mission_control.initialize = function (callback) {
selectedFeature.setStyle(getWaypointIcon(selectedMarker, true)); selectedFeature.setStyle(getWaypointIcon(selectedMarker, true));
} }
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for SAFEHOMES Table // Callback for SAFEHOMES Table
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1784,13 +1784,13 @@ TABS.mission_control.initialize = function (callback) {
SAFEHOMES.updateSafehome(tmpSH); SAFEHOMES.updateSafehome(tmpSH);
renderSafehomesTable(); renderSafehomesTable();
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
}); });
$('#cancelSafehome').on('click', function () { $('#cancelSafehome').on('click', function () {
closeSafehomePanel(); closeSafehomePanel();
}); });
$('#loadEepromSafehomeButton').on('click', function () { $('#loadEepromSafehomeButton').on('click', function () {
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log('Start of getting Safehome points'); GUI.log('Start of getting Safehome points');
@ -1802,9 +1802,9 @@ TABS.mission_control.initialize = function (callback) {
GUI.log('End of getting Safehome points'); GUI.log('End of getting Safehome points');
$('#loadEepromSafehomeButton').removeClass('disabled'); $('#loadEepromSafehomeButton').removeClass('disabled');
}, 500); }, 500);
}); });
$('#saveEepromSafehomeButton').on('click', function () { $('#saveEepromSafehomeButton').on('click', function () {
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log('Start of sending Safehome points'); GUI.log('Start of sending Safehome points');
@ -1815,7 +1815,7 @@ TABS.mission_control.initialize = function (callback) {
$('#saveEepromSafehomeButton').removeClass('disabled'); $('#saveEepromSafehomeButton').removeClass('disabled');
}, 500); }, 500);
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for HOME Table // Callback for HOME Table
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1825,15 +1825,15 @@ TABS.mission_control.initialize = function (callback) {
HOME.setLat(Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7)); HOME.setLat(Math.round(ol.proj.toLonLat(mapCenter)[1] * 1e7));
updateHome(); updateHome();
}); });
$('#cancelHome').on('click', function () { $('#cancelHome').on('click', function () {
closeHomePanel(); closeHomePanel();
}); });
$('#cancelPlot').on('click', function () { $('#cancelPlot').on('click', function () {
closeHomePanel(); closeHomePanel();
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for Remove buttons // Callback for Remove buttons
///////////////////////////////////////////// /////////////////////////////////////////////
@ -1875,11 +1875,11 @@ TABS.mission_control.initialize = function (callback) {
} }
} }
}); });
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for Save/load buttons // Callback for Save/load buttons
///////////////////////////////////////////// /////////////////////////////////////////////
$('#loadFileMissionButton').on('click', function () { $('#loadFileMissionButton').on('click', function () {
if (markers.length && !confirm(chrome.i18n.getMessage('confirm_delete_all_points'))) return; if (markers.length && !confirm(chrome.i18n.getMessage('confirm_delete_all_points'))) return;
removeAllWaypoints(); removeAllWaypoints();
@ -1912,7 +1912,7 @@ TABS.mission_control.initialize = function (callback) {
sendWaypointsToFC(); sendWaypointsToFC();
GUI.log('End send point'); GUI.log('End send point');
$('#saveMissionButton').removeClass('disabled'); $('#saveMissionButton').removeClass('disabled');
}); });
$('#loadEepromMissionButton').on('click', function () { $('#loadEepromMissionButton').on('click', function () {
@ -1921,7 +1921,7 @@ TABS.mission_control.initialize = function (callback) {
GUI.log(chrome.i18n.getMessage('eeprom_load_ok')); GUI.log(chrome.i18n.getMessage('eeprom_load_ok'));
MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], getWaypointsFromFC); MSP.send_message(MSPCodes.MSP_WP_MISSION_LOAD, [0], getWaypointsFromFC);
}); });
$('#saveEepromMissionButton').on('click', function () { $('#saveEepromMissionButton').on('click', function () {
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log('Start send point'); GUI.log('Start send point');
@ -1943,7 +1943,7 @@ TABS.mission_control.initialize = function (callback) {
saveSettings(); saveSettings();
if (settings.safeRadiusSH != oldSafeRadiusSH && $('#showHideSafehomeButton').is(":visible")) { if (settings.safeRadiusSH != oldSafeRadiusSH && $('#showHideSafehomeButton').is(":visible")) {
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
$('#SafeHomeSafeDistance').text(settings.safeRadiusSH); $('#SafeHomeSafeDistance').text(settings.safeRadiusSH);
} }
closeSettingsPanel(); closeSettingsPanel();
@ -1953,7 +1953,7 @@ TABS.mission_control.initialize = function (callback) {
loadSettings(); loadSettings();
closeSettingsPanel(); closeSettingsPanel();
}); });
updateTotalInfo(); updateTotalInfo();
@ -2075,7 +2075,7 @@ TABS.mission_control.initialize = function (callback) {
map.getView().setCenter(coord); map.getView().setCenter(coord);
map.getView().setZoom(16); map.getView().setZoom(16);
} }
redrawLayers(); redrawLayers();
updateHome(); updateHome();
updateTotalInfo(); updateTotalInfo();
@ -2095,14 +2095,14 @@ TABS.mission_control.initialize = function (callback) {
var data = { var data = {
'version': { $: { 'value': '2.3-pre8' } }, 'version': { $: { 'value': '2.3-pre8' } },
'mwp': { $: { 'cx': (Math.round(center[0] * 10000000) / 10000000), 'mwp': { $: { 'cx': (Math.round(center[0] * 10000000) / 10000000),
'cy': (Math.round(center[1] * 10000000) / 10000000), 'cy': (Math.round(center[1] * 10000000) / 10000000),
'home-x' : HOME.getLonMap(), 'home-x' : HOME.getLonMap(),
'home-y' : HOME.getLatMap(), 'home-y' : HOME.getLatMap(),
'zoom': zoom } }, 'zoom': zoom } },
'missionitem': [] 'missionitem': []
}; };
mission.get().forEach(function (waypoint) { mission.get().forEach(function (waypoint) {
var point = { $: { var point = { $: {
'no': waypoint.getNumber()+1, 'no': waypoint.getNumber()+1,
@ -2116,7 +2116,7 @@ TABS.mission_control.initialize = function (callback) {
} }; } };
data.missionitem.push(point); data.missionitem.push(point);
}); });
var builder = new window.xml2js.Builder({ 'rootName': 'mission', 'renderOpts': { 'pretty': true, 'indent': '\t', 'newline': '\n' } }); var builder = new window.xml2js.Builder({ 'rootName': 'mission', 'renderOpts': { 'pretty': true, 'indent': '\t', 'newline': '\n' } });
var xml = builder.buildObject(data); var xml = builder.buildObject(data);
fs.writeFile(filename, xml, (err) => { fs.writeFile(filename, xml, (err) => {
@ -2148,7 +2148,7 @@ TABS.mission_control.initialize = function (callback) {
updateTotalInfo(); updateTotalInfo();
}, 2000); }, 2000);
} }
function sendWaypointsToFC() { function sendWaypointsToFC() {
MISSION_PLANER.reinit(); MISSION_PLANER.reinit();
MISSION_PLANER.copy(mission); MISSION_PLANER.copy(mission);
@ -2169,26 +2169,26 @@ TABS.mission_control.initialize = function (callback) {
} }
function updateTotalInfo() { function updateTotalInfo() {
if (CONFIGURATOR.connectionValid) { if (CONFIGURATOR.connectionValid) {
$('#availablePoints').text(mission.getCountBusyPoints() + '/' + mission.getMaxWaypoints()); $('#availablePoints').text(mission.getCountBusyPoints() + '/' + mission.getMaxWaypoints());
$('#missionValid').html(mission.getValidMission() ? chrome.i18n.getMessage('armingCheckPass') : chrome.i18n.getMessage('armingCheckFail')); $('#missionValid').html(mission.getValidMission() ? chrome.i18n.getMessage('armingCheckPass') : chrome.i18n.getMessage('armingCheckFail'));
} }
} }
function updateFilename(filename) { function updateFilename(filename) {
$('#missionFilename').text(filename); $('#missionFilename').text(filename);
$('#infoMissionFilename').show(); $('#infoMissionFilename').show();
} }
function changeSwitchery(element, checked) { function changeSwitchery(element, checked) {
if ( ( element.is(':checked') && checked == false ) || ( !element.is(':checked') && checked == true ) ) { if ( ( element.is(':checked') && checked == false ) || ( !element.is(':checked') && checked == true ) ) {
element.parent().find('.switcherymid').trigger('click'); element.parent().find('.switcherymid').trigger('click');
} }
} }
function plotElevation() { function plotElevation() {
if ($('#missionPlanerElevation').is(":visible")) { if ($('#missionPlanerElevation').is(":visible")) {
if (mission.get().length == 0) { if (mission.get().length == 0) {