Basic user interface to create a MadLib. Write a story and put the part of speech that you want be blank in brackets.
Example: A boy named [Boy's Name] ate [Food] and it make him [Verb]!
/////////////////////////////////////////////////////
// Variables
/////////////////////////////////////////////////////
var defaultCopy = "My core skill sets are [core-skill-set-1] and [core-skill-set-2]. I'm endlessly [adjective-describing-self] and all my friends, family, and colleagues look to me for answers on [topic-1] and sometimes [topic-2]. As I've always been exceptionally passionate about [passion], I'm looking to [verb] focused on [specific-noun-phrase] so that I can [lofty-goal]."
var wordRegEx = /\[\s*[^\]]*]/g
var CopyArray = new Array()
var AnswerArray = new Array()
var Complete = false
/////////////////////////////////////////////////////
// Create HTML form element functions
/////////////////////////////////////////////////////
function formTable(){
return $("<div/>",{class:"myTable"})
}
function formRow(sectionTitle, subTitle, htmlElement) {
var Row = $("<div/>" ,{class:'myRow'})
var Cell1 = $("<div/>" ,{class:'myCell', text: sectionTitle})
var LabelSpan = $("<span/>" ,{class:'small' , text: subTitle})
var Cell2 = $("<div/>" ,{class:'myCell'})
$(Cell1).append(LabelSpan)
$(Cell2).append(htmlElement)
$(Row).append(Cell1).append(Cell2)
return Row
}
function formButton(passedText, passedFunction){
var Row = $("<div/>" ,{class:'myRow'})
var Cell1 = $("<div/>" ,{class:'myCell'})
var Cell2 = $("<div/>" ,{class:'myCell'})
var BTN = $("<button/>" ,{type:"button", text:passedText})
$(Cell2).append(BTN)
$(Row).append(Cell1).append(Cell2)
$(BTN).click(passedFunction)
return Row
}
/////////////////////////////////////////////////////
// Button functions
/////////////////////////////////////////////////////
// Finds words in brackets and then makes input feilds for them.
function makeImputs() {
Complete = false
var mainCopy = $("#madCopy").val()
var WordArray = mainCopy.match(wordRegEx)
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.