GPS
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
\ No newline at end of file
diff --git a/tabs/gps.js b/tabs/gps.js
index be8291d9..b987f975 100644
--- a/tabs/gps.js
+++ b/tabs/gps.js
@@ -1,3 +1,4 @@
+/*global $,MSPChainerClass,googleAnalytics,mspHelper,MSPCodes,GUI,chrome,MSP,TABS,Settings,helper,ol*/
'use strict';
TABS.gps = {};
@@ -8,11 +9,49 @@ TABS.gps.initialize = function (callback) {
googleAnalytics.sendAppView('GPS');
}
- function load_html() {
- GUI.load("./tabs/gps.html", process_html);
+ var loadChainer = new MSPChainerClass();
+
+ var loadChain = [
+ mspHelper.loadBfConfig,
+ mspHelper.loadMiscV2
+ ];
+
+ loadChainer.setChain(loadChain);
+ loadChainer.setExitPoint(load_html);
+ loadChainer.execute();
+
+ var saveChainer = new MSPChainerClass();
+
+ var saveChain = [
+ mspHelper.saveBfConfig,
+ mspHelper.saveMiscV2,
+ saveSettings,
+ mspHelper.saveToEeprom
+ ];
+
+ function saveSettings(onComplete) {
+ Settings.saveInputs().then(onComplete);
}
- load_html();
+ saveChainer.setChain(saveChain);
+ saveChainer.setExitPoint(reboot);
+
+ function reboot() {
+ //noinspection JSUnresolvedVariable
+ GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
+
+ GUI.tab_switch_cleanup(function () {
+ MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
+ //noinspection JSUnresolvedVariable
+ GUI.log(chrome.i18n.getMessage('deviceRebooting'));
+ GUI.handleReconnect($('.tab_gps a'));
+ });
+ });
+ }
+
+ function load_html() {
+ GUI.load("./tabs/gps.html", Settings.processHtml(process_html));
+ }
let cursorInitialized = false;
let iconStyle;
@@ -23,6 +62,36 @@ TABS.gps.initialize = function (callback) {
function process_html() {
localize();
+ var features = FC.getFeatures();
+
+ helper.features.updateUI($('.tab-gps'), BF_CONFIG.features);
+
+ // generate GPS
+ var gpsProtocols = FC.getGpsProtocols();
+ var gpsSbas = FC.getGpsSbasProviders();
+
+ var gps_protocol_e = $('#gps_protocol');
+ for (i = 0; i < gpsProtocols.length; i++) {
+ gps_protocol_e.append('
');
+ }
+
+ gps_protocol_e.change(function () {
+ MISC.gps_type = parseInt($(this).val());
+ });
+
+ gps_protocol_e.val(MISC.gps_type);
+
+ var gps_ubx_sbas_e = $('#gps_ubx_sbas');
+ for (i = 0; i < gpsSbas.length; i++) {
+ gps_ubx_sbas_e.append('
');
+ }
+
+ gps_ubx_sbas_e.change(function () {
+ MISC.gps_ubx_sbas = parseInt($(this).val());
+ });
+
+ gps_ubx_sbas_e.val(MISC.gps_ubx_sbas);
+
let mapView = new ol.View({
center: ol.proj.fromLonLat([0, 0]),
zoom: 15
@@ -36,20 +105,20 @@ TABS.gps.initialize = function (callback) {
imagerySet: 'AerialWithLabels',
maxZoom: 19
});
- } else if ( globalSettings.mapProviderType == 'mapproxy' ) {
- mapLayer = new ol.source.TileWMS({
- url: globalSettings.proxyURL,
- params: {'LAYERS':globalSettings.proxyLayer}
- })
+ } else if (globalSettings.mapProviderType == 'mapproxy') {
+ mapLayer = new ol.source.TileWMS({
+ url: globalSettings.proxyURL,
+ params: { 'LAYERS': globalSettings.proxyLayer }
+ })
} else {
mapLayer = new ol.source.OSM();
}
- $("#center_button").click(function(){
- let lat = GPS_DATA.lat / 10000000;
- let lon = GPS_DATA.lon / 10000000;
- let center = ol.proj.fromLonLat([lon, lat]);
- mapView.setCenter(center);
+ $("#center_button").click(function () {
+ let lat = GPS_DATA.lat / 10000000;
+ let lon = GPS_DATA.lon / 10000000;
+ let center = ol.proj.fromLonLat([lon, lat]);
+ mapView.setCenter(center);
});
mapHandler = new ol.Map({
@@ -144,7 +213,7 @@ TABS.gps.initialize = function (callback) {
});
mapHandler.addLayer(currentPositionLayer);
-
+
mapView.setCenter(center);
mapView.setZoom(14);
}
@@ -172,6 +241,29 @@ TABS.gps.initialize = function (callback) {
get_raw_gps_data();
});
+
+ $('a.save').on('click', function () {
+ if (FC.isFeatureEnabled('GPS', features)) {
+ googleAnalytics.sendEvent('Setting', 'GpsProtocol', gpsProtocols[MISC.gps_type]);
+ googleAnalytics.sendEvent('Setting', 'GpsSbas', gpsSbas[MISC.gps_ubx_sbas]);
+ }
+
+ googleAnalytics.sendEvent('Setting', 'GPSEnabled', FC.isFeatureEnabled('GPS', features) ? "true" : "false");
+
+ for (var i = 0; i < features.length; i++) {
+ var featureName = features[i].name;
+ if (FC.isFeatureEnabled(featureName, features)) {
+ googleAnalytics.sendEvent('Setting', 'Feature', featureName);
+ }
+ }
+
+ helper.features.reset();
+ helper.features.fromUI($('.tab-gps'));
+ helper.features.execute(function () {
+ saveChainer.execute();
+ });
+ });
+
GUI.content_ready(callback);
}