Phi initial commit
[fg:fgdata.git] / webgui / widgets / radiostack.js
1 define([
2         'knockout', 'text!./radiostack.html'
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
10         self.label = ko.observable(label);
11         self.use = ko.observable(188.888).extend({
12             fgprop : self.useKey
13         });
14         
15         self.stby = ko.observable(188.888).extend({
16             fgprop : self.sbyKey
17         });
18
19         self.swap = function() {
20             ko.utils.knockprops.write(self.useKey, this.stby());
21             ko.utils.knockprops.write(self.sbyKey, this.use());
22         };
23     }
24
25     function ViewModel(params) {
26         this.radios = ko.observableArray([
27                 new DualFrequencyViewModel("COM1", "com1"), new DualFrequencyViewModel("COM2", "com2"),
28                 new DualFrequencyViewModel("NAV1", "nav1"), new DualFrequencyViewModel("NAV2", "nav2"),
29         ]);
30
31     }
32
33     // Return component definition
34     return {
35         viewModel : ViewModel,
36         template : htmlString
37     };
38 });