homepage/script.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-05-15 18:48:57 -05:00
let codingMode = false; // Set to true for coding mode (no api calls to bible passage)
//https://labs.bible.org/api/?passage=random&formatting=plain&type=text
async function fetchBiblePassage() {
try {
let textData;
if (codingMode == true) {
textData = 'Samuel 16:9 “And he said, "I now know de wae" in zimbabwe.';
} else {
const response = await fetch('https://labs.bible.org/api/?passage=random&formatting=plain&type=text');
textData = await response.text();
}
document.getElementById('biblepassage').textContent = `${textData}`;
} catch (error) {
console.error('Error fetching Bible passage:', error);
// Handle the error gracefully, e.g., display an error message to the user
}
}
fetchBiblePassage();
const searchButton = document.getElementById('search-button');
const searchInput = document.getElementById('search-input');
searchButton.addEventListener('click', () => {
const searchTerm = searchInput.value;
if (searchTerm) {
2024-05-28 11:16:39 -05:00
window.location.href = `https://search.brave.com/search?q=${searchTerm}`;
2024-05-15 18:48:57 -05:00
} else {
alert('Please enter a search term.');
}
});