|
@@ -0,0 +1,162 @@
|
|
1
|
+var RoomNameGenerator = function(my) {
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+ /**
|
|
5
|
+ * Constructs new RoomNameGenerator object.
|
|
6
|
+ * @constructor constructs new RoomNameGenerator object.
|
|
7
|
+ */
|
|
8
|
+ function RoomNameGeneratorProto()
|
|
9
|
+ {
|
|
10
|
+
|
|
11
|
+ }
|
|
12
|
+
|
|
13
|
+ /**
|
|
14
|
+ * Default separator the words in the room name
|
|
15
|
+ * @type {string}
|
|
16
|
+ */
|
|
17
|
+ var DEFAULT_SEPARATOR = "-";
|
|
18
|
+
|
|
19
|
+ /**
|
|
20
|
+ * Default number of words in the room name.
|
|
21
|
+ * @type {number}
|
|
22
|
+ */
|
|
23
|
+ var NUMBER_OF_WORDS = 3;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+ /**
|
|
27
|
+ * The list with words.
|
|
28
|
+ * @type {string[]}
|
|
29
|
+ */
|
|
30
|
+ var words = [
|
|
31
|
+ "definite ", "indefinite ", "articles", "name", "preposition ", "help", "very", "to", "through", "and", "just",
|
|
32
|
+ "a", "form", "in", "sentence", "is", "great", "it", "think", "you", "say", "that", "help", "he", "low", "was",
|
|
33
|
+ "line", "for", "differ", "on", "turn", "are", "cause", "with", "much", "as", "mean", "before", "his", "move",
|
|
34
|
+ "they", "right", "be", "boy", "at", "old", "one", "too", "have", "same", "this", "tell", "from", "does", "or",
|
|
35
|
+ "set", "had", "three", "by", "want", "hot", "air", "word", "well", "but", "also", "what", "play", "some", "small",
|
|
36
|
+ "we", "end", "can", "put", "out", "home", "other", "read", "were", "hand", "all", "port", "there", "large",
|
|
37
|
+ "when", "spell", "up", "add", "use", "even", "your", "land", "how", "here", "said", "must", "an", "big", "each",
|
|
38
|
+ "high", "she", "such", "which", "follow", "do", "act", "their", "why", "time", "ask", "if", "men", "will", "change",
|
|
39
|
+ "way", "went", "about", "light", "many", "kind", "then", "off", "them", "need", "write", "house", "would",
|
|
40
|
+ "picture", "like", "try", "so", "us", "these", "again", "her", "animal", "long", "point", "make", "mother",
|
|
41
|
+ "thing", "world", "see", "near", "him", "build", "two", "self", "has", "earth", "look", "father", "more", "head",
|
|
42
|
+ "day", "stand", "could", "own", "go", "page", "come", "should", "did", "country", "number", "found", "sound",
|
|
43
|
+ "answer", "no", "school", "most", "grow", "people", "study", "my", "still", "over", "learn", "know", "plant",
|
|
44
|
+ "water", "cover", "than", "food", "call", "sun", "first", "four", "who", "between", "may", "state", "down",
|
|
45
|
+ "keep", "side", "eye", "been", "never", "now", "last", "find", "let", "any", "thought", "new", "city", "work",
|
|
46
|
+ "tree", "part", "cross", "take", "farm", "get", "hard", "place", "start", "made", "might", "live", "story",
|
|
47
|
+ "where", "saw", "after", "far", "back", "sea", "little", "draw", "only", "left", "round", "late", "man", "run",
|
|
48
|
+ "year", "don't", "came", "while", "show", "press", "every", "close", "good", "night", "me", "real", "give",
|
|
49
|
+ "life", "our", "few", "under", "north", "open", "ten", "seem", "simple", "together", "several", "next", "vowel",
|
|
50
|
+ "white", "toward", "children", "war", "begin", "lay", "got", "against", "walk", "pattern", "example", "slow",
|
|
51
|
+ "ease", "center", "paper", "love", "group", "person", "always", "money", "music", "serve", "those", "appear",
|
|
52
|
+ "both", "road", "mark", "map", "often", "rain", "letter", "rule", "until", "govern", "mile", "pull", "river",
|
|
53
|
+ "cold", "car", "notice", "feet", "voice", "care", "unit", "second", "power", "book", "town", "carry", "fine",
|
|
54
|
+ "took", "certain", "science", "fly", "eat", "fall", "room", "lead", "friend", "cry", "began", "dark", "idea",
|
|
55
|
+ "machine", "fish", "note", "mountain", "wait", "stop", "plan", "once", "figure", "base", "star", "hear", "box",
|
|
56
|
+ "horse", "noun", "cut", "field", "sure", "rest", "watch", "correct", "color", "able", "face", "pound", "wood",
|
|
57
|
+ "done", "main", "beauty", "enough", "drive", "plain", "stood", "girl", "contain", "usual", "front", "young",
|
|
58
|
+ "teach", "ready", "week", "above", "final", "ever", "gave", "red", "green", "list", "oh", "though", "quick",
|
|
59
|
+ "feel", "develop", "talk", "ocean", "bird", "warm", "soon", "free", "body", "minute", "dog", "strong", "family",
|
|
60
|
+ "special", "direct", "mind", "pose", "behind", "leave", "clear", "song", "tail", "measure", "produce", "door",
|
|
61
|
+ "fact", "product", "street", "black", "inch", "short", "multiply", "numeral", "nothing", "class", "course", "wind",
|
|
62
|
+ "stay", "question", "wheel", "happen", "full", "complete", "force", "ship", "blue", "area", "object", "half",
|
|
63
|
+ "decide", "rock", "surface", "order", "deep", "fire", "moon", "south", "island", "problem", "foot", "piece",
|
|
64
|
+ "system", "told", "busy", "knew", "test", "pass", "record", "since", "boat", "top", "common", "whole", "gold",
|
|
65
|
+ "king", "possible", "space", "plane", "heard", "stead", "best", "dry", "hour", "wonder", "better", "laugh",
|
|
66
|
+ "true", "thousand", "during", "ago", "hundred", "ran", "five", "check", "remember", "game", "step", "shape",
|
|
67
|
+ "early", "equate", "hold", "hot", "west", "miss", "ground", "brought", "interest", "heat", "reach", "snow",
|
|
68
|
+ "fast", "tire", "verb", "bring", "sing", "yes", "listen", "distant", "six", "fill", "table", "east", "travel",
|
|
69
|
+ "paint", "less", "language", "morning", "among", "grand", "cat", "ball", "century", "yet", "consider", "wave",
|
|
70
|
+ "type", "drop", "law", "heart", "bit", "am", "coast", "present", "copy", "heavy", "phrase", "dance", "silent",
|
|
71
|
+ "engine", "tall", "position", "sand", "arm", "soil", "wide", "roll", "sail", "temperature", "material", "finger",
|
|
72
|
+ "size", "industry", "vary", "value", "settle", "fight", "speak", "lie", "weight", "beat", "general", "excite",
|
|
73
|
+ "ice", "natural", "matter", "view", "circle", "sense", "pair", "ear", "include", "else", "divide", "quite",
|
|
74
|
+ "syllable", "broke", "felt", "case", "perhaps", "middle", "pick", "kill", "sudden", "son", "count", "lake",
|
|
75
|
+ "square", "moment", "reason", "scale", "length", "loud", "represent", "spring", "art", "observe", "subject",
|
|
76
|
+ "child", "region", "straight", "energy", "consonant", "hunt", "nation", "probable", "dictionary", "bed", "milk",
|
|
77
|
+ "brother", "speed", "egg", "method", "ride", "organ", "cell", "pay", "believe", "age", "fraction", "section",
|
|
78
|
+ "forest", "dress", "sit", "cloud", "race", "surprise", "window", "quiet", "store", "stone", "summer", "tiny",
|
|
79
|
+ "train", "climb", "sleep", "cool", "prove", "design", "lone", "poor", "leg", "lot", "exercise", "experiment",
|
|
80
|
+ "wall", "bottom", "catch", "key", "mount", "iron", "wish", "single", "sky", "stick", "board", "flat", "joy",
|
|
81
|
+ "twenty", "winter", "skin", "sat", "smile", "written", "crease", "wild", "hole", "instrument", "trade", "kept",
|
|
82
|
+ "melody", "glass", "trip", "grass", "office", "cow", "receive", "job", "row", "edge", "mouth", "sign", "exact",
|
|
83
|
+ "visit", "symbol", "past", "die", "soft", "least", "fun", "trouble", "bright", "shout", "gas", "except",
|
|
84
|
+ "weather", "wrote", "month", "seed", "million", "tone", "bear", "join", "finish", "suggest", "happy", "clean",
|
|
85
|
+ "hope", "break", "flower", "lady", "clothe", "yard", "strange", "rise", "gone", "bad", "jump", "blow", "baby",
|
|
86
|
+ "oil", "eight", "blood", "village", "touch", "meet", "grew", "root", "cent", "buy", "mix", "raise", "team",
|
|
87
|
+ "solve", "wire", "metal", "cost", "whether", "lost", "push", "brown", "seven", "wear", "paragraph", "garden",
|
|
88
|
+ "third", "equal", "shall", "sent", "held", "choose", "hair", "fell", "describe", "fit", "cook", "flow", "floor",
|
|
89
|
+ "fair", "either", "bank", "result", "collect", "burn", "save", "hill", "control", "safe", "decimal", "rank",
|
|
90
|
+ "word", "reference", "gentle", "truck", "woman", "noise", "captain", "level",
|
|
91
|
+ "practice", "chance", "separate", "gather", "difficult", "shop", "doctor", "stretch", "please", "throw",
|
|
92
|
+ "protect", "shine", "noon", "property", "whose", "column", "locate", "molecule", "ring", "select", "character",
|
|
93
|
+ "wrong", "insect", "gray", "caught", "repeat", "period", "require", "indicate", "broad", "radio", "prepare",
|
|
94
|
+ "spoke", "salt", "atom", "nose", "human", "plural", "history", "anger", "effect", "claim", "electric",
|
|
95
|
+ "continent", "expect", "oxygen", "crop", "sugar", "modern", "death", "element", "pretty", "hit", "skill",
|
|
96
|
+ "student", "women", "corner", "season", "party", "solution", "supply", "magnet", "bone", "silver", "rail",
|
|
97
|
+ "thank", "imagine", "branch", "provide", "match", "agree", "suffix", "thus", "especially", "capital", "fig",
|
|
98
|
+ "won't", "afraid", "chair", "huge", "danger", "sister", "fruit", "steel", "rich", "discuss", "thick", "forward",
|
|
99
|
+ "soldier", "similar", "process", "guide", "operate", "experience", "guess", "score", "necessary", "apple",
|
|
100
|
+ "sharp", "bought", "wing", "led", "create", "pitch", "neighbor", "coat", "wash", "mass", "bat", "card", "rather",
|
|
101
|
+ "band", "crowd", "rope", "corn", "slip", "compare", "win", "poem", "dream", "string", "evening", "bell",
|
|
102
|
+ "condition", "depend", "feed", "meat", "tool", "rub", "total", "tube", "basic", "famous", "smell", "dollar",
|
|
103
|
+ "valley", "stream", "nor", "fear", "double", "sight", "seat", "thin", "arrive", "triangle", "master", "planet",
|
|
104
|
+ "track", "hurry", "parent", "chief", "shore", "colony", "division", "clock", "sheet", "mine", "substance", "tie",
|
|
105
|
+ "favor", "enter", "connect", "major", "post", "fresh", "spend", "search", "chord", "send", "fat", "yellow",
|
|
106
|
+ "glad", "gun", "original", "allow", "share", "print", "station", "dead", "dad", "spot", "bread", "desert",
|
|
107
|
+ "charge", "suit", "proper", "current", "bar", "lift", "offer", "rose", "segment", "continue", "slave", "block",
|
|
108
|
+ "duck", "chart", "instant", "hat", "market", "sell", "degree", "success", "populate", "company", "chick",
|
|
109
|
+ "subtract", "dear", "event", "enemy", "particular", "reply", "deal", "drink", "swim", "occur", "term", "support",
|
|
110
|
+ "opposite", "speech", "wife", "nature", "shoe", "range", "shoulder", "steam", "spread", "motion", "arrange",
|
|
111
|
+ "path", "camp", "liquid", "invent", "log", "cotton", "meant", "born", "quotient", "determine", "teeth", "quart",
|
|
112
|
+ "shell", "nine", "neck", "fancy", "fan", "football"
|
|
113
|
+ ];
|
|
114
|
+
|
|
115
|
+ /**
|
|
116
|
+ * Returns random word from the array of words.
|
|
117
|
+ * @returns {string} random word from the array of words.
|
|
118
|
+ */
|
|
119
|
+ function generateWord()
|
|
120
|
+ {
|
|
121
|
+ return words[( Math.round(((new Date().getTime() / 1000) +Math.random()*1000) % 1008))];
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ /**
|
|
125
|
+ * Generates new room name.
|
|
126
|
+ * @param separator the separator for the words.
|
|
127
|
+ * @param number_of_words number of words in the room name
|
|
128
|
+ * @returns {string} the room name
|
|
129
|
+ */
|
|
130
|
+ RoomNameGeneratorProto.generateRoom = function(separator, number_of_words)
|
|
131
|
+ {
|
|
132
|
+ if(!separator)
|
|
133
|
+ separator = DEFAULT_SEPARATOR;
|
|
134
|
+ if(!number_of_words)
|
|
135
|
+ number_of_words = NUMBER_OF_WORDS;
|
|
136
|
+ var name = "";
|
|
137
|
+ for(var i = 0; i<number_of_words; i++)
|
|
138
|
+ name += ((i != 0)? separator : "") + generateWord();
|
|
139
|
+ return name;
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ /**
|
|
143
|
+ * Generates new room name.
|
|
144
|
+ * @param number_of_words number of words in the room name
|
|
145
|
+ * @returns {string} the room name
|
|
146
|
+ */
|
|
147
|
+ RoomNameGeneratorProto.generateRoomWithoutSeparator = function(number_of_words)
|
|
148
|
+ {
|
|
149
|
+ if(!number_of_words)
|
|
150
|
+ number_of_words = NUMBER_OF_WORDS;
|
|
151
|
+ var name = "";
|
|
152
|
+ for(var i = 0; i<number_of_words; i++) {
|
|
153
|
+ var word = generateWord();
|
|
154
|
+ word = word.substring(0, 1).toUpperCase() + word.substring(1, word.length);
|
|
155
|
+ name += word ;
|
|
156
|
+ }
|
|
157
|
+ return name;
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ return RoomNameGeneratorProto;
|
|
161
|
+}();
|
|
162
|
+
|