updated public key
This commit is contained in:
35
app.js
35
app.js
@@ -10,7 +10,9 @@ let carouselPosition = 0;
|
|||||||
let startX = 0;
|
let startX = 0;
|
||||||
let currentX = 0;
|
let currentX = 0;
|
||||||
let pushSubscription = null;
|
let pushSubscription = null;
|
||||||
const PUBLIC_VAPID_KEY = 'BNIXGVBzq6SNqvlDMFylw_hLTpf_J96ddbwfMa9Cn1tFQ1-vDqmz_NQS0a5UiczqAJ-uYs-6EeuwrnwaMRGtifk=';
|
const PUBLIC_VAPID_KEY = 'BKfRJXjSQmAJ452gLwlK_8scGrW6qMU1mBRp39ONtcQHkSsQgmLAaODIyGbgHyRpnDEv3HfXV1oGh3SC0fHxY0E';
|
||||||
|
const BACKEND_URL = 'https://webpush.virtonline.eu';
|
||||||
|
const BUTTON_ID = 'your_button1_serial';
|
||||||
|
|
||||||
// DOM Elements
|
// DOM Elements
|
||||||
const carousel = document.getElementById('carousel');
|
const carousel = document.getElementById('carousel');
|
||||||
@@ -49,12 +51,15 @@ async function subscribeToPushNotifications() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Send subscription to your server
|
// Send subscription to your server
|
||||||
await fetch('https://webpush.virtonline.eu/subscribe', {
|
await fetch(`${BACKEND_URL}/subscribe`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(subscription),
|
body: JSON.stringify({
|
||||||
|
button_id: BACKEND_URL,
|
||||||
|
subscription: subscription // The PushSubscription object
|
||||||
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
pushSubscription = subscription;
|
pushSubscription = subscription;
|
||||||
@@ -220,13 +225,11 @@ gameButton.addEventListener('click', () => {
|
|||||||
gameState = 'paused';
|
gameState = 'paused';
|
||||||
audioManager.play('gamePause');
|
audioManager.play('gamePause');
|
||||||
stopTimer();
|
stopTimer();
|
||||||
// sendPushNotification('Game Paused', 'The game timer has paused!');
|
|
||||||
break;
|
break;
|
||||||
case 'paused':
|
case 'paused':
|
||||||
gameState = 'running';
|
gameState = 'running';
|
||||||
audioManager.play('gameResume');
|
audioManager.play('gameResume');
|
||||||
startTimer();
|
startTimer();
|
||||||
// sendPushNotification('Game Resumed', 'The game timer has resumed!');
|
|
||||||
break;
|
break;
|
||||||
case 'over':
|
case 'over':
|
||||||
// Reset timers and start new game
|
// Reset timers and start new game
|
||||||
@@ -243,26 +246,6 @@ gameButton.addEventListener('click', () => {
|
|||||||
saveData();
|
saveData();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function sendPushNotification(title, message) {
|
|
||||||
if (!pushSubscription) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await fetch('https://webpush.virtonline.eu/flic-webhook', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
title: title,
|
|
||||||
body: message,
|
|
||||||
action: 'game_update'
|
|
||||||
})
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error sending push notification:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timer variables
|
// Timer variables
|
||||||
let timerInterval = null;
|
let timerInterval = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user