-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote_control.js
221 lines (191 loc) · 6.51 KB
/
remote_control.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*Classe Controle:*/
function RemoteControl(player, divId, p_areaPowerEject, p_areaNumbers, p_areaVolumeChannel, p_areaInteractive, p_areaColorful, p_areaMultimedia)
{
this.player = player;
this.divId = divId;
this.p_areaPowerEject = p_areaPowerEject;
this.p_areaNumbers = p_areaNumbers;
this.p_areaVolumeChannel = p_areaVolumeChannel;
this.p_areaInteractive = p_areaInteractive;
this.p_areaColorful = p_areaColorful;
this.p_areaMultimedia = p_areaMultimedia;
//flags para controle visual de cada área
var controlPowerEject = 0;
var controlNumbers = 0;
var controlVolumeChannel = 0;
var controlInteractive = 0;
var controlColorful = 0;
var controlMultimedia = 0;
//Ao criar um objeto Controle todas as áreas e botőes serăo criados...
document.getElementById(this.divId).innerHTML = "<div id='areaSpace1'>"+
"</div>"+
"<div id='areaPowerEject'>"+
"<div id='ButtonPower'>"+
"</div>"+
"<div id='ButtonEject'>"+
"</div>"+
"</div>"+
"<div id='areaSpace2'>"+
"</div>"+
"<div id='areaNumbers'>"+
"<div id='ButtonKey_1'>"+
"</div>"+
"<div id='ButtonKey_2'>"+
"</div>"+
"<div id='ButtonKey_3'>"+
"</div>"+
"<div id='ButtonKey_4'>"+
"</div>"+
"<div id='ButtonKey_5'>"+
"</div>"+
"<div id='ButtonKey_6'>"+
"</div>"+
"<div id='ButtonKey_7'>"+
"</div>"+
"<div id='ButtonKey_8'>"+
"</div>"+
"<div id='ButtonKey_9'>"+
"</div>"+
"<div id='ButtonKey_Hash'>"+
"</div>"+
"<div id='ButtonKey_0'>"+
"</div>"+
"<div id='ButtonKey_Star'>"+
"</div>"+
"</div>"+
"<div id='areaSpace3'>"+
"</div>"+
"<div id='areaVolumeChannel'>"+
"<div id='ButtonVolume_Up'>"+
"</div>"+
"<div id='ButtonVolume_Down'>"+
"</div>"+
"<div id='ButtonChannel_Up'>"+
"</div>"+
"<div id='ButtonChannel_Down'>"+
"</div>"+
"<div id='ButtonMenu'>"+
"</div>"+
"<div id='ButtonMute'>"+
"</div>"+
"<div id='ButtonHelp'>"+
"</div>"+
"</div>"+
"<div id='areaSpace4'>"+
"</div>"+
"<div id='areaInteractive'>"+
"<div id='ButtonCursor_Up'>"+
"</div>"+
"<div id='ButtonCursor_Down'>"+
"</div>"+
"<div id='ButtonCursor_Left'>"+
"</div>"+
"<div id='ButtonCursor_Right'>"+
"</div>"+
"<div id='ButtonEnter'>"+
"</div>"+
"<div id='ButtonInfo'>"+
"</div>"+
"<div id='ButtonGuide'>"+
"</div>"+
"<div id='ButtonBack'>"+
"</div>"+
"<div id='ButtonExit'>"+
"</div>"+
"</div>"+
"<div id='areaSpace5'>"+
"</div>"+
"<div id='areaColorful'>"+
"<div id='ButtonRed'>"+
"</div>"+
"<div id='ButtonGreen'>"+
"</div>"+
"<div id='ButtonYellow'>"+
"</div>"+
"<div id='ButtonBlue'>"+
"</div>"+
"</div>"+
"<div id='areaSpace6'>"+
"</div>"+
"<div id='areaMultimedia'>"+
"<div id='ButtonRewind'>"+
"</div>"+
"<div id='ButtonPlay'>"+
"</div>"+
"<div id='ButtonForward'>"+
"</div>"+
"<div id='ButtonRecord'>"+
"</div>"+
"<div id='ButtonPause'>"+
"</div>"+
"<div id='ButtonStop'>"+
"</div>"+
"</div>"+
"<div id='areaSpace7'>"+
"</div>"+
"<div id='areaLogo'>"+
"<img src='img_control/logo.png' width='100%' height='100%' />"+
"</div>"+
"<div id='areaSpace8'>"+
"</div>";
//... porém iniciarăo todos escondidos:
$('#areaSpace1').hide();
$('#areaPowerEject').hide();
$('#areaSpace2').hide();
$('#areaNumbers').hide();
$('#areaSpace3').hide();
$('#areaVolumeChannel').hide();
$('#areaSpace4').hide();
$('#areaInteractive').hide();
$('#areaSpace5').hide();
$('#areaColorful').hide();
$('#areaSpace6').hide();
$('#areaMultimedia').hide();
$('#areaSpace7').hide();
$('#areaLogo').hide();
$('#areaSpace8').hide();
//e finalmente haverá o tratamento correto para inicializaçăo das áreas:
this.setAreas();
//Pressionando o botăo quando hover (Chamada da Funçăo apropriada para o botăo)
var imgButtons = ['Eject', 'Power', 'Key_1', 'Key_2', 'Key_3', 'Key_4', 'Key_5', 'Key_6', 'Key_7', 'Key_8', 'Key_9', 'Key_Hash', 'Key_0', 'Key_Star', 'Volume_Up', 'Channel_Up', 'Volume_Down', 'Channel_Down', 'Menu', 'Mute', 'Help', 'Info','Guide', 'Exit', 'Back', 'Enter', 'Cursor_Up', 'Cursor_Down', 'Cursor_Left', 'Cursor_Right', 'Red', 'Green', 'Yellow', 'Blue', 'Rewind', 'Play', 'Forward', 'Pause', 'Record', 'Stop'];
for(button in imgButtons){
eval("$('#Button' + imgButtons[button]).click($.proxy(function(){"+
"this.functionButton('"+ imgButtons[button].toUpperCase() + "');" +
"},this));"
);
}
}
//Habilita as áreas pré-definidas pelo criador do controle:
RemoteControl.prototype.setAreas = function(){
var areas = ['PowerEject', 'Numbers', 'VolumeChannel', 'Interactive', 'Colorful', 'Multimedia'];
for (area in areas){
if(this['p_area'+areas[area]])
this['setArea'+areas[area]]();
}
}
//Chamada da funçăo específica de cada botăo
RemoteControl.prototype.functionButton = function(b){
this.player.keyPress(b);
}
//Para habilitar/desabilitar as áreas
var areas = ['PowerEject', 'Numbers', 'VolumeChannel', 'Interactive', 'Colorful', 'Multimedia'];
for(area in areas){
eval("RemoteControl.prototype['setArea" +areas[area]+ "'] = function(){"+
//sinaliza a flag de controle da área
"this['control" +areas[area]+ "'] = !(this['control" +areas[area]+ "']);"+
//a área sempre será visualizada juntamente com o seu espaçamento acima
"$('#areaSpace"+(area+1)+"').toggle();"+
"$('#area" +areas[area]+ "').toggle();"+
//o último espaçamento e os logos serăo visíveis enquanto qualquer outra área for visível:
"if((this.controlPowerEject)||(this.controlNumbers)||(this.controlVolumeChannel)||(this.controlInteractive)||(this.controlColorful)||(this.controlMultimedia)){"+
"$('#areaSpace7').show();"+
"$('#areaLogo').show();"+
"$('#areaSpace8').show();"+
"}"+
"else{ "+
"$('#areaSpace7').hide();"+
"$('#areaLogo').hide();"+
"$('#areaSpace8').hide();"+
"}"+
"}");
}