tizenbrew-module 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +40 -33
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
//
|
|
3
|
-
// If the module is executed while in the TizenBrew menu (not on net22.cc),
|
|
4
|
-
// it needs to redirect the browser to the actual streaming site.
|
|
1
|
+
(function () {
|
|
2
|
+
// If the module is executed in the TizenBrew menu, force-launch the browser
|
|
5
3
|
if (window.location.href.indexOf('net22.cc') === -1) {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
try {
|
|
5
|
+
// Create a fake link to force the TV to open the native browser
|
|
6
|
+
var a = document.createElement('a');
|
|
7
|
+
a.href = 'https://net22.cc';
|
|
8
|
+
a.target = '_blank';
|
|
9
|
+
document.body.appendChild(a);
|
|
10
|
+
a.click();
|
|
11
|
+
} catch (e) {
|
|
12
|
+
window.location.href = 'https://net22.cc';
|
|
13
|
+
}
|
|
14
|
+
return; // Stop script execution in the menu.
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
// Wrapped in an IIFE to prevent variable collisions in TizenBrew's global scope
|
|
@@ -24,25 +31,25 @@
|
|
|
24
31
|
try {
|
|
25
32
|
var nodeList = document.querySelectorAll(FOCUSABLE_SELECTORS);
|
|
26
33
|
var allElements = Array.prototype.slice.call(nodeList);
|
|
27
|
-
|
|
28
|
-
focusableElements = allElements.filter(function(el) {
|
|
34
|
+
|
|
35
|
+
focusableElements = allElements.filter(function (el) {
|
|
29
36
|
if (!el || !el.getBoundingClientRect) return false;
|
|
30
37
|
var rect = el.getBoundingClientRect();
|
|
31
|
-
|
|
38
|
+
|
|
32
39
|
// Fallback for getting style if window.getComputedStyle throws
|
|
33
40
|
var style;
|
|
34
41
|
try {
|
|
35
42
|
style = window.getComputedStyle(el);
|
|
36
|
-
} catch(e) {
|
|
43
|
+
} catch (e) {
|
|
37
44
|
return false;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
return (
|
|
41
|
-
rect.width > 0 &&
|
|
42
|
-
rect.height > 0 &&
|
|
48
|
+
rect.width > 0 &&
|
|
49
|
+
rect.height > 0 &&
|
|
43
50
|
style &&
|
|
44
|
-
style.display !== 'none' &&
|
|
45
|
-
style.visibility !== 'hidden' &&
|
|
51
|
+
style.display !== 'none' &&
|
|
52
|
+
style.visibility !== 'hidden' &&
|
|
46
53
|
style.opacity !== '0'
|
|
47
54
|
);
|
|
48
55
|
});
|
|
@@ -62,7 +69,7 @@
|
|
|
62
69
|
focusElement(0);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
|
-
} catch(err) {
|
|
72
|
+
} catch (err) {
|
|
66
73
|
console.error("TizenBrew Net22 Module Error in updateFocusableElements:", err);
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -73,42 +80,42 @@
|
|
|
73
80
|
if (currentFocusIndex !== -1 && focusableElements[currentFocusIndex] && focusableElements[currentFocusIndex].classList) {
|
|
74
81
|
focusableElements[currentFocusIndex].classList.remove('tizen-focus');
|
|
75
82
|
}
|
|
76
|
-
|
|
83
|
+
|
|
77
84
|
currentFocusIndex = index;
|
|
78
85
|
var el = focusableElements[currentFocusIndex];
|
|
79
|
-
|
|
86
|
+
|
|
80
87
|
if (el && el.focus) {
|
|
81
88
|
el.focus();
|
|
82
89
|
}
|
|
83
90
|
if (el && el.classList) {
|
|
84
91
|
el.classList.add('tizen-focus');
|
|
85
92
|
}
|
|
86
|
-
|
|
93
|
+
|
|
87
94
|
if (el && typeof el.scrollIntoView === 'function') {
|
|
88
95
|
try {
|
|
89
96
|
el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });
|
|
90
|
-
} catch(e) {
|
|
97
|
+
} catch (e) {
|
|
91
98
|
el.scrollIntoView();
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
|
-
} catch(err) {
|
|
102
|
+
} catch (err) {
|
|
96
103
|
console.error("TizenBrew Net22 Module Error in focusElement:", err);
|
|
97
104
|
}
|
|
98
105
|
}
|
|
99
106
|
|
|
100
|
-
document.addEventListener('focusout', function(e) {
|
|
107
|
+
document.addEventListener('focusout', function (e) {
|
|
101
108
|
try {
|
|
102
109
|
if (e.target && e.target.classList) {
|
|
103
110
|
e.target.classList.remove('tizen-focus');
|
|
104
111
|
}
|
|
105
|
-
} catch(err) {}
|
|
112
|
+
} catch (err) { }
|
|
106
113
|
});
|
|
107
114
|
|
|
108
115
|
function navigate(directionKeyCode) {
|
|
109
116
|
try {
|
|
110
117
|
if (focusableElements.length === 0) return;
|
|
111
|
-
|
|
118
|
+
|
|
112
119
|
if (currentFocusIndex === -1) {
|
|
113
120
|
focusElement(0);
|
|
114
121
|
return;
|
|
@@ -116,7 +123,7 @@
|
|
|
116
123
|
|
|
117
124
|
var currentEl = focusableElements[currentFocusIndex];
|
|
118
125
|
if (!currentEl || !currentEl.getBoundingClientRect) return;
|
|
119
|
-
|
|
126
|
+
|
|
120
127
|
var currentRect = currentEl.getBoundingClientRect();
|
|
121
128
|
var currentCenterX = currentRect.left + (currentRect.width / 2);
|
|
122
129
|
var currentCenterY = currentRect.top + (currentRect.height / 2);
|
|
@@ -129,7 +136,7 @@
|
|
|
129
136
|
|
|
130
137
|
var targetEl = focusableElements[i];
|
|
131
138
|
if (!targetEl || !targetEl.getBoundingClientRect) continue;
|
|
132
|
-
|
|
139
|
+
|
|
133
140
|
var targetRect = targetEl.getBoundingClientRect();
|
|
134
141
|
var targetCenterX = targetRect.left + (targetRect.width / 2);
|
|
135
142
|
var targetCenterY = targetRect.top + (targetRect.height / 2);
|
|
@@ -154,7 +161,7 @@
|
|
|
154
161
|
|
|
155
162
|
if (isValidDirection) {
|
|
156
163
|
var distance = Math.sqrt(dx * dx + dy * dy);
|
|
157
|
-
|
|
164
|
+
|
|
158
165
|
if (distance < minDistance) {
|
|
159
166
|
minDistance = distance;
|
|
160
167
|
bestMatchIndex = i;
|
|
@@ -165,12 +172,12 @@
|
|
|
165
172
|
if (bestMatchIndex !== -1) {
|
|
166
173
|
focusElement(bestMatchIndex);
|
|
167
174
|
}
|
|
168
|
-
} catch(err) {
|
|
175
|
+
} catch (err) {
|
|
169
176
|
console.error("TizenBrew Net22 Module Error in navigate:", err);
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
|
|
173
|
-
window.addEventListener('keydown', function(e) {
|
|
180
|
+
window.addEventListener('keydown', function (e) {
|
|
174
181
|
try {
|
|
175
182
|
var keyCode = e.keyCode || e.which;
|
|
176
183
|
switch (keyCode) {
|
|
@@ -181,7 +188,7 @@
|
|
|
181
188
|
e.preventDefault();
|
|
182
189
|
navigate(keyCode);
|
|
183
190
|
break;
|
|
184
|
-
|
|
191
|
+
|
|
185
192
|
case KEY_ENTER:
|
|
186
193
|
e.preventDefault();
|
|
187
194
|
if (currentFocusIndex !== -1 && focusableElements[currentFocusIndex]) {
|
|
@@ -196,7 +203,7 @@
|
|
|
196
203
|
}
|
|
197
204
|
}
|
|
198
205
|
break;
|
|
199
|
-
|
|
206
|
+
|
|
200
207
|
case KEY_RETURN:
|
|
201
208
|
e.preventDefault();
|
|
202
209
|
var closeButton = document.querySelector('.modal-close, .close-btn, .video-close');
|
|
@@ -207,7 +214,7 @@
|
|
|
207
214
|
}
|
|
208
215
|
break;
|
|
209
216
|
}
|
|
210
|
-
} catch(err) {
|
|
217
|
+
} catch (err) {
|
|
211
218
|
console.error("TizenBrew Net22 Module Error in keydown handler:", err);
|
|
212
219
|
}
|
|
213
220
|
});
|
|
@@ -215,12 +222,12 @@
|
|
|
215
222
|
// Replace MutationObserver completely with a safe setInterval
|
|
216
223
|
// This is incredibly robust for older TVs, prevents any infinite DOM loops,
|
|
217
224
|
// and doesn't rely on the MutationObserver API existing.
|
|
218
|
-
setInterval(function() {
|
|
225
|
+
setInterval(function () {
|
|
219
226
|
updateFocusableElements();
|
|
220
227
|
}, 1500);
|
|
221
228
|
|
|
222
229
|
// Initial check
|
|
223
|
-
window.addEventListener('load', function() {
|
|
230
|
+
window.addEventListener('load', function () {
|
|
224
231
|
updateFocusableElements();
|
|
225
232
|
});
|
|
226
233
|
|