2015-01-25 12:02:20 +00:00
|
|
|
require.config({
|
|
|
|
baseUrl : '.',
|
|
|
|
paths : {
|
|
|
|
jquery : '3rdparty/jquery/jquery-1.11.2.min',
|
|
|
|
'jquery-ui' : '3rdparty/jquery/ui',
|
2016-06-01 09:28:26 +00:00
|
|
|
knockout : '3rdparty/knockout/knockout-3.4.0',
|
2015-01-25 12:02:20 +00:00
|
|
|
kojqui : '3rdparty/knockout-jqueryui',
|
|
|
|
sprintf : '3rdparty/sprintf/sprintf.min',
|
2015-12-18 21:08:19 +00:00
|
|
|
leaflet : '3rdparty/leaflet-0.7.7/leaflet',
|
|
|
|
geodesic : '3rdparty/leaflet-0.7.7/Leaflet.Geodesic.min',
|
2015-01-25 12:02:20 +00:00
|
|
|
text : '3rdparty/require/text',
|
|
|
|
flot : '3rdparty/flot/jquery.flot',
|
2015-02-26 15:21:21 +00:00
|
|
|
flotresize : '3rdparty/flot/jquery.flot.resize',
|
2015-03-01 17:22:56 +00:00
|
|
|
flottime : '3rdparty/flot/jquery.flot.time',
|
2015-02-06 12:08:32 +00:00
|
|
|
fgcommand : 'lib/fgcommand',
|
2015-03-11 21:37:48 +00:00
|
|
|
props : 'lib/props2',
|
2015-11-19 10:42:29 +00:00
|
|
|
knockprops : 'lib/knockprops',
|
2015-09-27 18:57:41 +00:00
|
|
|
sammy : '3rdparty/sammy-latest.min',
|
|
|
|
aircraft : '../aircraft-dir',
|
|
|
|
pagedown : '3rdparty/pagedown',
|
|
|
|
clockpicker : '3rdparty/clockpicker/jquery-clockpicker.min',
|
2015-11-19 11:07:07 +00:00
|
|
|
stamen : 'http://maps.stamen.com/js/tile.stamen',
|
2015-10-02 19:52:29 +00:00
|
|
|
},
|
2015-11-19 11:07:07 +00:00
|
|
|
waitSeconds : 30,
|
2015-01-25 12:02:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
require([
|
2015-09-27 18:57:41 +00:00
|
|
|
'knockout', 'jquery', 'sammy', 'fgcommand', 'themeswitch', 'kojqui/button', 'kojqui/buttonset', 'kojqui/selectmenu',
|
2015-11-19 10:42:29 +00:00
|
|
|
'jquery-ui/sortable', 'flot', 'leaflet', 'knockprops'
|
2015-09-27 18:57:41 +00:00
|
|
|
], function(ko, jquery, Sammy, fgcommand) {
|
2015-01-25 12:02:20 +00:00
|
|
|
|
2016-06-01 09:28:26 +00:00
|
|
|
ko.options.deferUpdates = true;
|
|
|
|
|
|
|
|
|
2015-11-19 11:07:07 +00:00
|
|
|
ko.utils.knockprops.setAliases({
|
2015-01-25 12:02:20 +00:00
|
|
|
|
2015-11-19 11:07:07 +00:00
|
|
|
// time
|
|
|
|
gmt : "/sim/time/gmt",
|
|
|
|
timeWarp : "/sim/time/warp",
|
|
|
|
// flight
|
|
|
|
pitch : "/orientation/pitch-deg",
|
|
|
|
roll : "/orientation/roll-deg",
|
|
|
|
heading : "/orientation/heading-magnetic-deg",
|
|
|
|
"true-heading" : "/orientation/heading-deg",
|
|
|
|
altitude : "/position/altitude-ft",
|
|
|
|
latitude : "/position/latitude-deg",
|
|
|
|
longitude : "/position/longitude-deg",
|
|
|
|
airspeed : "/velocities/airspeed-kt",
|
|
|
|
groundspeed : "/velocities/groundspeed-kt",
|
|
|
|
slip : "/instrumentation/slip-skid-ball/indicated-slip-skid",
|
|
|
|
cg : "/fdm/jsbsim/inertia/cg-x-in",
|
|
|
|
weight : "/fdm/jsbsim/inertia/weight-lbs",
|
|
|
|
|
|
|
|
// radio settings
|
|
|
|
com1stn : "/instrumentation/comm/station-name",
|
|
|
|
com1use : "/instrumentation/comm/frequencies/selected-mhz",
|
|
|
|
com1sby : "/instrumentation/comm/frequencies/standby-mhz",
|
|
|
|
com1stn : "/instrumentation/comm/station-name",
|
|
|
|
com2stn : "/instrumentation/comm[1]/station-name",
|
|
|
|
com2use : "/instrumentation/comm[1]/frequencies/selected-mhz",
|
|
|
|
com2sby : "/instrumentation/comm[1]/frequencies/standby-mhz",
|
|
|
|
com2stn : "/instrumentation/comm[1]/station-name",
|
|
|
|
nav1use : "/instrumentation/nav/frequencies/selected-mhz",
|
|
|
|
nav1sby : "/instrumentation/nav/frequencies/standby-mhz",
|
|
|
|
nav1stn : "/instrumentation/nav/nav-id",
|
|
|
|
nav2use : "/instrumentation/nav[1]/frequencies/selected-mhz",
|
|
|
|
nav2sby : "/instrumentation/nav[1]/frequencies/standby-mhz",
|
|
|
|
nav2stn : "/instrumentation/nav[1]/nav-id",
|
|
|
|
adf1use : "/instrumentation/adf/frequencies/selected-khz",
|
|
|
|
adf1sby : "/instrumentation/adf/frequencies/standby-khz",
|
|
|
|
adf1stn : "/instrumentation/adf/ident",
|
|
|
|
dme1use : "/instrumentation/dme/frequencies/selected-mhz",
|
|
|
|
dme1dst : "/instrumentation/dme/indicated-distance-nm",
|
|
|
|
xpdrcod : "/instrumentation/transponder/id-code",
|
|
|
|
// weather
|
|
|
|
"ac-wdir" : "/environment/wind-from-heading-deg",
|
|
|
|
"ac-wspd" : "/environment/wind-speed-kt",
|
|
|
|
"ac-visi" : "/environment/visibility-m",
|
|
|
|
"ac-temp" : "/environment/temperature-degc",
|
|
|
|
"ac-dewp" : "/environment/dewpoint-degc",
|
|
|
|
"gnd-wdir" : "/environment/config/boundary/entry/wind-from-heading-deg",
|
|
|
|
"gnd-wspd" : "/environment/config/boundary/entry/wind-speed-kt",
|
|
|
|
"gnd-visi" : "/environment/config/boundary/entry/visibility-m",
|
|
|
|
"gnd-temp" : "/environment/config/boundary/entry/temperature-degc",
|
|
|
|
"gnd-dewp" : "/environment/config/boundary/entry/dewpoint-degc",
|
|
|
|
"metar-valid" : "/environment/metar/valid",
|
|
|
|
});
|
2015-01-25 12:02:20 +00:00
|
|
|
|
2016-01-13 12:59:01 +00:00
|
|
|
function PhiViewModel(topics) {
|
2015-01-25 12:02:20 +00:00
|
|
|
var self = this;
|
|
|
|
self.widgets = ko.observableArray([
|
2015-03-15 10:46:25 +00:00
|
|
|
"METAR", "PFD", "Radiostack", "Small Map", "Stopwatch"
|
2015-01-25 12:02:20 +00:00
|
|
|
]);
|
|
|
|
|
2016-01-13 12:59:01 +00:00
|
|
|
self.topics = topics;
|
2015-01-25 12:02:20 +00:00
|
|
|
|
|
|
|
self.selectedTopic = ko.observable();
|
2015-03-04 11:16:17 +00:00
|
|
|
self.selectedSubtopic = ko.observable();
|
2015-01-25 12:02:20 +00:00
|
|
|
|
|
|
|
self.selectTopic = function(topic) {
|
2015-03-04 11:16:17 +00:00
|
|
|
location.hash = topic;
|
2015-01-25 12:02:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-22 20:18:23 +00:00
|
|
|
self.refresh = function() {
|
|
|
|
location.reload();
|
|
|
|
}
|
2015-03-04 11:16:17 +00:00
|
|
|
|
2015-03-14 21:31:31 +00:00
|
|
|
self.doPause = function() {
|
|
|
|
fgcommand.pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
self.doUnpause = function() {
|
|
|
|
fgcommand.unpause();
|
|
|
|
}
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
jquery("#widgetarea").sortable({
|
2015-09-27 18:57:41 +00:00
|
|
|
handle : ".widget-handle",
|
|
|
|
axis : "y",
|
|
|
|
cursor : "move",
|
2015-03-15 10:46:25 +00:00
|
|
|
});
|
2015-09-27 18:57:41 +00:00
|
|
|
// jquery("#widgetarea").disableSelection();
|
2015-03-15 10:46:25 +00:00
|
|
|
|
2015-03-04 11:16:17 +00:00
|
|
|
// Client-side routes
|
|
|
|
Sammy(function() {
|
|
|
|
this.get('#:topic', function() {
|
2015-09-27 18:57:41 +00:00
|
|
|
self.selectedTopic(this.params.topic);
|
2015-03-04 11:16:17 +00:00
|
|
|
self.selectedSubtopic('');
|
|
|
|
});
|
|
|
|
|
|
|
|
this.get('#:topic/:subtopic', function() {
|
2015-09-27 18:57:41 +00:00
|
|
|
self.selectedTopic(this.params.topic);
|
|
|
|
self.selectedSubtopic(this.params.subtopic);
|
2015-03-04 11:16:17 +00:00
|
|
|
});
|
|
|
|
// empty route
|
|
|
|
this.get('', function() {
|
2015-09-27 18:57:41 +00:00
|
|
|
this.app.runRoute('get', '#' + self.topics[0]);
|
2015-03-04 11:16:17 +00:00
|
|
|
});
|
|
|
|
}).run();
|
2015-03-14 21:31:31 +00:00
|
|
|
|
2015-01-25 12:02:20 +00:00
|
|
|
}
|
2015-03-14 21:31:31 +00:00
|
|
|
ko.components.register('sidebarwidget', {
|
|
|
|
require : 'widgets/sidebarwidget'
|
|
|
|
});
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
ko.components.register('Small Map', {
|
2015-01-25 12:02:20 +00:00
|
|
|
require : 'widgets/map'
|
|
|
|
});
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
ko.components.register('Radiostack', {
|
2015-01-25 12:02:20 +00:00
|
|
|
require : 'widgets/radiostack'
|
|
|
|
});
|
|
|
|
|
2015-07-30 19:03:06 +00:00
|
|
|
ko.components.register('AircraftMarker', {
|
|
|
|
require : 'widgets/AircraftMarker'
|
|
|
|
});
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
ko.components.register('METAR', {
|
2015-03-05 13:58:48 +00:00
|
|
|
require : 'widgets/metar'
|
|
|
|
});
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
ko.components.register('PFD', {
|
2015-01-25 12:02:20 +00:00
|
|
|
require : 'widgets/efis'
|
|
|
|
});
|
|
|
|
|
2015-03-15 10:46:25 +00:00
|
|
|
ko.components.register('Stopwatch', {
|
2015-02-18 11:31:00 +00:00
|
|
|
require : 'widgets/Stopwatch'
|
|
|
|
});
|
2015-09-27 18:57:41 +00:00
|
|
|
|
2015-03-20 11:02:12 +00:00
|
|
|
ko.components.register('dualarcgauge', {
|
2015-09-27 18:57:41 +00:00
|
|
|
require : 'instruments/DualArcGauge'
|
2015-03-20 11:02:12 +00:00
|
|
|
})
|
2015-02-18 11:31:00 +00:00
|
|
|
|
2015-03-01 17:22:56 +00:00
|
|
|
ko.bindingHandlers.flotchart = {
|
|
|
|
init : function(element, valueAccessor, allBindings) {
|
|
|
|
// This will be called when the binding is first applied to an
|
|
|
|
// element
|
|
|
|
// Set up any initial state, event handlers, etc. here
|
|
|
|
var value = valueAccessor() || {};
|
|
|
|
|
|
|
|
if (value.hover && typeof (value.hover) === 'function') {
|
2015-04-15 09:17:12 +00:00
|
|
|
jquery(element).bind("plothover", function(event, pos, item) {
|
|
|
|
value.hover.call(jquery(this).data("flotplot"), pos, item);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (value.click && typeof (value.click) === 'function') {
|
|
|
|
jquery(element).bind("plotclick", function(event, pos, item) {
|
|
|
|
value.click.call(jquery(this).data("flotplot"), pos, item);
|
2015-03-01 17:22:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
update : function(element, valueAccessor, allBindings) {
|
|
|
|
var value = valueAccessor() || {};
|
2015-03-02 14:48:09 +00:00
|
|
|
var data = ko.unwrap(value.data);
|
|
|
|
var options = ko.unwrap(value.options);
|
2015-04-15 09:17:12 +00:00
|
|
|
var plot = jquery.plot(element, data, options);
|
2015-09-27 18:57:41 +00:00
|
|
|
jquery(element).data("flotplot", plot);
|
2015-04-15 09:17:12 +00:00
|
|
|
var postUpdate = ko.unwrap(value.postUpdate);
|
2015-09-27 18:57:41 +00:00
|
|
|
if (postUpdate) {
|
|
|
|
postUpdate.call(value, element);
|
2015-04-15 09:17:12 +00:00
|
|
|
}
|
2015-03-01 17:22:56 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-01-13 12:59:01 +00:00
|
|
|
jquery.get('/config.json', null, function(config) {
|
|
|
|
|
2016-01-19 08:44:04 +00:00
|
|
|
var userConfig = {}
|
2016-01-13 17:16:15 +00:00
|
|
|
// merge user config into global config
|
2016-01-19 08:44:04 +00:00
|
|
|
var jqxhr = jquery.get('/fg-home/Phi/config.json', null, function(data) {
|
|
|
|
userConfig = data;
|
|
|
|
}).always(function(){
|
2016-01-13 17:16:15 +00:00
|
|
|
for ( var p in userConfig.plugins ) {
|
|
|
|
config.plugins[p] = userConfig.plugins[p];
|
|
|
|
}
|
|
|
|
|
2016-01-13 12:59:01 +00:00
|
|
|
var topics = [];
|
|
|
|
if (config && config.plugins ) {
|
|
|
|
for ( var p in config.plugins ) {
|
|
|
|
var plugin = config.plugins[p];
|
2016-01-13 17:16:15 +00:00
|
|
|
if (plugin.component) {
|
|
|
|
if (false == ko.components.isRegistered(p)) {
|
|
|
|
ko.components.register(p, { require: plugin.component });
|
2016-01-13 12:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
topics.push(p);
|
|
|
|
}
|
|
|
|
}
|
2016-01-13 17:16:15 +00:00
|
|
|
|
|
|
|
topics.sort(function(a,b) {
|
|
|
|
indexa = config.plugins[a].index || 0;
|
|
|
|
indexb = config.plugins[b].index || 0;
|
|
|
|
return indexa - indexb;
|
|
|
|
});
|
2016-01-13 12:59:01 +00:00
|
|
|
ko.applyBindings(new PhiViewModel(topics), document.getElementById('wrapper'));
|
2016-01-13 17:16:15 +00:00
|
|
|
});
|
2016-01-13 12:59:01 +00:00
|
|
|
});
|
|
|
|
|
2015-09-27 18:57:41 +00:00
|
|
|
|
|
|
|
jquery("#toolbar").click(function() {
|
|
|
|
jquery("#content").animate({
|
|
|
|
top : 0
|
|
|
|
}, 1000, null, function() {
|
|
|
|
jquery(".htabs").css('background', '#427EBF url("images/FI_logo.svg") no-repeat scroll left center');
|
|
|
|
});
|
|
|
|
jquery("#widgetarea").animate({
|
|
|
|
top : 29
|
|
|
|
}, 1000);
|
|
|
|
});
|
2015-02-07 22:16:34 +00:00
|
|
|
|
2015-01-25 12:02:20 +00:00
|
|
|
});
|