Radlibz is an interactive, single-player game of MadLibs! No friends necessary! This application prompts the user for various parts of speech, names, places, and other words. These words are inserted into a corresponding story to create a new and hilarious tale every time! This story is then read aloud to the player in their chosen accent with our text to speech functionionality.
- Web Browser (Chrome, Safari, Firefox, etc)
- JavaScript
Copy the repository link.
https://github.com/amandalatkins/radlibz.git
Clone the repository to your local development environment
git clone https://github.com/amandalatkins/radlibz.git
Open index.html
in your preferred web browser
This code snippet shows the function that integrates the player's responses with the story sentences
// Takes the userResponses array and the sentences array (from the MabLibz API return object) and renders the story
function renderStory() {
// Create an empty string variable to concatenate onto as we run through our arrays
var storyHtml = "";
// Displays the title of the story
$("#storyTitle").text(title);
// Loop through all the sentences
for (var i = 0; i < sentences.length; i++) {
// As long as the sentences have content and aren't set to 0 (the api returns one 0)
if (sentences[i] !== "" && sentences[i] !== 0) {
// Replace this chracter combo with line breaks
var sentence = sentences[i].replace('\n','<br><br>');
// Replace this character with bullet point
sentence = sentence.replace('*','•');
// add sentence to story
storyHtml += sentence;
}
// Make sure there is a user response for this index
if (userResponses[i]) {
storyHtml += "<span class='user-word'>"+userResponses[i]+"</span>";
}
}
// append the story to the DOM
showStory.html(storyHtml);
speakText(showStory);
}
This code snippet shows how the app receives user inputs to read the completed story aloud
function speakText() {
// Get text from textbox.
var text = $('#showStory').text();
// Get selected voice from dropdown
var voice = $('#voiceselection').val()
// Speak it
responsiveVoice.speak(text, voice)
}
See also the list of contributors who participated in this project.
This project is licensed under the MIT License.
MadLibz API data is licened under the MIT License.
Merriam-Webster's Collegiate Thesaurus data is licensed according to their terms of service.
ResponsiveVoice-NonCommercial licensed under
Thanks to TailorBrands for assisting with the RadLibz logo. Special thanks to our instructor Jerome and TAs Mahisha and Kerwin for their ideas and guidance.