Hardy Boys Title Generator
Take the input text and create some output text in the style of the original.
by Dan Shahin
HTML
<script src="http://www.goodoldfashioned.com/js/markovmaker.js"></script>
<h4>Hardy Boys Title Generator</h4>
<textarea name="input" id="input" cols="30" rows="10">A Game Called Chaos
A Will to Survive
Attack of the Video Villains
Carnival of Crime
Crime in the Cards
Crime in the Kennel
Cross-Country Crime
Crusade of the Flaming Sword
Danger in the Extreme
Danger in the Fourth Dimension
Daredevils
Day of the Dinosaur
Double Jeopardy
Eye on Crime
Farming Fear
Fear on Wheels
Ghost of a Chance
Hidden Mountain
Hide-and-Sneak
High-Speed Showdown
In Plane Sight
Kickoff to Danger
Lost in Gator Swamp
Maximum Challenge
Motocross Madness
Mystery on Makatunk Island
Mystery with a Dangerous Beat
No Way Out
One False Step
Panic on Gull Island
Passport to Danger
Past And Present Danger
Racing to Disaster
Radical Moves
Reel Thrills
Rock 'n' Roll Renegades
Sabotage at Sports City
Sidetracked to Danger
Skin & Bones
Slam Dunk Sabotage
Speed Times Five
Terminal Shock
Terror at High Tide
The Alaskan Adventure
The Baseball Card Conspiracy
The Caribbean Cruise Caper
The Case of the Cosmic Kidnapping
The Case of the Counterfeit Criminals
The Case of the Psychic's Vision
The Castle Conundrum
The Chase for the Mystery Twister
The Cold Cash Caper
The Crisscross Crime
The Dangerous Transmission
The Demolition Mission
The Desert Thieves
The End of the Trail
The Giant Rat of Sumatra
The Hunt for the Four Brothers
The Hypersonic Secret
The Ice-Cold Case
The London Deception
The Lure of the Italian Treasure
The Mark of the Blue Tattoo
The Million-Dollar Nightmare
The Money Hunt
The Mystery in the Old Mine
The Mystery of the Black Rhino
The Prime-Time Crime
The Robot's Revenge
The Rocky Road to Revenge
The Search for the Snow Leopard
The Secret of Sigma Seven
The Secret of Skeleton Reef
The Secret of the Soldier's Gold
The Smoke Screen Mystery
The Spy that Never Lies
The Test Case
The Treasure at Dolphin Bay
Three-Ring Terror
Training for Trouble
Trial and Terror
Trick-or-Trouble
Tricks of the...
CSS
#input {
background-color: lightblue;
}
#output {
background-color: lightgreen;
}
#min {
width: 3em;
}
JavaScript
$('#generate').click(function () {
var input = $('#input').val(),
newText = generate(input)
$('#output').html(newText);
});
$('#reset').click(function () {
$('#output').html('');
});
function generate(input) {
return $.markovmaker(input,
{
punctuation: '.',
min_length : $('#min').val(),
punctuation_marks: /\n/,
word_splitter: /\s/
});
}
(function ($) {
var terminals = {};
var startwords = [];
var wordstats = {};
var sentences = [];
// Static method.
$.markovmaker = function (input,options) {
// Override default options with passed-in options.
options = $.extend({}, $.markovmaker.options, options);
// Return the name of your plugin plus a punctuation character.
var newString = markov(options,input);
return newString ;
};
// Static method default options.
$.markovmaker.options = {
punctuation: '.',
min_length : 2,
punctuation_marks: /\.|\;|\?|\:|\n/,
word_splitter: /\s/
};
function markov(options,input){
//options = $.extend({}, $.markovmaker.options, options);
terminals = {}; //properties are last words in sentences
startwords = []; //values are first words in sentences
wordstats = {}; // the markov chain
//split the input text into sentences
sentences = input.split(options.punctuation_marks);
//for each sentence
for (var i = 0; i < sentences.length; i++) {
//split sentence into words
var words = sentences[i].split(options.word_splitter);
//take note of last word in sentence
terminals[words[words.length - 1]] = true;
//take note of first word
startwords.push(words[0]);
//for each word
for (var j = 0; j < words.length - 1; j++) {
//build an object with word as property
//pointing to an arry of words that come after it
var thisWord = words[j],
nextWord = words[j + 1];
...