75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
// Aspetta che il documento HTML sia completamente caricato prima di eseguire lo script
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
// Ottieni il riferimento al pulsante di avvio del gioco
|
|
var startButton = document.getElementById("startButton");
|
|
|
|
// Aggiungi un gestore di eventi al pulsante di avvio
|
|
startButton.addEventListener("click", function() {
|
|
// Nascondi il pulsante di avvio
|
|
startButton.style.display = "none";
|
|
|
|
// Ottieni il riferimento al contenitore del gioco
|
|
var gameContainer = document.getElementById("gameContainer");
|
|
var ruota = document.getElementById("gameIframe");
|
|
|
|
// Mostra il contenitore del gioco
|
|
gameContainer.style.display = "block";
|
|
var ruota = document.getElementById("block");
|
|
|
|
// Ottieni il riferimento al video del gioco
|
|
var gameVideo = document.getElementById("gameVideo");
|
|
|
|
// Avvia il video
|
|
gameVideo.play();
|
|
|
|
// Aggiungi una classe CSS per far girare la ruota
|
|
gameContainer.classList.add("spin");
|
|
loadIframeWithTimeout();
|
|
});
|
|
});
|
|
|
|
function loadIframeWithTimeout() {
|
|
// Specify the timeout duration in milliseconds (e.g., 3000ms = 3 seconds)
|
|
var timeoutDuration = 0;
|
|
|
|
// Wait for the specified timeout
|
|
setTimeout(function() {
|
|
// Create the iframe element
|
|
var iframe = document.createElement('iframe');
|
|
|
|
// Set the source URL of the iframe
|
|
iframe.src = './ruota.html';
|
|
|
|
// Set the desired attributes for the iframe
|
|
iframe.width = '100%';
|
|
iframe.height = '100%';
|
|
iframe.frameBorder = '0';
|
|
// Apply CSS styles to cut the left part and center the iframe
|
|
iframe.style.position = 'absolute';
|
|
// iframe.style.left = '50%';
|
|
// iframe.style.transform = 'translateX(-50%)';
|
|
|
|
// Append the iframe to the bottom of the document body
|
|
document.body.appendChild(iframe);
|
|
console.log("loaded");
|
|
}, timeoutDuration);
|
|
}
|
|
function disableScroll() {
|
|
document.addEventListener('wheel', preventDefault);
|
|
document.addEventListener('touchmove', preventDefault);
|
|
document.addEventListener('keydown', preventDefault);
|
|
}
|
|
|
|
function enableScroll() {
|
|
document.removeEventListener('wheel', preventDefault);
|
|
document.removeEventListener('touchmove', preventDefault);
|
|
document.removeEventListener('keydown', preventDefault);
|
|
}
|
|
|
|
function preventDefault(event) {
|
|
event.preventDefault();
|
|
}
|
|
|
|
// Call disableScroll() to disable scrolling
|
|
disableScroll();
|