Overhauled radio webgui: use websockets and fgcommands
[fg:toms-fgdata.git] / Docs / gui / radio.js
1 $(document).ready(
2     function() {
3
4       var rp = new Array();
5       rp["#com1u"] = "/instrumentation/comm/frequencies/selected-mhz";
6       rp["#com1s"] = "/instrumentation/comm/frequencies/standby-mhz";
7       rp["#nav1u"] = "/instrumentation/nav/frequencies/selected-mhz";
8       rp["#nav1s"] = "/instrumentation/nav/frequencies/standby-mhz";
9       rp["#com2u"] = "/instrumentation/comm[1]/frequencies/selected-mhz";
10       rp["#com2s"] = "/instrumentation/comm[1]/frequencies/standby-mhz";
11       rp["#nav2u"] = "/instrumentation/nav[1]/frequencies/selected-mhz";
12       rp["#nav2s"] = "/instrumentation/nav[1]/frequencies/standby-mhz";
13       rp["#adf1u"] = "/instrumentation/adf/frequencies/selected-khz";
14       rp["#adf1s"] = "/instrumentation/adf/frequencies/standby-khz";
15       rp["#dme1u"] = "/instrumentation/dme/frequencies/selected-mhz";
16
17       $("#com1u").change(function(o) {
18         fgCommand.propertyAssign(rp["#com1u"], $("#com1u").val());
19       });
20       $("#com1s").change(function(o) {
21         fgCommand.propertyAssign(rp["#com1s"], $("#com1s").val());
22       });
23       $("#nav1u").change(function(o) {
24         fgCommand.propertyAssign(rp["#nav1u"], $("#nav1u").val());
25       });
26       $("#nav1s").change(function(o) {
27         fgCommand.propertyAssign(rp["#nav1s"], $("#nav1s").val());
28       });
29       $("#com2u").change(function(o) {
30         fgCommand.propertyAssign(rp["#com2u"], $("#com2u").val());
31       });
32       $("#com2s").change(function(o) {
33         fgCommand.propertyAssign(rp["#com2s"], $("#com2s").val());
34       });
35       $("#nav2u").change(function(o) {
36         fgCommand.propertyAssign(rp["#nav2u"], $("#nav2u").val());
37       });
38       $("#nav2s").change(function(o) {
39         fgCommand.propertyAssign(rp["#nav2s"], $("#nav2s").val());
40       });
41       $("#adf1u").change(function(o) {
42         fgCommand.propertyAssign(rp["#adf1u"], $("#adf1u").val());
43       });
44       $("#adf1s").change(function(o) {
45         fgCommand.propertyAssign(rp["#adf1s"], $("#adf1s").val());
46       });
47       $("#dme1u").change(function(o) {
48         fgCommand.propertyAssign(rp["#dme1u"], $("#dme1u").val());
49       });
50
51       $("#com1swap").click(function() {
52         fgCommand.propertySwap(rp["#com1u"], rp["#com1s"]);
53       });
54       $("#nav1swap").click(function() {
55         fgCommand.propertySwap(rp["#nav1u"], rp["#nav1s"]);
56       });
57       $("#com2swap").click(function() {
58         fgCommand.propertySwap(rp["#com2u"], rp["#com2s"]);
59       });
60       $("#nav2swap").click(function() {
61         fgCommand.propertySwap(rp["#nav2u"], rp["#nav2s"]);
62       });
63       $("#adf1swap").click(function() {
64         fgCommand.propertySwap(rp["#adf1u"], rp["#adf1s"]);
65       });
66
67       PropertyChangeListener(function() {
68         SetListener( rp["#com1u"], function(n) {
69           $("#com1u").val( n.value );
70         });
71         SetListener( rp["#com1s"], function(n) {
72           $("#com1s").val( n.value );
73         });
74         SetListener( rp["#nav1u"], function(n) {
75           $("#nav1u").val( n.value );
76         });
77         SetListener( rp["#nav1s"], function(n) {
78           $("#nav1s").val( n.value );
79         });
80         SetListener( rp["#com2u"], function(n) {
81           $("#com2u").val( n.value );
82         });
83         SetListener( rp["#com2s"], function(n) {
84           $("#com2s").val( n.value );
85         });
86         SetListener( rp["#nav2u"], function(n) {
87           $("#nav2u").val( n.value );
88         });
89         SetListener( rp["#nav2s"], function(n) {
90           $("#nav2s").val( n.value );
91         });
92         SetListener( rp["#adf1u"], function(n) {
93           $("#adf1u").val( n.value );
94         });
95         SetListener( rp["#adf1s"], function(n) {
96           $("#adf1s").val( n.value );
97         });
98         SetListener( rp["#dme1u"], function(n) {
99           $("#dme1u").val( n.value );
100         });
101       });
102 });