PHES – Predica Bíblica
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #87CEEB;
color: #333;
text-align: center;
}
.container {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
#appTitle {
font-size: 2em;
margin-bottom: 20px;
}
.input-section, .output-section, .share-section, .language-section {
margin-bottom: 20px;
}
input[type=”text”] {
width: 80%;
padding: 10px;
font-size: 1em;
margin: 10px 0;
}
button {
padding: 10px 20px;
font-size: 1em;
margin: 5px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
}
button:hover {
background-color: #45a049;
}
.popup {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
}
.popup-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 10px;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
// Variables globales
let currentLanguage = ‘es’;
// Función para obtener un versículo de bienvenida de manera aleatoria al iniciar la app
window.onload = function() {
displayRandomVerse();
}
// Función para generar un versículo bíblico aleatorio usando OpenAI
async function displayRandomVerse() {
const prompt = currentLanguage === ‘es’
? “Dame un versículo de aliento de la Biblia en español.”
: “Give me an encouraging Bible verse in English.”;
try {
const response = await fetch(‘https://api.openai.com/v1/completions’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: `Bearer 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` // <<< REEMPLAZAR AQUÍ CON TU API KEY DE OPENAI
},
body: JSON.stringify({
model: 'text-davinci-003',
prompt: prompt,
max_tokens: 60,
n: 1,
stop: null,
temperature: 0.7
})
});
const data = await response.json();
const verse = data.choices[0].text.trim();
document.getElementById("welcomeVerse").textContent = verse;
} catch (error) {
console.error("Error al obtener la cita bíblica:", error);
document.getElementById("welcomeVerse").textContent = currentLanguage === 'es' ? "Error al cargar la cita." : "Error loading verse.";
}
}
// Función para buscar predica basada en la palabra/frase ingresada
async function fetchPredica() {
const phrase = document.getElementById("inputPhrase").value;
if (phrase === '') {
alert(currentLanguage === 'es' ? 'Por favor, ingresa una palabra o frase.' : 'Please enter a word or phrase.');
return;
}
const prompt = currentLanguage === 'es'
? `Escribe una predica basada en la biblia que incluya citas de libros, capítulos y versículos sobre el tema: "${phrase}".`
: `Write a biblical sermon that includes quotes from books, chapters, and verses about the topic: "${phrase}".`;
try {
const response = await fetch('https://api.openai.com/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer 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` // <<< REEMPLAZAR AQUÍ CON TU API KEY DE OPENAI
},
body: JSON.stringify({
model: 'text-davinci-003',
prompt: prompt,
max_tokens: 500,
n: 1,
stop: null,
temperature: 0.7
})
});
const data = await response.json();
const predica = data.choices[0].text.trim();
document.getElementById("outputPredica").textContent = predica;
} catch (error) {
console.error("Error al generar la predica:", error);
alert(currentLanguage === 'es' ? 'Error al generar la predica. Inténtalo de nuevo.' : 'Error generating sermon. Please try again.');
}
}
// Función para reiniciar los campos
function resetFields() {
document.getElementById("inputPhrase").value = '';
document.getElementById("outputPredica").textContent = '';
}
// Función para compartir la predica generada
function sharePredica() {
const predica = document.getElementById("outputPredica").textContent;
if (predica === '') {
alert(currentLanguage === 'es' ? 'No hay nada que compartir.' : 'There is nothing to share.');
return;
}
if (navigator.share) {
navigator.share({
title: 'Predica Generada',
text: predica,
}).then(() => {
console.log(“Predica compartida exitosamente.”);
}).catch((error) => {
console.error(“Error al compartir:”, error);
});
} else {
alert(currentLanguage === ‘es’ ? ‘Compartir no es compatible en este dispositivo.’ : ‘Sharing is not supported on this device.’);
}
}
// Función para mostrar el popup de donación
function showDonationPopup() {
document.getElementById(“donationPopup”).style.display = ‘block’;
}
// Función para cerrar el popup de donaciones
function closeDonationPopup() {
document.getElementById(“donationPopup”).style.display = ‘none’;
}
// Función para redirigir a PayPal
function redirectToPaypal() {
const paypalUrl = “https://www.paypal.com/donate?business=offlodors@gmail.com”; // <<< REEMPLAZAR AQUÍ CON TU EMAIL DE PAYPAL
window.open(paypalUrl, '_blank');
}
// Función para ingresar la información de tarjeta de crédito
function enterCreditCardInfo() {
alert(currentLanguage === 'es' ? 'Próximamente soporte para tarjeta de crédito.' : 'Credit card support coming soon.');
}
// Función para cambiar el idioma
function setLanguage(lang) {
currentLanguage = lang;
if (lang === 'es') {
document.getElementById("appTitle").textContent = "PHES - Predica Bíblica";
document.getElementById("inputLabel").textContent = "Escribe una palabra o frase:";
document.getElementById("searchBtn").textContent = "Buscar";
document.getElementById("resetBtn").textContent = "Reiniciar";
document.getElementById("outputTitle").textContent = "Predica Generada:";
document.getElementById("shareBtn").textContent = "Compartir";
document.getElementById("donateBtn").textContent = "Donar";
document.getElementById("spanishBtn").textContent = "Español";
document.getElementById("englishBtn").textContent = "English";
document.getElementById("donationTitle").textContent = "Donación";
document.getElementById("donationText").textContent = "Elige tu método de pago:";
document.getElementById("paypalBtn").textContent = "PayPal";
document.getElementById("creditCardBtn").textContent = "Tarjeta de Crédito";
} else {
document.getElementById("appTitle").textContent = "PHES - Biblical Sermon";
document.getElementById("inputLabel").textContent = "Enter a word or phrase:";
document.getElementById("searchBtn").textContent = "Search";
document.getElementById("resetBtn").textContent = "Reset";
document.getElementById("outputTitle").textContent = "Generated Sermon:";
document.getElementById("shareBtn").textContent = "Share";
document.getElementById("donateBtn").textContent = "Donate";
document.getElementById("spanishBtn").textContent = "Español";
document.getElementById("englishBtn").textContent = "English";
document.getElementById("donationTitle").textContent = "Donation";
document.getElementById("donationText").textContent = "Choose your payment method:";
document.getElementById("paypalBtn").textContent = "PayPal";
document.getElementById("creditCardBtn").textContent = "Credit Card";
}
displayRandomVerse(); // Recargar la cita bíblica con el nuevo idioma
}