From 4514c2c49f0e0ec7cf9911dc254a8d20644d5def Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 5 Aug 2015 21:28:20 -0400 Subject: pushing messages into a div --- public/js/vendor/view/router.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'public/js/vendor') diff --git a/public/js/vendor/view/router.js b/public/js/vendor/view/router.js index 28905b2..ac2b5d4 100644 --- a/public/js/vendor/view/router.js +++ b/public/js/vendor/view/router.js @@ -15,7 +15,7 @@ var Router = View.extend({ } if (pathname in routes) { - this[this.routes[pathname]](null) + this[this.routes[pathname]]() return } @@ -27,27 +27,27 @@ var Router = View.extend({ var routePath = route.split("/") if (routePath[1] == path[1]) { if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) { - this[this.routes[route]](null, path[2]) + this[this.routes[route]](path[2]) return } else if (routePath[2] == path[2]) { if (routePath[3] && path[3]) { if (routePath[3].indexOf(":") !== -1) { - this[this.routes[route]](null, path[3]) + this[this.routes[route]](path[3]) return } else if (routePath[3] == path[3]) { - this[this.routes[route]](null) + this[this.routes[route]]() return } } else if (! routePath[3] && ! path[3]) { - this[this.routes[route]](null) + this[this.routes[route]]() return } } else if (! routePath[2] && (! path[2].length || ! path[2])) { - this[this.routes[route]](null) + this[this.routes[route]]() return } } -- cgit v1.2.3-70-g09d2 From 3c3a30c3676c1abef87b8faaf7921f9a7244730d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 6 Aug 2015 02:20:00 -0400 Subject: relocating events --- public/js/lib/views/room/chat.js | 5 ++--- public/js/lib/views/room/room.js | 9 +++------ public/js/vendor/util.js | 1 + 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'public/js/vendor') diff --git a/public/js/lib/views/room/chat.js b/public/js/lib/views/room/chat.js index 222522f..0932e47 100644 --- a/public/js/lib/views/room/chat.js +++ b/public/js/lib/views/room/chat.js @@ -24,8 +24,8 @@ var ChatView = View.extend({ this.seen[key] = true var $el = $( this.template ) - $el.find(".nick").html(msg.nick) - $el.find(".msg").html(msg.msg) + $el.find(".nick").html(sanitize(msg.nick)) + $el.find(".msg").html(sanitizeHTML(msg.msg)) this.$messages.append($el) if (! this.scrolled) { this.scrollToBottom() @@ -34,7 +34,6 @@ var ChatView = View.extend({ send: function(e){ e && e.preventDefault() - console.log("hi") var val = this.$msg.sanitize() this.$msg.focus() if (! val) return diff --git a/public/js/lib/views/room/room.js b/public/js/lib/views/room/room.js index 3b3b253..13f08ce 100644 --- a/public/js/lib/views/room/room.js +++ b/public/js/lib/views/room/room.js @@ -1,5 +1,3 @@ -var chat - var RoomView = View.extend({ events: { @@ -11,20 +9,19 @@ var RoomView = View.extend({ var base = this this.name = name - chat = this.chatView = new ChatView (socket) + this.chatView = new ChatView (socket) this.userlist = new UserlistView (socket) - app.socket.emit("join", { nick: user.username }) app.socket.on("welcome", function(room){ - room.messages.forEach(chat.add) + room.messages.forEach(base.chat.add) base.userlist.users = room.users base.userlist.update() }) app.socket.on("message", function(msg){ - chat.add(msg) + base.chat.add(msg) }) } diff --git a/public/js/vendor/util.js b/public/js/vendor/util.js index 73a25ad..3637f49 100644 --- a/public/js/vendor/util.js +++ b/public/js/vendor/util.js @@ -14,6 +14,7 @@ function trim (s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } function sanitize (s){ return (s || "").replace(new RegExp("[<>&]", 'g'), "") } function sanitizeName (s){ return (s || "").replace(new RegExp("[^-_a-zA-Z0-9]", 'g'), "") } function stripHTML (s){ return (s || "").replace(/<[^>]+>/g, "") } +function sanitizeHTML (s){ return (s || "").replace(/&/g, "&").replace(//g, ">") } function capitalize (s){ return s.split(" ").map(capitalizeWord).join(" ") } function capitalizeWord (s){ return s.charAt(0).toUpperCase() + s.slice(1) } function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g,"-") } -- cgit v1.2.3-70-g09d2