Statistics
| Branch: | Revision:

blinker / firefox.plugin / data / scripts / actions / actions.js @ master

History | View | Annotate | Download (13.518 KB)

1 76dd22bd KevinTaron
/*
2
 * Copyright 2015 Thies Pfeiffer and Dimitri Heil and Kevin Taron
3
 * Blinker is distributed under the terms of the GNU General Public License
4
 * 
5
 * This file is part of Blinker.
6
 * 
7
 * Blinker is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 * 
12
 * Blinker is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with Blinker. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
function getActionElements(element) {
22
        var elementType = $(element).get(0).tagName;
23
        var elementAttr = $(element).attr('type');
24
25
        switch(elementType) {
26
                case "BUTTON":
27
                        return getItemsForButton(element);
28
                case "A":
29
                        return getItemsForLink(element);
30
                case "INPUT":
31
                        if(elementAttr == "submit" || elementAttr == "reset") {
32
                                return getItemsForButton(element);
33
                        } else {
34
                                console.log("ERROR MESSAGE: elementAttr for INPUT not found - " + elementAttr);
35
                                return null;
36
                        }
37
                case "AUDIO":
38
                        return getItemsForAudio(element);
39
                case "VIDEO":
40
                        return getItemsForVideo(element);
41
            default:
42
                console.log("ERROR MESSAGE: elementType not found - " + elementType);
43
                    return getItemsForButton(element);
44
        }
45
}
46
47
48
49
function getItemsForButton(element) {
50
        var dataValue = "Ok";
51
        var dataCancel = "Hide";
52
        var gazeCloseFunction = "closeAll()";
53
        var gazeFunction = "";
54
        var gazeFunctionAfter = "closeAll()";
55
        var gazeTarget = ".openedElement";
56
        var gazeType = "action";
57
        var gazeModel = "dwell";
58
        var isKeyboardButton = false;
59
        var gazeClass = 'gazeOk'; 
60
61
        if($(element).hasClass('ui-keyboard-button')) { isKeyboardButton = true; gazeClass = 'gazeOk gazeKeyBoardOk' }
62
        if($(element).attr('gaze-data-value')) { dataValue = $(element).attr('gaze-data-value'); }
63
        if($(element).attr('data-gaze-function-Close')) { gazeCloseFunction = $(element).attr('data-gaze-function-Close'); }
64
        if($(element).attr('data-gaze-function-After')) { gazeFunctionAfter = $(element).attr('data-gaze-function-After'); }
65
66
        var gazeCancel = '<div class="gazeCancel" data-gaze="true"';
67
        gazeCancel += ' data-gaze-type="' + gazeType +'"'; 
68
        gazeCancel += ' data-gaze-model="' + gazeModel +'"'; 
69
        gazeCancel += ' data-gaze-target="' + gazeTarget +'"'; 
70
        gazeCancel += ' data-gaze-function="' + gazeCloseFunction +'"'; 
71
72
        gazeCancel += '>';
73
        gazeCancel += '<p>';
74
        gazeCancel += dataCancel;
75
        gazeCancel += '</p>';
76
        gazeCancel += '</div>';
77
        
78
79
        var gazeOk = '<div class="' + gazeClass +'" data-gaze="true"';
80
        gazeOk += ' data-gaze-type="' + gazeType +'"'; 
81
        gazeOk += ' data-gaze-model="' + gazeModel +'"'; 
82
        gazeOk += ' data-gaze-target="' + gazeTarget +'"'; 
83
84
        gazeOk += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
85
        gazeOk += '>';
86
        gazeOk += '<p>';
87
        gazeOk += dataValue;
88
        gazeOk += '</p>';
89
        gazeOk += '</div>';
90
91
        var myarray = [];
92
        
93
        if(isKeyboardButton) {
94
                myarray.push(gazeCancel);
95
96
                // Add the prev Keyboard Button
97
                if($(element).prev('.ui-keyboard-button').length > 0) {
98
                        $('.openedElementPrev').removeClass('openedElementPrev');
99
                        $(element).prev().addClass('openedElementPrev');
100
                        var prevButton = $(element).prev();
101
                        var prevValue = $(prevButton).attr('gaze-data-value');
102
                        var prevTarget = '.openedElementPrev';
103
104
                        var gazePrev = '<div class="' + gazeClass +'" data-gaze="true"';
105
                        gazePrev += ' data-gaze-type="' + gazeType +'"'; 
106
                        gazePrev += ' data-gaze-model="' + gazeModel +'"'; 
107
                        gazePrev += ' data-gaze-target="' + prevTarget +'"'; 
108
                        gazePrev += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
109
110
                        gazePrev += '>';
111
                        gazePrev += '<p>';
112
                        gazePrev += prevValue;
113
                        gazePrev += '</p>';
114
                        gazePrev += '</div>';
115
                        myarray.push(gazePrev);
116
                }
117
118
                // Add the watch Keyboard Button 
119
                myarray.push(gazeOk);
120
                
121
                // Add the next Keyboard Button
122
                if($(element).next('.ui-keyboard-button').length > 0) {
123
                        $('.openedElementNext').removeClass('openedElementNext');
124
                        $(element).next().addClass('openedElementNext');
125
                        var nextButton = $(element).next();
126
                        var nextValue = $(nextButton).attr('gaze-data-value');
127
                        var nextTarget = '.openedElementNext';
128
                        
129
                        var gazeNext = '<div class="' + gazeClass +'" data-gaze="true"';
130
                        gazeNext += ' data-gaze-type="' + gazeType +'"'; 
131
                        gazeNext += ' data-gaze-model="' + gazeModel +'"'; 
132
                        gazeNext += ' data-gaze-target="' + nextTarget +'"'; 
133
                        gazeNext += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
134
135
                        gazeNext += '>';
136
                        gazeNext += '<p>';
137
                        gazeNext += nextValue;
138
                        gazeNext += '</p>';
139
                        gazeNext += '</div>';
140
                        myarray.push(gazeNext);
141
                }
142
143
        } else {
144
                myarray.push(gazeCancel);
145
                myarray.push(gazeOk);
146
        }
147
 
148
149
        return myarray;
150
}
151
152
function getItemsForLink(element) {
153
        var dataValue = "Follow Link";
154
        var dataCancel = "Hide";
155
        var gazeCloseFunction = "closeAll()";
156
        var gazeFunction = "";
157
        var gazeFunctionAfter = "closeAll()";
158
        var gazeTarget = ".openedElement";
159
        var gazeType = "action";
160
        var gazeModel = "dwell";
161
        var isKeyboardButton = false;
162
        var gazeClass = 'gazeOk'; 
163
164
        if($(element).hasClass('ui-keyboard-button')) { isKeyboardButton = true; gazeClass = 'gazeOk gazeKeyBoardOk' }
165
        if($(element).attr('gaze-data-value')) { dataValue = $(element).attr('gaze-data-value'); }
166
        if($(element).attr('data-gaze-function-Close')) { gazeCloseFunction = $(element).attr('data-gaze-function-Close'); }
167
        if($(element).attr('data-gaze-function-After')) { gazeFunctionAfter = $(element).attr('data-gaze-function-After'); }
168
169
        var gazeCancel = '<div class="gazeCancel" data-gaze="true"';
170
        gazeCancel += ' data-gaze-type="' + gazeType +'"'; 
171
        gazeCancel += ' data-gaze-model="' + gazeModel +'"'; 
172
        gazeCancel += ' data-gaze-target="' + gazeTarget +'"'; 
173
        gazeCancel += ' data-gaze-function="' + gazeCloseFunction +'"'; 
174
175
        gazeCancel += '>';
176
        gazeCancel += '<p>';
177
        gazeCancel += dataCancel;
178
        gazeCancel += '</p>';
179
        gazeCancel += '</div>';
180
        
181
182
        var gazeOk = '<div class="' + gazeClass +'" data-gaze="true"';
183
        gazeOk += ' data-gaze-type="' + gazeType +'"'; 
184
        gazeOk += ' data-gaze-model="' + gazeModel +'"'; 
185
        gazeOk += ' data-gaze-target="' + gazeTarget +'"'; 
186
187
        gazeOk += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
188
        gazeOk += '>';
189
        gazeOk += '<p>';
190
        gazeOk += dataValue;
191
        gazeOk += '</p>';
192
        gazeOk += '</div>';
193
194
        var myarray = [];
195
        
196
        myarray.push(gazeCancel);
197
        myarray.push(gazeOk);
198
199
 
200
201
        return myarray;
202
}
203
204
205
function getItemsForVideo(element) {
206
        var myarray = [];
207
208
        var dataValue = "Ok";
209
        var dataCancel = "Hide";
210
        var gazeCloseFunction = "closeAll()";
211
        var gazeFunction = "";
212
        var gazeFunctionAfter = "closeAll()";
213
        var gazeTarget = ".openedElement";
214
        var gazeType = "action";
215
        var gazeModel = "dwell";
216
        var isKeyboardButton = false;
217
        var gazeClass = 'gazeOk gazeMultimedia'; 
218
219
        if($(element).attr('gaze-data-value')) { dataValue = $(element).attr('gaze-data-value'); }
220
        if($(element).attr('data-gaze-function-Close')) { gazeCloseFunction = $(element).attr('data-gaze-function-Close'); }
221
        if($(element).attr('data-gaze-function-After')) { gazeFunctionAfter = $(element).attr('data-gaze-function-After'); }
222
223
        var gazeCancel = '<div class="gazeCancel" data-gaze="true"';
224
        gazeCancel += ' data-gaze-type="' + gazeType +'"'; 
225
        gazeCancel += ' data-gaze-model="' + gazeModel +'"'; 
226
        gazeCancel += ' data-gaze-target="' + gazeTarget +'"'; 
227
        gazeCancel += ' data-gaze-function="' + gazeCloseFunction +'"'; 
228
229
        gazeCancel += '>';
230
        gazeCancel += '<p>';
231
        gazeCancel += dataCancel;
232
        gazeCancel += '</p>';
233
        gazeCancel += '</div>';
234
235
        var gazePause = '<div class="gazeMultiPause ' + gazeClass +'" data-gaze="true"';
236
        gazePause += ' data-gaze-type="' + gazeType +'"'; 
237
        gazePause += ' data-gaze-model="' + gazeModel +'"'; 
238
        gazePause += ' data-gaze-target="' + gazeTarget +'"'; 
239
240
        gazePause += ' data-gaze-function="vidpause()"'; 
241
        gazePause += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
242
        gazePause += '>';
243
        gazePause += '<p>';
244
        gazePause += 'Pause';
245
        gazePause += '</p>';
246
        gazePause += '</div>';
247
        
248
249
        var gazeOk = '<div class="gazeMultiPlay ' + gazeClass +'" data-gaze="true"';
250
        gazeOk += ' data-gaze-type="' + gazeType +'"'; 
251
        gazeOk += ' data-gaze-model="' + gazeModel +'"'; 
252
        gazeOk += ' data-gaze-target="' + gazeTarget +'"'; 
253
254
        gazeOk += ' data-gaze-function="vidplay()"'; 
255
        gazeOk += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
256
        gazeOk += '>';
257
        gazeOk += '<p>';
258
        gazeOk += dataValue;
259
        gazeOk += '</p>';
260
        gazeOk += '</div>';
261
262
        var gazeFullscreen = '<div class="gazeFullScreen ' + gazeClass +'" data-gaze="true"';
263
        gazeFullscreen += ' data-gaze-type="' + gazeType +'"'; 
264
        gazeFullscreen += ' data-gaze-model="' + gazeModel +'"'; 
265
        gazeFullscreen += ' data-gaze-function="gazeFullscreenclick()"'; 
266
        gazeFullscreen += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
267
        gazeFullscreen += '>';
268
        gazeFullscreen += '<p>';
269
        gazeFullscreen += 'Fullscreen';
270
        gazeFullscreen += '</p>';
271
        gazeFullscreen += '</div>';
272
273
        var gazeTime = '<div class="gazeMultiSkipTime ' + gazeClass +'" data-gaze="true"';
274
        gazeTime += ' data-gaze-type="' + gazeType +'"'; 
275
        gazeTime += ' data-gaze-model="' + gazeModel +'"'; 
276
        gazeTime += ' data-gaze-target="' + gazeTarget +'"'; 
277
278
        gazeTime += ' data-gaze-function="skip(10)"'; 
279
        gazeTime += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
280
        gazeTime += '>';
281
        gazeTime += '<p>';
282
        gazeTime += 'Skip';
283
        gazeTime += '</p>';
284
        gazeTime += '</div>';
285
286
        var gazeVolume = '<div class="gazeMultiVolume ' + gazeClass +'" data-gaze="true"';
287
        gazeVolume += ' data-gaze-type="' + gazeType +'"'; 
288
        gazeVolume += ' data-gaze-model="' + gazeModel +'"'; 
289
        gazeVolume += ' data-gaze-target="' + gazeTarget +'"'; 
290
291
        gazeVolume += ' data-gaze-function="vidvol(0.5)"'; 
292
        gazeVolume += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
293
        gazeVolume += '>';
294
        gazeVolume += '<p>';
295
        gazeVolume += 'Volumen';
296
        gazeVolume += '</p>';
297
        gazeVolume += '</div>';
298
299
300
        //myarray.push(gazeCancel);
301
        myarray.push(gazeVolume);
302
        myarray.push(gazePause);
303
        myarray.push(gazeOk);
304
        myarray.push(gazeTime);
305
        myarray.push(gazeFullscreen);
306
307
        return myarray;
308
}
309
310
function getItemsForAudio(element) {
311
        var myarray = [];
312
313
        var dataValue = "Ok";
314
        var dataCancel = "Hide";
315
        var gazeCloseFunction = "closeAll()";
316
        var gazeFunction = "";
317
        var gazeFunctionAfter = "closeAll()";
318
        var gazeTarget = ".openedElement";
319
        var gazeType = "action";
320
        var gazeModel = "dwell";
321
        var isKeyboardButton = false;
322
        var gazeClass = 'gazeOk gazeMultimedia'; 
323
324
        if($(element).attr('gaze-data-value')) { dataValue = $(element).attr('gaze-data-value'); }
325
        if($(element).attr('data-gaze-function-Close')) { gazeCloseFunction = $(element).attr('data-gaze-function-Close'); }
326
        if($(element).attr('data-gaze-function-After')) { gazeFunctionAfter = $(element).attr('data-gaze-function-After'); }
327
328
        var gazeCancel = '<div class="gazeCancel" data-gaze="true"';
329
        gazeCancel += ' data-gaze-type="' + gazeType +'"'; 
330
        gazeCancel += ' data-gaze-model="' + gazeModel +'"'; 
331
        gazeCancel += ' data-gaze-target="' + gazeTarget +'"'; 
332
        gazeCancel += ' data-gaze-function="' + gazeCloseFunction +'"'; 
333
334
        gazeCancel += '>';
335
        gazeCancel += '<p>';
336
        gazeCancel += dataCancel;
337
        gazeCancel += '</p>';
338
        gazeCancel += '</div>';
339
340
        var gazePause = '<div class="gazeMultiPause ' + gazeClass +'" data-gaze="true"';
341
        gazePause += ' data-gaze-type="' + gazeType +'"'; 
342
        gazePause += ' data-gaze-model="' + gazeModel +'"'; 
343
        gazePause += ' data-gaze-target="' + gazeTarget +'"'; 
344
345
        gazePause += ' data-gaze-function="audpause()"'; 
346
        gazePause += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
347
        gazePause += '>';
348
        gazePause += '<p>';
349
        gazePause += 'Pause';
350
        gazePause += '</p>';
351
        gazePause += '</div>';
352
        
353
354
        var gazeOk = '<div class="gazeMultiPlay ' + gazeClass +'" data-gaze="true"';
355
        gazeOk += ' data-gaze-type="' + gazeType +'"'; 
356
        gazeOk += ' data-gaze-model="' + gazeModel +'"'; 
357
        gazeOk += ' data-gaze-target="' + gazeTarget +'"'; 
358
359
        gazeOk += ' data-gaze-function="audplay()"'; 
360
        gazeOk += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
361
        gazeOk += '>';
362
        gazeOk += '<p>';
363
        gazeOk += dataValue;
364
        gazeOk += '</p>';
365
        gazeOk += '</div>';
366
367
        var gazeTime = '<div class="gazeMultiSkipTime ' + gazeClass +'" data-gaze="true"';
368
        gazeTime += ' data-gaze-type="' + gazeType +'"'; 
369
        gazeTime += ' data-gaze-model="' + gazeModel +'"'; 
370
        gazeTime += ' data-gaze-target="' + gazeTarget +'"'; 
371
372
        gazeTime += ' data-gaze-function="audskip(10)"'; 
373
        gazeTime += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
374
        gazeTime += '>';
375
        gazeTime += '<p>';
376
        gazeTime += 'Skip';
377
        gazeTime += '</p>';
378
        gazeTime += '</div>';
379
380
        var gazeVolume = '<div class="gazeMultiVolume ' + gazeClass +'" data-gaze="true"';
381
        gazeVolume += ' data-gaze-type="' + gazeType +'"'; 
382
        gazeVolume += ' data-gaze-model="' + gazeModel +'"'; 
383
        gazeVolume += ' data-gaze-target="' + gazeTarget +'"'; 
384
385
        gazeVolume += ' data-gaze-function="audplay()"'; 
386
        gazeVolume += ' data-gaze-function-after="' + gazeFunctionAfter +'"'; 
387
        gazeVolume += '>';
388
        gazeVolume += '<p>';
389
        gazeVolume += 'Volumen';
390
        gazeVolume += '</p>';
391
        gazeVolume += '</div>';
392
393
394
        myarray.push(gazeCancel);
395
        myarray.push(gazePause);
396
        myarray.push(gazeOk);
397
        myarray.push(gazeTime);
398
        myarray.push(gazeVolume);
399
400
        return myarray;
401
}