Phi: nicer station id popup
[fg:fgdata.git] / webgui / widgets / radiostack.js
1 define([
2         'knockout', 'text!./radiostack.html', 'kojqui/tooltip'
3 ], function(ko, htmlString) {
4
5     function DualFrequencyViewModel(label, pfx) {
6         var self = this;
7         self.useKey = pfx + "use";
8         self.sbyKey = pfx + "sby";
9         self.stnKey = pfx + "stn";
10
11         self.label = ko.observable(label);
12         self.use = ko.observable(188.888).extend({
13             fgprop : self.useKey
14         });
15         
16         self.stby = ko.observable(188.888).extend({
17             fgprop : self.sbyKey
18         });
19
20         self.stn = ko.observable("").extend({
21             fgprop : self.stnKey
22         });
23
24         self.swap = function() {
25             ko.utils.knockprops.write(self.useKey, this.stby());
26             ko.utils.knockprops.write(self.sbyKey, this.use());
27         };
28     }
29
30     function ViewModel(params) {
31         this.radios = ko.observableArray([
32                 new DualFrequencyViewModel("COM1", "com1"), new DualFrequencyViewModel("COM2", "com2"),
33                 new DualFrequencyViewModel("NAV1", "nav1"), new DualFrequencyViewModel("NAV2", "nav2"),
34                 new DualFrequencyViewModel("ADF", "adf1"), 
35         ]);
36
37     }
38
39     // Return component definition
40     return {
41         viewModel : ViewModel,
42         template : htmlString
43     };
44 });