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
45 changes: 45 additions & 0 deletions js/script.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Generator
constructor: ->
@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'
]
@first_names = [
'Inspectah', 'Masta', 'Poppa',
'Five Foot', 'Ghostface', 'Old Dirty'
]
@transforms = [
((s) -> s.toUpperCase()[0]),
((s) -> s.toUpperCase().split('').join('.') + '.'),
((s) -> s.replace /s|S/g, '$$$$'),
((s) -> s)
]

get_name: (submitted_name) ->
structures = [
@first_names.random() + ' {}',
@first_names.random() + ' {} ' + @last_names.random(),
'{} ' + @last_names.random()
]

name = @transforms.random() submitted_name
structures.random().replace '{}', name

Array.prototype.random = -> @[Math.floor(Math.random() * @.length)]

engine = new Generator

$('.response, .error').hide()
$('#enter').click ->
$('.response, .error').hide()
input = $('#user-input').val()
if input.length > 0
name = engine.get_name input
$('.response').text name
$('.response').show()
else
$('.error').show()
true
87 changes: 55 additions & 32 deletions js/script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.