Skip to content

Commit

Permalink
Fixed the random name method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed Apr 12, 2012
1 parent ddfc5d2 commit 58a8728
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions app/assets/javascripts/backbone/views/channel_tabs.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ class Kandan.Views.ChannelTabs extends Backbone.View
@

createChannel: (event)->
channelName = prompt("What's the channel name?", Kandan.Views.ChannelTabs.randomChannelName())
names = [
"A Dark Place",
"Discotheque",
"Dungeon",
"Garden",
"Lobby",
"Office",
"Palace",
"Park",
"Studio",
"Temple",
"War Room",
"Zork"]

# Inefficient random method but there are only a few names so it's
# not an issue
name = _.shuffle(names)[0]

channelName = prompt("What's the channel name?", name)
channelName = channelName.replace(/^\s+|\s+$/g, '')
if channelName
channel = new Kandan.Models.Channel({name: channelName})
Expand All @@ -22,18 +40,3 @@ class Kandan.Views.ChannelTabs extends Backbone.View
channelIndex = $(event.target).parents('li').prevAll().length
Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0
return false

randomChannelName: () ->
names = [
"A Dark Place",
"Discotheque",
"Dungeon",
"Garden",
"Lobby",
"Office",
"Palace",
"Park",
"Studio",
"Temple",
"War Room",
"Zork"]

0 comments on commit 58a8728

Please sign in to comment.