mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
parent
b9dd9a0f90
commit
38689d90d1
2 changed files with 89 additions and 8 deletions
|
@ -336,7 +336,7 @@ function validateEmail(email) {
|
|||
return re.test(email);
|
||||
}
|
||||
|
||||
function isEmailValid(email){
|
||||
function isEmailValid(email) {
|
||||
return validateEmail(email);
|
||||
}
|
||||
|
||||
|
@ -729,7 +729,9 @@ function playNext(url) {
|
|||
console.log(response);
|
||||
if (!response || response.error) {
|
||||
console.log("playNext ajax fail");
|
||||
//document.location = url;
|
||||
if (response.url) {
|
||||
//document.location = response.url;
|
||||
}
|
||||
} else {
|
||||
console.log("playNext ajax success");
|
||||
$('topInfo').hide();
|
||||
|
@ -890,7 +892,7 @@ function setCurrentTime(currentTime) {
|
|||
}
|
||||
|
||||
function isALiveContent() {
|
||||
if (typeof isLive !== 'undefined' && isLive && (typeof isOnlineLabel === 'undefined' || isOnlineLabel===true)) {
|
||||
if (typeof isLive !== 'undefined' && isLive && (typeof isOnlineLabel === 'undefined' || isOnlineLabel === true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -962,11 +964,11 @@ function checkAutoPlay() {
|
|||
if (isAutoplayEnabled()) {
|
||||
$("#autoplay").prop('checked', true);
|
||||
$('.autoplay-button').addClass('checked');
|
||||
avideoTooltip(".autoplay-button","Autoplay is ON");
|
||||
}else{
|
||||
avideoTooltip(".autoplay-button", "Autoplay is ON");
|
||||
} else {
|
||||
$("#autoplay").prop('checked', false);
|
||||
$('.autoplay-button').removeClass('checked');
|
||||
avideoTooltip(".autoplay-button","Autoplay is OFF");
|
||||
avideoTooltip(".autoplay-button", "Autoplay is OFF");
|
||||
}
|
||||
showAutoPlayVideoDiv();
|
||||
}
|
||||
|
@ -1166,11 +1168,32 @@ function countTo(selector, total) {
|
|||
if (typeof showPleaseWaitTimeOut == 'undefined') {
|
||||
var showPleaseWaitTimeOut = 0;
|
||||
}
|
||||
|
||||
var tabsCategoryDocumentHeight = 0;
|
||||
function tabsCategoryDocumentHeightChanged() {
|
||||
var newHeight = $(document).height();
|
||||
if (tabsCategoryDocumentHeight !== newHeight) {
|
||||
tabsCategoryDocumentHeight = newHeight;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
Cookies.set('timezone', Intl.DateTimeFormat().resolvedOptions().timeZone, {
|
||||
path: '/',
|
||||
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 () {
|
||||
var pleaseWaitDiv = $("#pleaseWaitDialog");
|
||||
if (pleaseWaitDiv.length === 0) {
|
||||
|
@ -1657,10 +1680,45 @@ function avideoAjax(url, data) {
|
|||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
avideoToastSuccess(response.msg);
|
||||
if(typeof response.eval !== 'undefined'){
|
||||
if (typeof response.eval !== 'undefined') {
|
||||
eval(response.eval);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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
23
view/js/sw.js
Normal 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)),
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue