Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ <h1>Rap Name Generator</h1>
<script src="js/google-code-prettify/prettify.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$(document).ready(function() {
setFormBindings();
});

function setFormBindings() {
$('#enter').on('click', function() {
var user_input = $('#user-input').val();
if (user_input) {
var engine = new Generator;
var name = engine.generateName(user_input);
$('.response').html(name).show();
} else {
$('.error').show();
}
});

$('#user-input').focus(function() {
$('.error').hide();
$('.response').html("").hide();
});

}
26 changes: 13 additions & 13 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


/**
* RAP NAME GENERATOR
* The user will insert their first name and on click receive one of several
Expand All @@ -13,20 +11,22 @@
**/

function Generator() {

/* Name Arrays: Customize names to change possible output */
this.last_names = ['the Chef', 'Digital', 'Wise', 'Knight', 'Wrecka', 'the Genius', 'the Zoo Keeper', 'the Monk', 'the Scientist', 'the Disciple', 'the Darkman', 'Pellegrino', 'the Ill Figure', 'Rocks The World', 'the Baptist',];
this.last_names = ['the Chef', 'Digital', 'Wise', 'Knight', 'Wrecka', 'the Genius', 'the Zoo Keeper', 'the Monk', 'the Scientist', 'the Disciple', 'the Darkman', 'Pellegrino', 'the Ill Figure', 'Rocks The World', 'the Baptist', ];
this.first_names = ['Inspectah', 'Masta', 'Poppa', 'Five Foot', 'Ghostface', 'Old Dirty'];

}

Generator.prototype.generateName = function(actualName) {
var firstname = this.getRandomName(this.first_names);
var lastname = this.getRandomName(this.last_names);
var maybeMiddle = Math.floor((Math.random() * 2) + 0) == 0 ? actualName + " " : "";
return firstname + " " + maybeMiddle + lastname;
}

//Add your codez here


$(document).ready(function() {

var engine = new Generator;
//Add your codez here
Generator.prototype.getRandomPosition = function(array) {
return Math.floor((Math.random() * array.length) + 0);
}

});
Generator.prototype.getRandomName = function(names) {
return names[this.getRandomPosition(names)];
}