Merge branch 'title_numbers' of https://github.com/m30164/dump1090 into m30164-title_numbers

This commit is contained in:
Oliver Jowett 2015-02-22 11:35:59 +00:00
commit 288a8242dd
2 changed files with 26 additions and 3 deletions

View file

@ -5,6 +5,11 @@
// //
// -------------------------------------------------------- // --------------------------------------------------------
// -- Title Settings --------------------------------------
// Show number of aircraft and/or messages per second in the page title
NumPlanesInTitle = true;
NumMessagesInTitle = true;
// -- Output Settings ------------------------------------- // -- Output Settings -------------------------------------
// Show metric values // Show metric values
// The Metric setting controls whether metric (m, km, km/h) or // The Metric setting controls whether metric (m, km, km/h) or

View file

@ -34,6 +34,7 @@ var StaleReceiverCount = 0;
var FetchPending = null; var FetchPending = null;
var MessageCountHistory = []; var MessageCountHistory = [];
var MessagesPerSecond = 0;
var NBSP='\u00a0'; var NBSP='\u00a0';
@ -139,7 +140,7 @@ function fetchData() {
var PositionHistorySize = 0; var PositionHistorySize = 0;
function initialize() { function initialize() {
// Set page basics // Set page basics
$("head title").text(PageName); $("head title").text(PageName); // page title
$("#infoblock_name").text(PageName); $("#infoblock_name").text(PageName);
PlaneRowTemplate = document.getElementById("plane_row_template"); PlaneRowTemplate = document.getElementById("plane_row_template");
@ -485,9 +486,24 @@ function reaper() {
refreshSelected(); refreshSelected();
} }
// Page Title update function
function refreshPageTitle() {
if(NumPlanesInTitle && !NumMessagesInTitle){
$("head title").text("DUMP1090 - " + TrackedAircraftPositions);
}
else if(!NumPlanesInTitle && NumMessagesInTitle){
$("head title").text("DUMP1090 - " + MessagesPerSecond.toFixed(1));
}
else if(NumPlanesInTitle && NumMessagesInTitle){
$("head title").text("DUMP1090 - " + TrackedAircraftPositions + " | " + MessagesPerSecond.toFixed(1));
}
}
// Refresh the detail window about the plane // Refresh the detail window about the plane
function refreshSelected() { function refreshSelected() {
var selected = false; refreshPageTitle();
var selected = false;
if (typeof SelectedPlane !== 'undefined' && SelectedPlane != "ICAO" && SelectedPlane != null) { if (typeof SelectedPlane !== 'undefined' && SelectedPlane != "ICAO" && SelectedPlane != null) {
selected = Planes[SelectedPlane]; selected = Planes[SelectedPlane];
} }
@ -508,8 +524,10 @@ function refreshSelected() {
message_rate = message_count_delta / message_time_delta; message_rate = message_count_delta / message_time_delta;
} }
if (message_rate !== null) if (message_rate !== null){
MessagesPerSecond = message_rate;
$('#dump1090_message_rate').text(message_rate.toFixed(1)); $('#dump1090_message_rate').text(message_rate.toFixed(1));
}
else else
$('#dump1090_message_rate').text("n/a"); $('#dump1090_message_rate').text("n/a");