tizenbrew-module 1.0.1 → 1.0.3
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 +43 -33
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
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
|
+
// Use native Tizen API to launch the TV's built-in web browser
|
|
6
|
+
if (typeof tizen !== 'undefined' && tizen.application && tizen.ApplicationControl) {
|
|
7
|
+
var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view", "https://net22.cc");
|
|
8
|
+
tizen.application.launchAppControl(appControl, null, function() {}, function(e) {
|
|
9
|
+
window.location.href = 'https://net22.cc';
|
|
10
|
+
});
|
|
11
|
+
} else {
|
|
12
|
+
window.location.href = 'https://net22.cc';
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
window.location.href = 'https://net22.cc';
|
|
16
|
+
}
|
|
17
|
+
return; // Stop script execution in the menu.
|
|
8
18
|
}
|
|
9
19
|
|
|
10
20
|
// Wrapped in an IIFE to prevent variable collisions in TizenBrew's global scope
|
|
@@ -24,25 +34,25 @@
|
|
|
24
34
|
try {
|
|
25
35
|
var nodeList = document.querySelectorAll(FOCUSABLE_SELECTORS);
|
|
26
36
|
var allElements = Array.prototype.slice.call(nodeList);
|
|
27
|
-
|
|
28
|
-
focusableElements = allElements.filter(function(el) {
|
|
37
|
+
|
|
38
|
+
focusableElements = allElements.filter(function (el) {
|
|
29
39
|
if (!el || !el.getBoundingClientRect) return false;
|
|
30
40
|
var rect = el.getBoundingClientRect();
|
|
31
|
-
|
|
41
|
+
|
|
32
42
|
// Fallback for getting style if window.getComputedStyle throws
|
|
33
43
|
var style;
|
|
34
44
|
try {
|
|
35
45
|
style = window.getComputedStyle(el);
|
|
36
|
-
} catch(e) {
|
|
46
|
+
} catch (e) {
|
|
37
47
|
return false;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
return (
|
|
41
|
-
rect.width > 0 &&
|
|
42
|
-
rect.height > 0 &&
|
|
51
|
+
rect.width > 0 &&
|
|
52
|
+
rect.height > 0 &&
|
|
43
53
|
style &&
|
|
44
|
-
style.display !== 'none' &&
|
|
45
|
-
style.visibility !== 'hidden' &&
|
|
54
|
+
style.display !== 'none' &&
|
|
55
|
+
style.visibility !== 'hidden' &&
|
|
46
56
|
style.opacity !== '0'
|
|
47
57
|
);
|
|
48
58
|
});
|
|
@@ -62,7 +72,7 @@
|
|
|
62
72
|
focusElement(0);
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
|
-
} catch(err) {
|
|
75
|
+
} catch (err) {
|
|
66
76
|
console.error("TizenBrew Net22 Module Error in updateFocusableElements:", err);
|
|
67
77
|
}
|
|
68
78
|
}
|
|
@@ -73,42 +83,42 @@
|
|
|
73
83
|
if (currentFocusIndex !== -1 && focusableElements[currentFocusIndex] && focusableElements[currentFocusIndex].classList) {
|
|
74
84
|
focusableElements[currentFocusIndex].classList.remove('tizen-focus');
|
|
75
85
|
}
|
|
76
|
-
|
|
86
|
+
|
|
77
87
|
currentFocusIndex = index;
|
|
78
88
|
var el = focusableElements[currentFocusIndex];
|
|
79
|
-
|
|
89
|
+
|
|
80
90
|
if (el && el.focus) {
|
|
81
91
|
el.focus();
|
|
82
92
|
}
|
|
83
93
|
if (el && el.classList) {
|
|
84
94
|
el.classList.add('tizen-focus');
|
|
85
95
|
}
|
|
86
|
-
|
|
96
|
+
|
|
87
97
|
if (el && typeof el.scrollIntoView === 'function') {
|
|
88
98
|
try {
|
|
89
99
|
el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });
|
|
90
|
-
} catch(e) {
|
|
100
|
+
} catch (e) {
|
|
91
101
|
el.scrollIntoView();
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
|
-
} catch(err) {
|
|
105
|
+
} catch (err) {
|
|
96
106
|
console.error("TizenBrew Net22 Module Error in focusElement:", err);
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
document.addEventListener('focusout', function(e) {
|
|
110
|
+
document.addEventListener('focusout', function (e) {
|
|
101
111
|
try {
|
|
102
112
|
if (e.target && e.target.classList) {
|
|
103
113
|
e.target.classList.remove('tizen-focus');
|
|
104
114
|
}
|
|
105
|
-
} catch(err) {}
|
|
115
|
+
} catch (err) { }
|
|
106
116
|
});
|
|
107
117
|
|
|
108
118
|
function navigate(directionKeyCode) {
|
|
109
119
|
try {
|
|
110
120
|
if (focusableElements.length === 0) return;
|
|
111
|
-
|
|
121
|
+
|
|
112
122
|
if (currentFocusIndex === -1) {
|
|
113
123
|
focusElement(0);
|
|
114
124
|
return;
|
|
@@ -116,7 +126,7 @@
|
|
|
116
126
|
|
|
117
127
|
var currentEl = focusableElements[currentFocusIndex];
|
|
118
128
|
if (!currentEl || !currentEl.getBoundingClientRect) return;
|
|
119
|
-
|
|
129
|
+
|
|
120
130
|
var currentRect = currentEl.getBoundingClientRect();
|
|
121
131
|
var currentCenterX = currentRect.left + (currentRect.width / 2);
|
|
122
132
|
var currentCenterY = currentRect.top + (currentRect.height / 2);
|
|
@@ -129,7 +139,7 @@
|
|
|
129
139
|
|
|
130
140
|
var targetEl = focusableElements[i];
|
|
131
141
|
if (!targetEl || !targetEl.getBoundingClientRect) continue;
|
|
132
|
-
|
|
142
|
+
|
|
133
143
|
var targetRect = targetEl.getBoundingClientRect();
|
|
134
144
|
var targetCenterX = targetRect.left + (targetRect.width / 2);
|
|
135
145
|
var targetCenterY = targetRect.top + (targetRect.height / 2);
|
|
@@ -154,7 +164,7 @@
|
|
|
154
164
|
|
|
155
165
|
if (isValidDirection) {
|
|
156
166
|
var distance = Math.sqrt(dx * dx + dy * dy);
|
|
157
|
-
|
|
167
|
+
|
|
158
168
|
if (distance < minDistance) {
|
|
159
169
|
minDistance = distance;
|
|
160
170
|
bestMatchIndex = i;
|
|
@@ -165,12 +175,12 @@
|
|
|
165
175
|
if (bestMatchIndex !== -1) {
|
|
166
176
|
focusElement(bestMatchIndex);
|
|
167
177
|
}
|
|
168
|
-
} catch(err) {
|
|
178
|
+
} catch (err) {
|
|
169
179
|
console.error("TizenBrew Net22 Module Error in navigate:", err);
|
|
170
180
|
}
|
|
171
181
|
}
|
|
172
182
|
|
|
173
|
-
window.addEventListener('keydown', function(e) {
|
|
183
|
+
window.addEventListener('keydown', function (e) {
|
|
174
184
|
try {
|
|
175
185
|
var keyCode = e.keyCode || e.which;
|
|
176
186
|
switch (keyCode) {
|
|
@@ -181,7 +191,7 @@
|
|
|
181
191
|
e.preventDefault();
|
|
182
192
|
navigate(keyCode);
|
|
183
193
|
break;
|
|
184
|
-
|
|
194
|
+
|
|
185
195
|
case KEY_ENTER:
|
|
186
196
|
e.preventDefault();
|
|
187
197
|
if (currentFocusIndex !== -1 && focusableElements[currentFocusIndex]) {
|
|
@@ -196,7 +206,7 @@
|
|
|
196
206
|
}
|
|
197
207
|
}
|
|
198
208
|
break;
|
|
199
|
-
|
|
209
|
+
|
|
200
210
|
case KEY_RETURN:
|
|
201
211
|
e.preventDefault();
|
|
202
212
|
var closeButton = document.querySelector('.modal-close, .close-btn, .video-close');
|
|
@@ -207,7 +217,7 @@
|
|
|
207
217
|
}
|
|
208
218
|
break;
|
|
209
219
|
}
|
|
210
|
-
} catch(err) {
|
|
220
|
+
} catch (err) {
|
|
211
221
|
console.error("TizenBrew Net22 Module Error in keydown handler:", err);
|
|
212
222
|
}
|
|
213
223
|
});
|
|
@@ -215,12 +225,12 @@
|
|
|
215
225
|
// Replace MutationObserver completely with a safe setInterval
|
|
216
226
|
// This is incredibly robust for older TVs, prevents any infinite DOM loops,
|
|
217
227
|
// and doesn't rely on the MutationObserver API existing.
|
|
218
|
-
setInterval(function() {
|
|
228
|
+
setInterval(function () {
|
|
219
229
|
updateFocusableElements();
|
|
220
230
|
}, 1500);
|
|
221
231
|
|
|
222
232
|
// Initial check
|
|
223
|
-
window.addEventListener('load', function() {
|
|
233
|
+
window.addEventListener('load', function () {
|
|
224
234
|
updateFocusableElements();
|
|
225
235
|
});
|
|
226
236
|
|
package/package.json
CHANGED