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
18 changes: 9 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<link rel="shortcut icon" href="../ico/favicon.png">

<title>Wu-Tang Clan Rap Name Generator</title>


<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/animations.css">

</head>

<body>
Expand Down Expand Up @@ -42,15 +42,15 @@

<!--container -->
<div class="container">

<div class="welcome">
<div class='pulse'><img src="img/logo.png"></div>
<h1>Rap Name Generator</h1>
<p class='lead'>Do you want a crazy cool rap name like your favorite<br /> middle-aged rapper from the 90's supergroup Wu-Tang Clan?<br /><br />Enter your real first name below and click play!<p>
<h1>Rap Name Generator</h1>
<p class='lead'>Do you want a crazy cool rap name like your favorite<br /> middle-aged rapper from the 90's supergroup Wu-Tang Clan?<br /><br />Enter your real first name below and click play!<p>
</div>



<div class="input-group input-group-lg input-name">
<span class="input-group-btn">
<button class="btn btn-default" id="enter" type="button">
Expand All @@ -64,14 +64,14 @@ <h1>Rap Name Generator</h1>
<!--response -->
<div class='messages'>
<div class="alert alert-success response"></div>
<div class="alert alert-danger error"><strong>Oh snap!</strong> You forgot to enter a name!</div>
<div class="alert alert-danger error"><strong>Oh snap!</strong> You forgot to enter a name!</div>
</div>


</div>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="js/google-code-prettify/prettify.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</body>
</html>
66 changes: 62 additions & 4 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


/**
/**
* RAP NAME GENERATOR
* The user will insert their first name and on click receive one of several
* possible outputs (i.e. Jill).
Expand All @@ -20,13 +20,71 @@ function Generator() {

}

Generator.prototype.toAcronym = function(name) {
return name.split("").join(".").toUpperCase()+"."
}

Generator.prototype.toInitial = function(name) {
return name[0].toUpperCase()
}

//Add your codez here
Generator.prototype.append = function(name) {
return name + " " + this.last_names[Math.floor(Math.random() * this.last_names.length)]
}

Generator.prototype.prepend = function(name) {
return this.first_names[Math.floor(Math.random() * this.first_names.length)] + " " + name
}

Generator.prototype.sandwich = function(name) {
return this.prepend(this.append(name))
}

Generator.prototype.onlyLetters = function(name) {
return name.replace(/[^a-zA-Z]/g,"")
}

Generator.prototype.generate = function(name) {
var new_name;
switch (Math.floor(Math.random() * 3)) {
case 0:
new_name = name;
break;
case 1:
new_name = this.toAcronym(name);
break;
case 2:
new_name = this.toInitial(name);
break;
}
switch (Math.floor(Math.random() * 3)) {
case 0:
new_name = this.append(new_name);
break;
case 1:
new_name = this.prepend(new_name);
break;
case 2:
new_name = this.sandwich(new_name);
break;
}
return new_name;
}

$(document).ready(function() {

var engine = new Generator;
//Add your codez here
var engine = new Generator;

$('#enter').on('click', function(){
var input = engine.onlyLetters($('#user-input').val())
if (input !== "") {
$('.error').hide()
$('.response').html(engine.generate(input)).show()
} else {
$('.error').show()
$('.response').hide()
}
});


});