stremio/apps/tizen-tv/www/js/polyfill.js
Jos Vooges | STH a0311c031e Add Samsung Tizen TV web client.
Focus-friendly VMC shell for Tizen with live TV and playback against the master API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 19:16:30 +02:00

59 lines
1.7 KiB
JavaScript

/* Oudere Tizen-browsers: fetch + pad helpers */
(function (global) {
if (typeof global.fetch !== "function") {
global.fetch = function (url, opts) {
opts = opts || {};
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(opts.method || "GET", url, true);
var headers = opts.headers || {};
for (var k in headers) {
if (headers.hasOwnProperty(k)) xhr.setRequestHeader(k, headers[k]);
}
xhr.onload = function () {
var body = xhr.responseText;
resolve({
ok: xhr.status >= 200 && xhr.status < 300,
status: xhr.status,
text: function () {
return Promise.resolve(body);
},
json: function () {
return Promise.resolve(JSON.parse(body || "null"));
},
});
};
xhr.onerror = function () {
reject(new Error("Netwerkfout"));
};
xhr.send(opts.body || null);
});
};
}
if (!Element.prototype.closest) {
Element.prototype.closest = function (sel) {
var el = this;
while (el && el.nodeType === 1) {
if (el.matches ? el.matches(sel) : el.msMatchesSelector(sel)) return el;
el = el.parentElement;
}
return null;
};
}
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
if (typeof Promise === "undefined") {
var fatal = document.getElementById("fatal");
if (fatal) {
fatal.classList.remove("hidden");
fatal.textContent =
"Deze TV ondersteunt geen moderne JavaScript (Promise ontbreekt).";
}
}
})(window);