1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00
Daniel 2021-06-29 20:41:23 -03:00
parent b9dd9a0f90
commit 38689d90d1
2 changed files with 89 additions and 8 deletions

View file

@ -729,7 +729,9 @@ function playNext(url) {
console.log(response); console.log(response);
if (!response || response.error) { if (!response || response.error) {
console.log("playNext ajax fail"); console.log("playNext ajax fail");
//document.location = url; if (response.url) {
//document.location = response.url;
}
} else { } else {
console.log("playNext ajax success"); console.log("playNext ajax success");
$('topInfo').hide(); $('topInfo').hide();
@ -1166,11 +1168,32 @@ function countTo(selector, total) {
if (typeof showPleaseWaitTimeOut == 'undefined') { if (typeof showPleaseWaitTimeOut == 'undefined') {
var showPleaseWaitTimeOut = 0; var showPleaseWaitTimeOut = 0;
} }
var tabsCategoryDocumentHeight = 0;
function tabsCategoryDocumentHeightChanged() {
var newHeight = $(document).height();
if (tabsCategoryDocumentHeight !== newHeight) {
tabsCategoryDocumentHeight = newHeight;
return true;
}
return false;
}
$(document).ready(function () { $(document).ready(function () {
Cookies.set('timezone', Intl.DateTimeFormat().resolvedOptions().timeZone, { Cookies.set('timezone', Intl.DateTimeFormat().resolvedOptions().timeZone, {
path: '/', path: '/',
expires: 365 expires: 365
}); });
tabsCategoryDocumentHeight = $(document).height();
$('.nav-tabs-horizontal').scrollingTabs();
//$('.nav-tabs-horizontal').fadeIn();
setInterval(function () {
if (tabsCategoryDocumentHeightChanged()) {
$('.nav-tabs-horizontal').scrollingTabs('refresh');
}
}, 1000);
modal = modal || (function () { modal = modal || (function () {
var pleaseWaitDiv = $("#pleaseWaitDialog"); var pleaseWaitDiv = $("#pleaseWaitDialog");
if (pleaseWaitDiv.length === 0) { if (pleaseWaitDiv.length === 0) {
@ -1664,3 +1687,38 @@ function avideoAjax(url, data) {
} }
}); });
} }
// Register service worker to control making site work offline
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register(webSiteRootURL+'view/js/sw.js')
.then(() => { console.log('Service Worker Registered'); });
}
// Code to handle install prompt on desktop
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI to notify the user they can add to home screen
addBtn.style.display = 'block';
addBtn.addEventListener('click', () => {
// hide our user interface that shows our A2HS button
addBtn.style.display = 'none';
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
});
});

23
view/js/sw.js Normal file
View file

@ -0,0 +1,23 @@
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open(webSiteRootURL).then((cache) => cache.addAll([
/*
'/pwa-examples/a2hs/',
'/pwa-examples/a2hs/index.html',
'/pwa-examples/a2hs/index.js',
'/pwa-examples/a2hs/style.css',
'/pwa-examples/a2hs/images/fox1.jpg',
'/pwa-examples/a2hs/images/fox2.jpg',
'/pwa-examples/a2hs/images/fox3.jpg',
'/pwa-examples/a2hs/images/fox4.jpg',
*/
])),
);
});
self.addEventListener('fetch', (e) => {
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request)),
);
});