Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Rewrite with ES6
Illia Daynatovich4584d89c431a
diff --git a/app.js b/app.jsindex 987ff002e1..e39ce7637a 100644--- a/app.js+++ b/app.js@@ -24,7 +24,7 @@ const LogCollector = Logger.LogCollector;import JitsiMeetLogStorage from "./modules/util/JitsiMeetLogStorage";import URLProcessor from "./modules/config/URLProcessor";-import RoomnameGenerator from './modules/util/RoomnameGenerator';+import { generateRoomWithoutSeparator } from './modules/util/RoomnameGenerator';import UI from "./modules/UI/UI";import settings from "./modules/settings/Settings";@@ -75,7 +75,7 @@ function buildRoomName () {let roomName = getRoomName();if(!roomName) {- let word = RoomnameGenerator.generateRoomWithoutSeparator();+ let word = generateRoomWithoutSeparator();roomName = word.toLowerCase();let historyURL = window.location.href + word;//Trying to push state with current URL + roomNamediff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex 30fbcf58e9..db8845edcd 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -25,7 +25,7 @@ import SettingsMenu from "./side_pannels/settings/SettingsMenu";import Profile from "./side_pannels/profile/Profile";import Settings from "./../settings/Settings";import RingOverlay from "./ring_overlay/RingOverlay";-import RandomUtil from "../util/RandomUtil";+import { randomInt } from "../util/RandomUtil";import UIErrors from './UIErrors';import { debounce } from "../util/helpers";@@ -1100,8 +1100,7 @@ UI.notifyFocusDisconnected = function (focus, retrySec) {*/UI.showPageReloadOverlay = function (isNetworkFailure, reason) {// Reload the page after 10 - 30 seconds- PageReloadOverlay.show(- 10 + RandomUtil.randomInt(0, 20), isNetworkFailure, reason);+ PageReloadOverlay.show(10 + randomInt(0, 20), isNetworkFailure, reason);};/**diff --git a/modules/UI/welcome_page/WelcomePage.js b/modules/UI/welcome_page/WelcomePage.jsindex d722ebcf3b..0826e943f4 100644--- a/modules/UI/welcome_page/WelcomePage.js+++ b/modules/UI/welcome_page/WelcomePage.js@@ -1,8 +1,9 @@/* global $, interfaceConfig, APP */-var animateTimeout, updateTimeout;-var RoomnameGenerator = require("../../util/RoomnameGenerator");-import UIUtil from "../util/UIUtil";+import { generateRoomWithoutSeparator } from '../../util/RoomnameGenerator';+import UIUtil from '../util/UIUtil';++var animateTimeout, updateTimeout;function enter_room() {var val = $("#enter_room_field").val();@@ -23,7 +24,7 @@ function animate(word) {}function update_roomname() {- var word = RoomnameGenerator.generateRoomWithoutSeparator();+ var word = generateRoomWithoutSeparator();$("#enter_room_field").attr("room_name", word);$("#enter_room_field").attr("placeholder", "");clearTimeout(animateTimeout);diff --git a/modules/util/RandomUtil.js b/modules/util/RandomUtil.jsindex f82e094ad1..c1d6bde4a9 100644--- a/modules/util/RandomUtil.js+++ b/modules/util/RandomUtil.js@@ -1,73 +1,82 @@/**+ * Alphanumeric characters.* @const*/-var ALPHANUM = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';+const ALPHANUM+ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';/**- * Hexadecimal digits.+ * Hexadecimal digit characters.* @const*/-var HEX_DIGITS = '0123456789abcdef';+const HEX_DIGITS = '0123456789abcdef';/**- * Generates random int within the range [min, max]- * @param min the minimum value for the generated number- * @param max the maximum value for the generated number- * @returns random int number+ * Generate a string with random alphanumeric characters with a specific length.+ *+ * @param {number} length - The length of the string to return.+ * @returns {string} A string of random alphanumeric characters with the+ * specified length.*/-function randomInt(min, max) {- return Math.floor(Math.random() * (max - min + 1)) + min;+export function randomAlphanumString(length) {+ return _randomString(length, ALPHANUM);}/**- * Get random element from array or string.- * @param {Array|string} arr source- * @returns array element or string character+ * Get random element of array or string.+ *+ * @param {Array|string} arr - Source.+ * @returns {Array|string} Array element or string character.*/-function randomElement(arr) {- return arr[randomInt(0, arr.length -1)];+export function randomElement(arr) {+ return arr[randomInt(0, arr.length - 1)];}/**- * Generate random alphanumeric string.- * @param {number} length expected string length- * @returns {string} random string of specified length+ * Returns a random hex digit.+ *+ * @returns {Array|string}*/-function randomAlphanumStr(length) {- var result = '';+export function randomHexDigit() {+ return randomElement(HEX_DIGITS);+}- for (var i = 0; i < length; i += 1) {- result += randomElement(ALPHANUM);- }+/**+ * Generates a string of random hexadecimal digits with a specific length.+ *+ * @param {number} length - The length of the string to return.+ * @returns {string} A string of random hexadecimal digits with the specified+ * length.+ */+export function randomHexString(length) {+ return _randomString(length, HEX_DIGITS);+}- return result;+/**+ * Generates random int within the range [min, max].+ *+ * @param {number} min - The minimum value for the generated number.+ * @param {number} max - The maximum value for the generated number.+ * @returns {number} Random int number.+ */+export function randomInt(min, max) {+ return Math.floor(Math.random() * (max - min + 1)) + min;}/**- * Exported interface.+ * Generates a string of random characters with a specific length.+ *+ * @param {number} length - The length of the string to return.+ * @param {string} characters - The characters from which the returned string is+ * to be constructed.+ * @returns {string} A string of random characters with the specified length.*/-var RandomUtil = {- /**- * Returns a random hex digit.- * @returns {*}- */- randomHexDigit: function() {- return randomElement(HEX_DIGITS);- },- /**- * Returns a random string of hex digits with length 'len'.- * @param len the length.- */- randomHexString: function (len) {- var ret = '';- while (len--) {- ret += this.randomHexDigit();- }- return ret;- },- randomElement: randomElement,- randomAlphanumStr: randomAlphanumStr,- randomInt: randomInt-};+function _randomString(length, characters) {+ let result = '';-module.exports = RandomUtil;+ for (let i = 0; i < length; ++i) {+ result += randomElement(characters);+ }++ return result;+}diff --git a/modules/util/RoomnameGenerator.js b/modules/util/RoomnameGenerator.jsindex 4ed55d16e7..52a5c06341 100644--- a/modules/util/RoomnameGenerator.js+++ b/modules/util/RoomnameGenerator.js@@ -1,198 +1,240 @@-var RandomUtil = require('./RandomUtil');-//var nouns = [-//];-var pluralNouns = [- "Aliens", "Animals", "Antelopes", "Ants", "Apes", "Apples", "Baboons",- "Bacteria", "Badgers", "Bananas", "Bats", "Bears", "Birds", "Bonobos",- "Brides", "Bugs", "Bulls", "Butterflies", "Cheetahs", "Cherries", "Chicken",- "Children", "Chimps", "Clowns", "Cows", "Creatures", "Dinosaurs", "Dogs",- "Dolphins", "Donkeys", "Dragons", "Ducks", "Dwarfs", "Eagles", "Elephants",- "Elves", "Fathers", "Fish", "Flowers", "Frogs", "Fruit", "Fungi",- "Galaxies", "Geese", "Goats", "Gorillas", "Hedgehogs", "Hippos", "Horses",- "Hunters", "Insects", "Kids", "Knights", "Lemons", "Lemurs", "Leopards",- "LifeForms", "Lions", "Lizards", "Mice", "Monkeys", "Monsters", "Mushrooms",- "Octopodes", "Oranges", "Orangutans", "Organisms", "Pants", "Parrots",- "Penguins", "People", "Pigeons", "Pigs", "Pineapples", "Plants", "Potatoes",- "Priests", "Rats", "Reptiles", "Reptilians", "Rhinos", "Seagulls", "Sheep",- "Siblings", "Snakes", "Spaghetti", "Spiders", "Squid", "Squirrels",- "Stars", "Students", "Teachers", "Tigers", "Tomatoes", "Trees", "Vampires",- "Vegetables", "Viruses", "Vulcans", "Weasels", "Werewolves", "Whales",- "Witches", "Wizards", "Wolves", "Workers", "Worms", "Zebras"+import { randomElement } from './RandomUtil';++/*+const _NOUN_ = [+];+*/++/**+ * The list of plural nouns.+ * @const+ */+const _PLURALNOUN_ = [+ 'Aliens', 'Animals', 'Antelopes', 'Ants', 'Apes', 'Apples', 'Baboons',+ 'Bacteria', 'Badgers', 'Bananas', 'Bats', 'Bears', 'Birds', 'Bonobos',+ 'Brides', 'Bugs', 'Bulls', 'Butterflies', 'Cheetahs', 'Cherries', 'Chicken',+ 'Children', 'Chimps', 'Clowns', 'Cows', 'Creatures', 'Dinosaurs', 'Dogs',+ 'Dolphins', 'Donkeys', 'Dragons', 'Ducks', 'Dwarfs', 'Eagles', 'Elephants',+ 'Elves', 'Fathers', 'Fish', 'Flowers', 'Frogs', 'Fruit', 'Fungi',+ 'Galaxies', 'Geese', 'Goats', 'Gorillas', 'Hedgehogs', 'Hippos', 'Horses',+ 'Hunters', 'Insects', 'Kids', 'Knights', 'Lemons', 'Lemurs', 'Leopards',+ 'LifeForms', 'Lions', 'Lizards', 'Mice', 'Monkeys', 'Monsters', 'Mushrooms',+ 'Octopodes', 'Oranges', 'Orangutans', 'Organisms', 'Pants', 'Parrots',+ 'Penguins', 'People', 'Pigeons', 'Pigs', 'Pineapples', 'Plants', 'Potatoes',+ 'Priests', 'Rats', 'Reptiles', 'Reptilians', 'Rhinos', 'Seagulls', 'Sheep',+ 'Siblings', 'Snakes', 'Spaghetti', 'Spiders', 'Squid', 'Squirrels',+ 'Stars', 'Students', 'Teachers', 'Tigers', 'Tomatoes', 'Trees', 'Vampires',+ 'Vegetables', 'Viruses', 'Vulcans', 'Weasels', 'Werewolves', 'Whales',+ 'Witches', 'Wizards', 'Wolves', 'Workers', 'Worms', 'Zebras'+];++/*+const _PLACE_ = [+ 'Pub', 'University', 'Airport', 'Library', 'Mall', 'Theater', 'Stadium',+ 'Office', 'Show', 'Gallows', 'Beach', 'Cemetery', 'Hospital', 'Reception',+ 'Restaurant', 'Bar', 'Church', 'House', 'School', 'Square', 'Village',+ 'Cinema', 'Movies', 'Party', 'Restroom', 'End', 'Jail', 'PostOffice',+ 'Station', 'Circus', 'Gates', 'Entrance', 'Bridge'+];+*/++/**+ * The list of verbs.+ * @const+ */+const _VERB_ = [+ 'Abandon', 'Adapt', 'Advertise', 'Answer', 'Anticipate', 'Appreciate',+ 'Approach', 'Argue', 'Ask', 'Bite', 'Blossom', 'Blush', 'Breathe', 'Breed',+ 'Bribe', 'Burn', 'Calculate', 'Clean', 'Code', 'Communicate', 'Compute',+ 'Confess', 'Confiscate', 'Conjugate', 'Conjure', 'Consume', 'Contemplate',+ 'Crawl', 'Dance', 'Delegate', 'Devour', 'Develop', 'Differ', 'Discuss',+ 'Dissolve', 'Drink', 'Eat', 'Elaborate', 'Emancipate', 'Estimate', 'Expire',+ 'Extinguish', 'Extract', 'Facilitate', 'Fall', 'Feed', 'Finish', 'Floss',+ 'Fly', 'Follow', 'Fragment', 'Freeze', 'Gather', 'Glow', 'Grow', 'Hex',+ 'Hide', 'Hug', 'Hurry', 'Improve', 'Intersect', 'Investigate', 'Jinx',+ 'Joke', 'Jubilate', 'Kiss', 'Laugh', 'Manage', 'Meet', 'Merge', 'Move',+ 'Object', 'Observe', 'Offer', 'Paint', 'Participate', 'Party', 'Perform',+ 'Plan', 'Pursue', 'Pierce', 'Play', 'Postpone', 'Pray', 'Proclaim',+ 'Question', 'Read', 'Reckon', 'Rejoice', 'Represent', 'Resize', 'Rhyme',+ 'Scream', 'Search', 'Select', 'Share', 'Shoot', 'Shout', 'Signal', 'Sing',+ 'Skate', 'Sleep', 'Smile', 'Smoke', 'Solve', 'Spell', 'Steer', 'Stink',+ 'Substitute', 'Swim', 'Taste', 'Teach', 'Terminate', 'Think', 'Type',+ 'Unite', 'Vanish', 'Worship'+];++/**+ * The list of adverbs.+ * @const+ */+const _ADVERB_ = [+ 'Absently', 'Accurately', 'Accusingly', 'Adorably', 'AllTheTime', 'Alone',+ 'Always', 'Amazingly', 'Angrily', 'Anxiously', 'Anywhere', 'Appallingly',+ 'Apparently', 'Articulately', 'Astonishingly', 'Badly', 'Barely',+ 'Beautifully', 'Blindly', 'Bravely', 'Brightly', 'Briskly', 'Brutally',+ 'Calmly', 'Carefully', 'Casually', 'Cautiously', 'Cleverly', 'Constantly',+ 'Correctly', 'Crazily', 'Curiously', 'Cynically', 'Daily', 'Dangerously',+ 'Deliberately', 'Delicately', 'Desperately', 'Discreetly', 'Eagerly',+ 'Easily', 'Euphoricly', 'Evenly', 'Everywhere', 'Exactly', 'Expectantly',+ 'Extensively', 'Ferociously', 'Fiercely', 'Finely', 'Flatly', 'Frequently',+ 'Frighteningly', 'Gently', 'Gloriously', 'Grimly', 'Guiltily', 'Happily',+ 'Hard', 'Hastily', 'Heroically', 'High', 'Highly', 'Hourly', 'Humbly',+ 'Hysterically', 'Immensely', 'Impartially', 'Impolitely', 'Indifferently',+ 'Intensely', 'Jealously', 'Jovially', 'Kindly', 'Lazily', 'Lightly',+ 'Loudly', 'Lovingly', 'Loyally', 'Magnificently', 'Malevolently', 'Merrily',+ 'Mightily', 'Miserably', 'Mysteriously', 'NOT', 'Nervously', 'Nicely',+ 'Nowhere', 'Objectively', 'Obnoxiously', 'Obsessively', 'Obviously',+ 'Often', 'Painfully', 'Patiently', 'Playfully', 'Politely', 'Poorly',+ 'Precisely', 'Promptly', 'Quickly', 'Quietly', 'Randomly', 'Rapidly',+ 'Rarely', 'Recklessly', 'Regularly', 'Remorsefully', 'Responsibly',+ 'Rudely', 'Ruthlessly', 'Sadly', 'Scornfully', 'Seamlessly', 'Seldom',+ 'Selfishly', 'Seriously', 'Shakily', 'Sharply', 'Sideways', 'Silently',+ 'Sleepily', 'Slightly', 'Slowly', 'Slyly', 'Smoothly', 'Softly', 'Solemnly',+ 'Steadily', 'Sternly', 'Strangely', 'Strongly', 'Stunningly', 'Surely',+ 'Tenderly', 'Thoughtfully', 'Tightly', 'Uneasily', 'Vanishingly',+ 'Violently', 'Warmly', 'Weakly', 'Wearily', 'Weekly', 'Weirdly', 'Well',+ 'Well', 'Wickedly', 'Wildly', 'Wisely', 'Wonderfully', 'Yearly'];-//var places = [-// "Pub", "University", "Airport", "Library", "Mall", "Theater", "Stadium",-// "Office", "Show", "Gallows", "Beach", "Cemetery", "Hospital", "Reception",-// "Restaurant", "Bar", "Church", "House", "School", "Square", "Village",-// "Cinema", "Movies", "Party", "Restroom", "End", "Jail", "PostOffice",-// "Station", "Circus", "Gates", "Entrance", "Bridge"-//];-var verbs = [- "Abandon", "Adapt", "Advertise", "Answer", "Anticipate", "Appreciate",- "Approach", "Argue", "Ask", "Bite", "Blossom", "Blush", "Breathe", "Breed",- "Bribe", "Burn", "Calculate", "Clean", "Code", "Communicate", "Compute",- "Confess", "Confiscate", "Conjugate", "Conjure", "Consume", "Contemplate",- "Crawl", "Dance", "Delegate", "Devour", "Develop", "Differ", "Discuss",- "Dissolve", "Drink", "Eat", "Elaborate", "Emancipate", "Estimate", "Expire",- "Extinguish", "Extract", "Facilitate", "Fall", "Feed", "Finish", "Floss",- "Fly", "Follow", "Fragment", "Freeze", "Gather", "Glow", "Grow", "Hex",- "Hide", "Hug", "Hurry", "Improve", "Intersect", "Investigate", "Jinx",- "Joke", "Jubilate", "Kiss", "Laugh", "Manage", "Meet", "Merge", "Move",- "Object", "Observe", "Offer", "Paint", "Participate", "Party", "Perform",- "Plan", "Pursue", "Pierce", "Play", "Postpone", "Pray", "Proclaim",- "Question", "Read", "Reckon", "Rejoice", "Represent", "Resize", "Rhyme",- "Scream", "Search", "Select", "Share", "Shoot", "Shout", "Signal", "Sing",- "Skate", "Sleep", "Smile", "Smoke", "Solve", "Spell", "Steer", "Stink",- "Substitute", "Swim", "Taste", "Teach", "Terminate", "Think", "Type",- "Unite", "Vanish", "Worship"++/**+ * The list of adjectives.+ * @const+ */+const _ADJECTIVE_ = [+ 'Abominable', 'Accurate', 'Adorable', 'All', 'Alleged', 'Ancient', 'Angry',+ 'Anxious', 'Appalling', 'Apparent', 'Astonishing', 'Attractive', 'Awesome',+ 'Baby', 'Bad', 'Beautiful', 'Benign', 'Big', 'Bitter', 'Blind', 'Blue',+ 'Bold', 'Brave', 'Bright', 'Brisk', 'Calm', 'Camouflaged', 'Casual',+ 'Cautious', 'Choppy', 'Chosen', 'Clever', 'Cold', 'Cool', 'Crawly',+ 'Crazy', 'Creepy', 'Cruel', 'Curious', 'Cynical', 'Dangerous', 'Dark',+ 'Delicate', 'Desperate', 'Difficult', 'Discreet', 'Disguised', 'Dizzy',+ 'Dumb', 'Eager', 'Easy', 'Edgy', 'Electric', 'Elegant', 'Emancipated',+ 'Enormous', 'Euphoric', 'Evil', 'Fast', 'Ferocious', 'Fierce', 'Fine',+ 'Flawed', 'Flying', 'Foolish', 'Foxy', 'Freezing', 'Funny', 'Furious',+ 'Gentle', 'Glorious', 'Golden', 'Good', 'Green', 'Green', 'Guilty',+ 'Hairy', 'Happy', 'Hard', 'Hasty', 'Hazy', 'Heroic', 'Hostile', 'Hot',+ 'Humble', 'Humongous', 'Humorous', 'Hysterical', 'Idealistic', 'Ignorant',+ 'Immense', 'Impartial', 'Impolite', 'Indifferent', 'Infuriated',+ 'Insightful', 'Intense', 'Interesting', 'Intimidated', 'Intriguing',+ 'Jealous', 'Jolly', 'Jovial', 'Jumpy', 'Kind', 'Laughing', 'Lazy', 'Liquid',+ 'Lonely', 'Longing', 'Loud', 'Loving', 'Loyal', 'Macabre', 'Mad', 'Magical',+ 'Magnificent', 'Malevolent', 'Medieval', 'Memorable', 'Mere', 'Merry',+ 'Mighty', 'Mischievous', 'Miserable', 'Modified', 'Moody', 'Most',+ 'Mysterious', 'Mystical', 'Needy', 'Nervous', 'Nice', 'Objective',+ 'Obnoxious', 'Obsessive', 'Obvious', 'Opinionated', 'Orange', 'Painful',+ 'Passionate', 'Perfect', 'Pink', 'Playful', 'Poisonous', 'Polite', 'Poor',+ 'Popular', 'Powerful', 'Precise', 'Preserved', 'Pretty', 'Purple', 'Quick',+ 'Quiet', 'Random', 'Rapid', 'Rare', 'Real', 'Reassuring', 'Reckless', 'Red',+ 'Regular', 'Remorseful', 'Responsible', 'Rich', 'Rude', 'Ruthless', 'Sad',+ 'Scared', 'Scary', 'Scornful', 'Screaming', 'Selfish', 'Serious', 'Shady',+ 'Shaky', 'Sharp', 'Shiny', 'Shy', 'Simple', 'Sleepy', 'Slow', 'Sly',+ 'Small', 'Smart', 'Smelly', 'Smiling', 'Smooth', 'Smug', 'Sober', 'Soft',+ 'Solemn', 'Square', 'Square', 'Steady', 'Strange', 'Strong', 'Stunning',+ 'Subjective', 'Successful', 'Surly', 'Sweet', 'Tactful', 'Tense',+ 'Thoughtful', 'Tight', 'Tiny', 'Tolerant', 'Uneasy', 'Unique', 'Unseen',+ 'Warm', 'Weak', 'Weird', 'WellCooked', 'Wild', 'Wise', 'Witty', 'Wonderful',+ 'Worried', 'Yellow', 'Young', 'Zealous'];-var adverbs = [- "Absently", "Accurately", "Accusingly", "Adorably", "AllTheTime", "Alone",- "Always", "Amazingly", "Angrily", "Anxiously", "Anywhere", "Appallingly",- "Apparently", "Articulately", "Astonishingly", "Badly", "Barely",- "Beautifully", "Blindly", "Bravely", "Brightly", "Briskly", "Brutally",- "Calmly", "Carefully", "Casually", "Cautiously", "Cleverly", "Constantly",- "Correctly", "Crazily", "Curiously", "Cynically", "Daily", "Dangerously",- "Deliberately", "Delicately", "Desperately", "Discreetly", "Eagerly",- "Easily", "Euphoricly", "Evenly", "Everywhere", "Exactly", "Expectantly",- "Extensively", "Ferociously", "Fiercely", "Finely", "Flatly", "Frequently",- "Frighteningly", "Gently", "Gloriously", "Grimly", "Guiltily", "Happily",- "Hard", "Hastily", "Heroically", "High", "Highly", "Hourly", "Humbly",- "Hysterically", "Immensely", "Impartially", "Impolitely", "Indifferently",- "Intensely", "Jealously", "Jovially", "Kindly", "Lazily", "Lightly",- "Loudly", "Lovingly", "Loyally", "Magnificently", "Malevolently", "Merrily",- "Mightily", "Miserably", "Mysteriously", "NOT", "Nervously", "Nicely",- "Nowhere", "Objectively", "Obnoxiously", "Obsessively", "Obviously",- "Often", "Painfully", "Patiently", "Playfully", "Politely", "Poorly",- "Precisely", "Promptly", "Quickly", "Quietly", "Randomly", "Rapidly",- "Rarely", "Recklessly", "Regularly", "Remorsefully", "Responsibly",- "Rudely", "Ruthlessly", "Sadly", "Scornfully", "Seamlessly", "Seldom",- "Selfishly", "Seriously", "Shakily", "Sharply", "Sideways", "Silently",- "Sleepily", "Slightly", "Slowly", "Slyly", "Smoothly", "Softly", "Solemnly",- "Steadily", "Sternly", "Strangely", "Strongly", "Stunningly", "Surely",- "Tenderly", "Thoughtfully", "Tightly", "Uneasily", "Vanishingly",- "Violently", "Warmly", "Weakly", "Wearily", "Weekly", "Weirdly", "Well",- "Well", "Wickedly", "Wildly", "Wisely", "Wonderfully", "Yearly"++/*+const _PRONOUN_ = [];-var adjectives = [- "Abominable", "Accurate", "Adorable", "All", "Alleged", "Ancient", "Angry",- "Anxious", "Appalling", "Apparent", "Astonishing", "Attractive", "Awesome",- "Baby", "Bad", "Beautiful", "Benign", "Big", "Bitter", "Blind", "Blue",- "Bold", "Brave", "Bright", "Brisk", "Calm", "Camouflaged", "Casual",- "Cautious", "Choppy", "Chosen", "Clever", "Cold", "Cool", "Crawly",- "Crazy", "Creepy", "Cruel", "Curious", "Cynical", "Dangerous", "Dark",- "Delicate", "Desperate", "Difficult", "Discreet", "Disguised", "Dizzy",- "Dumb", "Eager", "Easy", "Edgy", "Electric", "Elegant", "Emancipated",- "Enormous", "Euphoric", "Evil", "Fast", "Ferocious", "Fierce", "Fine",- "Flawed", "Flying", "Foolish", "Foxy", "Freezing", "Funny", "Furious",- "Gentle", "Glorious", "Golden", "Good", "Green", "Green", "Guilty",- "Hairy", "Happy", "Hard", "Hasty", "Hazy", "Heroic", "Hostile", "Hot",- "Humble", "Humongous", "Humorous", "Hysterical", "Idealistic", "Ignorant",- "Immense", "Impartial", "Impolite", "Indifferent", "Infuriated",- "Insightful", "Intense", "Interesting", "Intimidated", "Intriguing",- "Jealous", "Jolly", "Jovial", "Jumpy", "Kind", "Laughing", "Lazy", "Liquid",- "Lonely", "Longing", "Loud", "Loving", "Loyal", "Macabre", "Mad", "Magical",- "Magnificent", "Malevolent", "Medieval", "Memorable", "Mere", "Merry",- "Mighty", "Mischievous", "Miserable", "Modified", "Moody", "Most",- "Mysterious", "Mystical", "Needy", "Nervous", "Nice", "Objective",- "Obnoxious", "Obsessive", "Obvious", "Opinionated", "Orange", "Painful",- "Passionate", "Perfect", "Pink", "Playful", "Poisonous", "Polite", "Poor",- "Popular", "Powerful", "Precise", "Preserved", "Pretty", "Purple", "Quick",- "Quiet", "Random", "Rapid", "Rare", "Real", "Reassuring", "Reckless", "Red",- "Regular", "Remorseful", "Responsible", "Rich", "Rude", "Ruthless", "Sad",- "Scared", "Scary", "Scornful", "Screaming", "Selfish", "Serious", "Shady",- "Shaky", "Sharp", "Shiny", "Shy", "Simple", "Sleepy", "Slow", "Sly",- "Small", "Smart", "Smelly", "Smiling", "Smooth", "Smug", "Sober", "Soft",- "Solemn", "Square", "Square", "Steady", "Strange", "Strong", "Stunning",- "Subjective", "Successful", "Surly", "Sweet", "Tactful", "Tense",- "Thoughtful", "Tight", "Tiny", "Tolerant", "Uneasy", "Unique", "Unseen",- "Warm", "Weak", "Weird", "WellCooked", "Wild", "Wise", "Witty", "Wonderful",- "Worried", "Yellow", "Young", "Zealous"- ];-//var pronouns = [-//];-//var conjunctions = [-//"And", "Or", "For", "Above", "Before", "Against", "Between"-//];+*//*+const _CONJUNCTION_ = [+ 'And', 'Or', 'For', 'Above', 'Before', 'Against', 'Between'+];+*/++/*** Maps a string (category name) to the array of words from that category.+ * @const*/-var CATEGORIES =-{- //"_NOUN_": nouns,- "_PLURALNOUN_": pluralNouns,- //"_PLACE_": places,- "_VERB_": verbs,- "_ADVERB_": adverbs,- "_ADJECTIVE_": adjectives- //"_PRONOUN_": pronouns,- //"_CONJUNCTION_": conjunctions,+const CATEGORIES = {+ _ADJECTIVE_,+ _ADVERB_,+ _PLURALNOUN_,+ _VERB_++// _CONJUNCTION_,+// _NOUN_,+// _PLACE_,+// _PRONOUN_,};-var PATTERNS = [- "_ADJECTIVE__PLURALNOUN__VERB__ADVERB_"+/**+ * The list of room name patterns.+ * @const+ */+const PATTERNS = [+ '_ADJECTIVE__PLURALNOUN__VERB__ADVERB_'// BeautifulFungiOrSpaghetti- //"_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_",+// '_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_',// AmazinglyScaryToy- //"_ADVERB__ADJECTIVE__NOUN_",+// '_ADVERB__ADJECTIVE__NOUN_',// NeitherTrashNorRifle- //"Neither_NOUN_Nor_NOUN_",- //"Either_NOUN_Or_NOUN_",+// 'Neither_NOUN_Nor_NOUN_',+// 'Either_NOUN_Or_NOUN_',// EitherCopulateOrInvestigate- //"Either_VERB_Or_VERB_",- //"Neither_VERB_Nor_VERB_",+// 'Either_VERB_Or_VERB_',+// 'Neither_VERB_Nor_VERB_',- //"The_ADJECTIVE__ADJECTIVE__NOUN_",- //"The_ADVERB__ADJECTIVE__NOUN_",- //"The_ADVERB__ADJECTIVE__NOUN_s",- //"The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_",+// 'The_ADJECTIVE__ADJECTIVE__NOUN_',+// 'The_ADVERB__ADJECTIVE__NOUN_',+// 'The_ADVERB__ADJECTIVE__NOUN_s',+// 'The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_',// WolvesComputeBadly- //"_PLURALNOUN__VERB__ADVERB_",+// '_PLURALNOUN__VERB__ADVERB_',// UniteFacilitateAndMerge- //"_VERB__VERB_And_VERB_",+// '_VERB__VERB_And_VERB_',- //NastyWitchesAtThePub- //"_ADJECTIVE__PLURALNOUN_AtThe_PLACE_",+ // NastyWitchesAtThePub+// '_ADJECTIVE__PLURALNOUN_AtThe_PLACE_',];-/*- * Returns true if the string 's' contains one of the- * template strings.+/**+ * Generates a new room name.+ *+ * @returns {string} A newly-generated room name.*/-function hasTemplate(s) {- for (var template in CATEGORIES){- if (s.indexOf(template) >= 0){- return true;+export function generateRoomWithoutSeparator() {+ // XXX Note that if more than one pattern is available, the choice of 'name'+ // won't have a uniform distribution amongst all patterns (names from+ // patterns with fewer options will have higher probability of being chosen+ // that names from patterns with more options).+ let name = randomElement(PATTERNS);++ while (hasTemplate(name)) {+ for (const template in CATEGORIES) { // eslint-disable-line guard-for-in+ const word = randomElement(CATEGORIES[template]);++ name = name.replace(template, word);}}++ return name;}/**- * Generates new room name.+ * Determines whether a specific string contains at least one of the+ * templates/categories.+ *+ * @param {string} s - String containing categories.+ * @returns {boolean} True if the specified string contains at least one of the+ * templates/categories; otherwise, false.*/-var RoomnameGenerator = {- generateRoomWithoutSeparator: function() {- // Note that if more than one pattern is available, the choice of- // 'name' won't have a uniform distribution amongst all patterns (names- // from patterns with fewer options will have higher probability of- // being chosen that names from patterns with more options).- var name = RandomUtil.randomElement(PATTERNS);- var word;- while (hasTemplate(name)) {- for (var template in CATEGORIES) {- word = RandomUtil.randomElement(CATEGORIES[template]);- name = name.replace(template, word);- }+function hasTemplate(s) {+ for (const template in CATEGORIES) {+ if (s.indexOf(template) >= 0) {+ return true;}-- return name;}-};-module.exports = RoomnameGenerator;+ return false;+}