Skip to content

Commit

Permalink
fortunes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schwartz committed Apr 9, 2024
1 parent dd5775d commit 31eaea7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 9 deletions.
23 changes: 23 additions & 0 deletions assets/js/authentification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { getAuth, createUserWithEmailAndPassword, sendEmailVerification } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-auth.js";
const auth = getAuth();

function signUpAndSendVerification(email, password) {
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCrential.user;

// Send Verification Email
sendEmailVerification(user)
.then(() => {
// Email verification sent
// Redirect user
});
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// Handle errors
// Display message
});
}
60 changes: 55 additions & 5 deletions assets/js/games.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function startGame() {
});
}
export function makeGuess(letter) {
console.log("Trying to disable button with ID:", "button-" + letter);

letter = letter.toLowerCase(); // Convert letter to lowercase
let wordToGuessLower = wordToGuess.toLowerCase(); // Convert wordToGuess to lowercase

Expand Down Expand Up @@ -137,11 +137,17 @@ function generateRandomSentence() {
const objectPronouns = ['me', 'you', 'him', 'her', 'them'];
const determiners = ['the', 'a', 'an', 'my', 'your'];
const nouns = ['cat', 'dog', 'pizza', 'music', 'car'];
const nounPhrases = ["a professor of linguistics", "a beacon of hope", "a voice of reason", "an explorer of truths"];
const actionVerbsIntransitive = ["walking", "dreaming", "leading", "striving"];
const actionVerbsTransitive = ["encouraging", "inspiring", "challenging", "supporting"];
const stateVerbsTransitive = ["have", "embody", "cherish", "seek"];
const objects = ["bright, powerful eyes", "an unbreakable spirit", "a keen mind", "a warm heart"];
const prepositionPhrases = ["in times of challenge", "with grace and courage", "beyond the horizons", "through the storms"];

// Verbs in their base form
const verbs = {
base: ['love', 'hate', 'enjoy', 'dislike', 'prefer'],
thirdPersonSingular: ['loves', 'hates', 'enjoys', 'dislikes', 'prefers']
base: ['love', 'convince','show', 'enjoy', 'dislike', 'prefer'],
thirdPersonSingular: ['loves', 'convinces', 'shows', 'enjoys', 'dislikes', 'prefers']
};
function isThirdPersonSingular(subject) {
return !['I', 'You', 'They'].includes(subject);
Expand Down Expand Up @@ -174,6 +180,29 @@ function generateRandomSentence() {
const object = getObject();

return `${subject} ${verb} ${object}.`;
// Fortune templates
const templates = [
"You are {NP} and you are {AVI} while {AVT} {Obj}.",
"You {SVT} {Obj}, {NP} {PP}."
];

function generateMotivationalFortune() {
const template = getRandomElement(templates);
const sentence = template
.replace("{NP}", getRandomElement(nounPhrases))
.replace("{AVI}", getRandomElement(actionVerbsIntransitive))
.replace("{AVT}", getRandomElement(actionVerbsTransitive))
.replace("{SVT}", getRandomElement(stateVerbsTransitive))
.replace("{Obj}", getRandomElement(objects))
.replace("{PP}", getRandomElement(prepositionPhrases));

return sentence.charAt(0).toUpperCase() + sentence.slice(1); // Capitalize the first letter
}

// Example usage
const fortune = generateMotivationalFortune();
console.log(fortune);

}

// Section 6 Analytics and Tracking
Expand Down Expand Up @@ -262,18 +291,39 @@ document.addEventListener('DOMContentLoaded', function() {
if (button) {
button.addEventListener('click', () => makeGuess(letter));
}

});

const fortuneButton = document.getElementById('Fortune');
const fortuneDisplay = document.getElementById('fortune-display'); // Make sure you have this element in your HTML

// // Check if the elements exist
// if (fortuneButton && fortuneDisplay) {
// // Add a click event listener to the button
// fortuneButton.addEventListener('click', function() {
// Generate a motivational fortune
// const fortune = generateMotivationalFortune();
// Display the fortune in the fortune-display element
// fortuneDisplay.textContent = fortune;
// });
// }

// Set up the random sentence generator form submission
const randomSentenceForm = document.getElementById('random');
if (randomSentenceForm) {
randomSentenceForm.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent traditional form submission
generateRandomSentence(); // Generate and display the sentence
});
const randomSentence = generateRandomSentence();
document.getElementById('random-sentence').textContent = randomSentence; // Display the generated sentence
});
}
// Example usage for the random sentence generator
const randomSentence = generateRandomSentence();
document.getElementById('random-sentence').textContent = randomSentence;
if (fortuneButton) {
fortuneButton.addEventListener('click', function() {
const fortune = generateMotivationalFortune();
fortuneDisplay.textContent = fortune; // Display the generated fortune
});
}
});
13 changes: 9 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!-- Header -->
<header id="header">
<h1>Learn Languages</h1>
<h1><a href= "https://labase.languapps.com"> An English Grammar for Learners</a></h1>
<!-- Hamburger Menu Button -->
<button class="hamburger-menu" id="hamburger-toggle">&#9776;</button>
<nav id="navigation">
Expand Down Expand Up @@ -96,14 +96,19 @@ <h2>Languapps</h2>
<section id="one" class="main style2 right dark fullscreen">
<div class="content box style2">
<header>
<h2>Get Random</h2>
<h2>Fortunes</h2>
<!-- Motivational Fortune Teller
<button id="Fortune">Generate Motivational Fortune</button>
<div id="fortune-display"></div> -->
<!-- Existing Random Sentence Generator -->
<form id="random">
<input type="submit" value="Generate">
<input type="submit" value="Cause">
</form>
<div id="random-sentence"></div>

</header>
<p data-translate="does">Digital Publishing<br>Review Software<br>Live stream<br>Independant<br>Writing Contests<br>Puppet Shows<br>Random Sentences!</p>
<div class="fb-login-button" data-width="" data-size="" data-button-type="" data-layout="" data-auto-logout-link="true" data-use-continue-as="true"></div>
<div id="random-sentence"></div>
</div>
<a href="#two" class="button style2 down anchored">Next</a>
</section>
Expand Down

0 comments on commit 31eaea7

Please sign in to comment.