image/w/js/webui.js

branch
novnc
changeset 41
7639cfa6aec0
parent 40
71e06f6d80fd
child 42
c6a1a6ca5437
equal deleted inserted replaced
40:71e06f6d80fd 41:7639cfa6aec0
6 6
7 var BBScreen={ 7 var BBScreen={
8 8
9 Screen: -1, 9 Screen: -1,
10 setScreen: function(s){ 10 setScreen: function(s){
11 console.log("Screen:"+s); 11 Screen = parseInt(s,10);
12 switch (s) { 12 console.log("Screen:"+Screen);
13 case '0': 13 switch (Screen) {
14 case '100': 14 case 0: $("#mltline").show();
15 case '101': 15 $("#mlt_table").show();
16 case '102': 16 $("#but00").text('Hand');
17 case '103': 17 $("#but20").text('Auto');
18 case '104': 18 $("#mlt00").show();
19 case '105': 19 $("#mlt20").show();
20 case '106': 20 $("#mlt01").hide();
21 case '107': 21 $("#mlt21").hide();
22 case '201': 22 $("#midline").show();
23 $("#mltline").show(); 23 $("#mid00").hide();
24 //$("#mlt01").hide(); 24 $("#mid20").hide();
25 $("#hltline").show();
26 $("#hlt_table").show();
27 $("#hlt00").hide();
28 $("#hlt20").hide();
29 $("#hlt01").show();
30 $("#hlt21").show();
31 $("#hlt01").css("background-color", "#e7e7e7");
32 $("#hlt01").css("color", "black");
33 $("#but04").text('Info');
34 $("#but24").text('Tools');
35 $("#row_info").hide();
36 $("#prompt").hide();
37 break;
38 case 2: $("#mltline").hide();
39 $("#midline").hide();
40 $("#hltline").hide();
41 $("#row_info").show();
42 $("#prompt").hide();
43 break;
44 // case 21: Automaat show recipe and Stop / Start
45 // Prompt
46 // Prompt
47 case 100:
48 case 101:
49 case 102:
50 case 103:
51 case 104:
52 case 105:
53 case 106:
54 case 107: $("#mltline").show();
55 $("#but00").text('+sp');
56 $("#but20").text('-sp');
25 $("#midline").show(); 57 $("#midline").show();
26 $("#hltline").show(); 58 $("#hltline").show();
59 $("#hlt01").hide();
60 $("#hlt21").hide();
27 $("#row_info").hide(); 61 $("#row_info").hide();
28 console.log("this is 0"); 62 $("#prompt").hide();
29 break; 63 break;
30 case '108': $("#mltline").show(); // to boil 64 case 108: $("#mltline").show(); // to boil
31 $("#midline").hide(); 65 $("#midline").hide();
32 $("#hltline").hide(); 66 $("#hltline").hide();
33 break; 67 $("#prompt").hide();
34 case '109': $("#mltline").show(); // boil 68 break;
69 case 109: $("#mltline").show(); // boil
35 $("#midline").show(); 70 $("#midline").show();
36 $("#hltline").hide(); 71 $("#hltline").hide();
37 break; 72 $("#prompt").hide();
38 case '2': $("#mltline").hide(); 73 break;
74 case 200: $("#mltline").hide();
39 $("#midline").hide(); 75 $("#midline").hide();
40 $("#hltline").hide(); 76 $("#hltline").hide();
41 $("#row_info").show(); 77 $("#row_info").hide();
42 console.log("this is 2"); 78 $("#prompt").show();
43 break; 79 break;
80 case 201: $("#mltline").show();
81 $("#mlt00").hide();
82 $("#mlt20").hide();
83 $("#mlt01").hide();
84 $("#mlt21").hide();
85 $("#mlt_table").hide();
86 $("#but00").text('+sp');
87 $("#but20").text('-sp');
88 $("#but01").text('Pomp');
89 $("#but21").text('Aan');
90 $("#midline").show();
91 $("#mid00").hide();
92 $("#mid20").hide();
93 $("#hltline").show();
94 $("#hlt00").hide();
95 $("#hlt20").hide();
96 $("#hlt21").hide();
97 $("#hlt_table").hide();
98 $("#but03").text('+sp');
99 $("#but23").text('-sp');
100 $("#but04").text('Stop');
101 $("#but24").text('Aan');
102 $("#hlt01").css("background-color", "#575757");
103 $("#hlt01").css("color", "white");
104 $("#row_info").hide();
105 $("#prompt").hide();
106 break;
44 default: $("#mltline").hide(); 107 default: $("#mltline").hide();
45 $("#midline").hide(); 108 $("#midline").hide();
46 $("#hltline").hide(); 109 $("#hltline").hide();
47 console.log("this is default"); 110 $("#prompt").hide();
111 console.log("this is default screen "+Screen);
48 break; 112 break;
49 } 113 }
50 }, 114 },
51 MLT_pv: function(s) { 115 MLT_pv: function(s) {
52 $("#mlt_pv").text(s); 116 $("#mlt_pv").text(s);
53 }, 117 },
54 MLT_sp: function(s) { 118 MLT_sp: function(s) {
55 $("#mlt_sp").text(s); 119 $("#mlt_sp").text(s);
120 if (Screen == 201) {
121 if (s != "") {
122 $("#mlt00").show();
123 $("#mlt20").show();
124 $("#mlt01").show();
125 $("#mlt21").show();
126 $("#mlt_table").show();
127 }
128 }
56 }, 129 },
57 MLT_power: function(s) { 130 MLT_power: function(s) {
58 $("#mlt_power").text(s); 131 $("#mlt_power").text(s);
59 }, 132 },
60 MLT_led: function(s) { 133 MLT_led: function(s) {
72 HLT_pv: function(s) { 145 HLT_pv: function(s) {
73 $("#hlt_pv").text(s); 146 $("#hlt_pv").text(s);
74 }, 147 },
75 HLT_sp: function(s) { 148 HLT_sp: function(s) {
76 $("#hlt_sp").text(s); 149 $("#hlt_sp").text(s);
150 if (Screen == 201) {
151 if (s != "") {
152 $("#hlt00").show();
153 $("#hlt20").show();
154 $("#hlt21").show();
155 $("#hlt_table").show();
156 }
157 }
77 }, 158 },
78 HLT_power: function(s) { 159 HLT_power: function(s) {
79 $("#hlt_power").text(s); 160 $("#hlt_power").text(s);
80 }, 161 },
81 HLT_led: function(s) { 162 HLT_led: function(s) {
144 } 225 }
145 }; 226 };
146 227
147 228
148 function sendTouch(x, y) { 229 function sendTouch(x, y) {
149 websocket.send('{"touch":{"x":"'+x+'","y":"'+y+'"}}'); 230 websocket.send('{"touch":{"x":'+x+',"y":'+y+'}}');
150 console.log('Sent {"touch":{"x":"'+x+'","y":"'+y+'"}}'); 231 console.log('Sent {"touch":{"x":'+x+',"y":'+y+'}}');
151 } 232 }
152 233
153 234
154 /* Define keys in the screens and their actions. */ 235 /* Define keys in the screens and their actions. */
155 $("#ok_info").click( function() { sendTouch(160,220); }); 236 $("#ok_info").click( function() { sendTouch(160,220); });
237 $("#mlt00").click( function() { sendTouch( 35, 46); });
238 $("#mlt20").click( function() { sendTouch(285, 46); });
239 $("#mlt01").click( function() { sendTouch( 35, 96); });
240 $("#mlt21").click( function() { sendTouch(285, 96); });
241 $("#mid00").click( function() { sendTouch( 35,140); });
242 $("#mid20").click( function() { sendTouch(285,140); });
243 $("#hlt00").click( function() { sendTouch( 35,170); });
244 $("#hlt20").click( function() { sendTouch(285,170); });
245 $("#hlt01").click( function() { sendTouch( 35,220); });
246 $("#hlt21").click( function() { sendTouch(285,220); });
247 $("#button_ja").click( function() { sendTouch( 80,120); });
248 $("#button_nee").click( function() { sendTouch(240,120); });
156 249
157 250
158 websocket.onopen = function(evt) { 251 websocket.onopen = function(evt) {
159 console.log('WebSocket connection opened'); 252 console.log('WebSocket connection opened');
160 document.getElementById("test").innerHTML = "WebSocket is connected!"; 253 document.getElementById("test").innerHTML = "WebSocket is connected!";

mercurial