VulpesOS/gaia/tv_apps/fling-tutorial/js/index.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

50 lines
1.4 KiB
JavaScript
Executable file

/* global FTEWizard */
(function (exports) {
'use strict';
window.addEventListener('load', function() {
var offlineContent = document.querySelector('#offline-content');
var mozIframe = document.querySelector('#moz-iframe[mozbrowser]');
if (navigator.onLine) {
mozIframe.classList.remove('hidden');
mozIframe.addEventListener('mozbrowserloadend', () => {
mozIframe.focus();
});
// The call of window.close by content inside iframe(even with mozbrowser)
// is not allowed and does't not trigger the mozbrowserclose event.
// As a result, we use the mozbrowserlocationchange event to observe
// when user finishes the tutorial.
mozIframe.addEventListener('mozbrowserlocationchange', (e) => {
if (e.detail === mozIframe.src + '#finished') {
window.close();
}
});
// The mozbrowserclose event would be trrigered when content inside iframe
// is crashed. When crashed, let's just leave this app.
mozIframe.addEventListener('mozbrowserclose', () => {
window.close();
});
mozIframe.src = 'https://casttv.services.mozilla.com';
} else {
offlineContent.classList.remove('hidden');
var tutorial = new FTEWizard('flingTutorial');
tutorial.init({
container: offlineContent,
pageClass: 'slide',
buttonsClass: 'slide-button',
launchEveryTime: true,
onfinish: function () {
window.close();
}.bind(tutorial)
});
}
});
})(window);