betaflight-configurator/js/main.js

67 lines
2.8 KiB
JavaScript
Raw Normal View History

2013-04-13 10:38:06 +00:00
// OS detection
var OS = "Unknown";
if (navigator.appVersion.indexOf("Win") != -1) OS = "Windows";
if (navigator.appVersion.indexOf("Mac") != -1) OS = "MacOS";
if (navigator.appVersion.indexOf("X11") != -1) OS = "UNIX";
if (navigator.appVersion.indexOf("Linux") != -1) OS = "Linux";
var timers = new Array();
2013-04-08 19:10:47 +00:00
$(document).ready(function() {
2013-04-13 00:43:23 +00:00
var tabs = $('#tabs > ul');
2013-04-08 19:10:47 +00:00
$('a', tabs).click(function() {
if ($(this).parent().hasClass('active') == false) { // only initialize when the tab isn't already active
if (connectionId < 1 || configuration_received == false) { // if there is no active connection, return
2013-04-08 19:10:47 +00:00
return;
}
// Disable any active "data pulling" timer
disable_timers();
2013-04-12 17:17:27 +00:00
// Disable CLI (there is no "nicer way of doing so right now)
if (CLI_active == true) {
leave_CLI();
}
2013-04-08 19:10:47 +00:00
// Disable previous active button
$('li', tabs).removeClass('active');
// Highlight selected button
$(this).parent().addClass('active');
if ($(this).parent().hasClass('tab_initial_setup')) {
$('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup);
} else if ($(this).parent().hasClass('tab_pid_tuning')) {
$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning);
} else if ($(this).parent().hasClass('tab_receiver')) {
$('#content').load("./tabs/receiver.html", tab_initialize_receiver);
2013-04-10 11:53:48 +00:00
} else if ($(this).parent().hasClass('tab_auxiliary_configuration')) {
$('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration);
} else if ($(this).parent().hasClass('tab_gps')) {
$('#content').load("./tabs/gps.html", tab_initialize_gps);
} else if ($(this).parent().hasClass('tab_motor_outputs')) {
$('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs);
2013-04-11 10:01:51 +00:00
} else if ($(this).parent().hasClass('tab_sensors')) {
$('#content').load("./tabs/sensors.html", tab_initialize_sensors);
2013-04-12 17:17:27 +00:00
} else if ($(this).parent().hasClass('tab_cli')) {
$('#content').load("./tabs/cli.html", tab_initialize_cli);
2013-04-13 13:29:52 +00:00
} else if ($(this).parent().hasClass('tab_about')) {
$('#content').load("./tabs/about.html");
2013-04-08 19:10:47 +00:00
}
}
});
// temporary
//$('#content').load("./tabs/gps.html", tab_initialize_gps);
});
function disable_timers() {
for (var i = 0; i < timers.length; i++) {
clearInterval(timers[i]);
}
// kill all the refferences
timers = [];
2013-04-11 14:19:24 +00:00
return true;
}