Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

modifica per gestire url param nell'index.html

  • Loading branch information...
commit 9d818d55374b6dd9a802c406a5f2f1e21e5dbbb3 1 parent ccb2d1a
unknown authored
Showing with 16 additions and 3 deletions.
  1. +2 −2 demo/chat.js
  2. +14 −1 demo/web/js/client.js
View
4 demo/chat.js
@@ -10,7 +10,7 @@ chatServer.listen(8001);
// create a channel and log all activity to stdout
chatServer.addChannel({
- basePath: "/chat"
+ basePath: "/chat/1"
}).addListener("msg", function(msg) {
sys.puts("1 <" + msg.nick + "> " + msg.text);
}).addListener("join", function(msg) {
@@ -20,7 +20,7 @@ chatServer.addChannel({
});
chatServer.addChannel({
- basePath: "/chat2"
+ basePath: "/chat/2"
}).addListener("msg", function(msg) {
sys.puts("2 <" + msg.nick + "> " + msg.text);
}).addListener("join", function(msg) {
View
15 demo/web/js/client.js
@@ -1,8 +1,21 @@
(function($) {
+var urlParams = {};
+(function () {
+ var e,
+ a = /\+/g, // Regex for replacing addition symbol with a space
+ r = /([^&=]+)=?([^&]*)/g,
+ d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
+ q = window.location.search.substring(1);
+
+ while (e = r.exec(q))
+ urlParams[d(e[1])] = d(e[2]);
+})();
+
+
var title = document.title,
colors = ["green", "orange", "yellow", "red", "fuschia", "blue"],
- channel = nodeChat.connect("/chat"),
+ channel = nodeChat.connect("/chat/" + urlParams["ch"]),
log,
message;
Please sign in to comment.
Something went wrong with that request. Please try again.