forked from mitxp/HbbTV-Testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.js
99 lines (90 loc) · 2.19 KB
/
base.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
var opts = false;
var selected = 0;
function initVideo() {
try {
document.getElementById('video').bindToCurrentChannel();
} catch (e) {
// ignore
}
try {
document.getElementById('video').setFullScreen(false);
} catch (e) {
// ignore
}
}
function initApp() {
try {
var app = document.getElementById('appmgr').getOwnerApplication(document);
app.show();
app.activate();
} catch (e) {
// ignore
}
setKeyset(0x1+0x2+0x4+0x8+0x10);
}
function setKeyset(mask) {
// for HbbTV 0.5:
try {
var elemcfg = document.getElementById('oipfcfg');
elemcfg.keyset.value = mask;
} catch (e) {
// ignore
}
try {
var elemcfg = document.getElementById('oipfcfg');
elemcfg.keyset.setValue(mask);
} catch (e) {
// ignore
}
// for HbbTV 1.0:
try {
var app = document.getElementById('appmgr').getOwnerApplication(document);
app.privateData.keyset.setValue(mask);
app.privateData.keyset.value = mask;
} catch (e) {
// ignore
}
}
function registerKeyEventListener() {
document.addEventListener("keydown", function(e) {
if (handleKeyCode(e.keyCode)) {
e.preventDefault();
}
}, false);
}
function menuInit() {
opts = document.getElementById('menu').getElementsByTagName('li');
menuSelect(0);
}
function menuSelect(i) {
if (i<=0) {
i = 0;
} else if (i>=opts.length) {
i = opts.length-1;
}
selected = i;
var scroll = Math.max(0, Math.min(opts.length-13, selected-6));
for (i=0; i<opts.length; i++) {
opts[i].style.display = (i>=scroll && i<scroll+13) ? 'block' : 'none';
opts[i].className = selected==i ? 'lisel' : '';
}
}
function showStatus(succss, txt) {
var elem = document.getElementById('status');
elem.className = succss ? 'statok' : 'statfail';
if (!txt) {
elem.innerHTML = '';
return;
}
elem.innerHTML = '<b>Status:<'+'/b><br />'+txt;
if (succss) {
setInstr('Test succeeded, please execute the next test<br />(press OK).');
if (opts) menuSelect(selected+1);
} else {
setInstr('Test failed, please return to test menu<br />(press OK).');
if (opts) menuSelect(opts.length-1);
}
}
function setInstr(txt) {
document.getElementById('instr').innerHTML = txt;
}