Permalink
Browse files

Generate random channel names.

  • Loading branch information...
1 parent 2b9f6dd commit cb1439152c389097c3857cb692338309dc769d19 @dv committed Jan 16, 2012
Showing with 22 additions and 1 deletion.
  1. +22 −1 index.html
View
@@ -55,7 +55,7 @@
$(function() {
if(!window.location.hash) {
- window.location.hash = "#BLABLABLA";
+ window.location.hash = "#" + createRandomWord(6);
}
label("channelname").html(window.location.hash);
@@ -102,5 +102,26 @@
return false;
});
});
+
+ // createRandomWord by James Padolsey
+ // http://james.padolsey.com/javascript/random-word-generator/
+ function createRandomWord(length) {
+ var consonants = 'bcdfghjklmnpqrstvwxyz',
+ vowels = 'aeiou',
+ rand = function(limit) {
+ return Math.floor(Math.random()*limit);
+ },
+ i, word='', length = parseInt(length,10),
+ consonants = consonants.split(''),
+ vowels = vowels.split('');
+
+ for (i=0;i<length/2;i++) {
+ var randConsonant = consonants[rand(consonants.length)],
+ randVowel = vowels[rand(vowels.length)];
+ word += randConsonant;
+ word += i*2<length-1 ? randVowel : '';
+ }
+ return word;
+ }
</script>
</body>

0 comments on commit cb14391

Please sign in to comment.