Spaces:
Running
Running
// Funci贸n para mostrar un mensaje de bienvenida al usuario | |
function mostrarBienvenida() { | |
const nombre = prompt("Ingrese su nombre"); | |
alert("隆Hola " + nombre + "! Bienvenido a nuestra iglesia."); | |
} | |
// Funci贸n para mostrar un mensaje de despedida al usuario | |
function mostrarDespedida() { | |
const nombre = prompt("Ingrese su nombre"); | |
alert("隆Hasta pronto " + nombre + "! Te esperamos la pr贸xima vez."); | |
} | |
// Llamamos a la funci贸n mostrarBienvenida al cargar la p谩gina | |
mostrarBienvenida(); | |
// Funci贸n para exportar el contenido a una imagen | |
function exportarImagen() { | |
html2canvas(document.body).then(function(canvas) { | |
const imgData = canvas.toDataURL("image/png"); | |
const a = document.createElement("a"); | |
a.href = imgData; | |
a.download = "imagen-iglesia.png"; | |
a.click(); | |
}); | |
} | |
// Funci贸n para exportar el contenido a un PDF | |
function exportarPDF() { | |
window.print(); | |
} | |
// Funci贸n para mostrar las opciones desplegables | |
function mostrarOpcionesDesplegables() { | |
var botonDesplegable = document.getElementById('botonDesplegable'); | |
var opciones = document.createElement('div'); | |
opciones.innerHTML = ` | |
<button id="imgData">Exportar a imagen</button> | |
<button id="exportarPDF">Exportar a PDF</button> | |
<button id="despedida">Despedida</button> | |
`; | |
// Asignar eventos a los nuevos botones | |
document.getElementById("imgData").addEventListener("click", function() { | |
exportarImagen(); | |
ocultarBotones(); | |
}); | |
document.getElementById("exportarPDF").addEventListener("click", function() { | |
exportarPDF(); | |
ocultarBotones(); | |
}); | |
document.getElementById("despedida").addEventListener("click", function() { | |
mostrarDespedida(); | |
ocultarBotones(); | |
}); | |
// Ocultar bot贸n desplegable | |
botonDesplegable.style.display = 'none'; | |
// Insertar las opciones despu茅s de ocultar el bot贸n desplegable | |
botonDesplegable.parentNode.insertBefore(opciones, botonDesplegable.nextSibling); | |
} | |
// Funci贸n para ocultar los botones | |
function ocultarBotones() { | |
var botonesExportacion = document.querySelector('.botones-exportacion'); | |
botonesExportacion.classList.add('oculto'); | |
} | |
// Llamamos a la funci贸n mostrarOpcionesDesplegables al hacer clic en el bot贸n "Opciones" | |
document.getElementById("botonDesplegable").addEventListener("click", mostrarOpcionesDesplegables); | |