Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactors in client loading code

  • Loading branch information...
commit 26de2711d9d74de251c0b37677ee63289a6d4a0d 1 parent a79e807
Pablo authored
Showing with 10 additions and 9 deletions.
  1. +10 −9 js/client.js
View
19 js/client.js
@@ -1,30 +1,31 @@
$(function () {
- var nick = "user" + ~~(Math.random() * 1000);
- var channel = "#teambox";
- var server = "talker-bridge.jit.su:80";
+ var config = { nick: "user" + ~~(Math.random() * 1000)
+ , channel: "#teambox"
+ , server: "talker-bridge.jit.su:80"
+ };
// get channel from url params
var c = window.location.href.match(/channel=([a-zA-Z0-9]*)/);
if (c && c[1]){
- channel = '#'+c[1];
+ config.channel = '#'+c[1];
}
// get server from url params
var s = window.location.href.match(/server=([a-zA-Z0-9:\.]*)/);
if (s && s[1]){
- server = s[1];
+ config.server = s[1];
}
// get nick from url params
var n = window.location.href.match(/nick=([a-zA-Z0-9]*)/);
if (n && n[1]){
- nick = n[1];
+ config.nick = n[1];
} else {
- nick = prompt("Choose a nickname for the chat:");
- window.location = window.location + "?nick=" + nick;
+ config.nick = prompt("Choose a nickname for the chat:") || config.nick;
+ window.location = (window.location + "&nick=" + config.nick).replace(/\/&/, "&");
}
// Start Talker client
- Talker.client.connect(server, channel, nick);
+ Talker.client.connect(config.server, config.channel, config.nick);
});
Please sign in to comment.
Something went wrong with that request. Please try again.