Permalink
Browse files

working.. able to display msg on browser

  • Loading branch information...
1 parent 9327bfb commit ec528d18d7a66ea6405f4e0453600ff9824cc2a1 @butu5 committed Aug 22, 2011
Showing with 37 additions and 4 deletions.
  1. +1 −0 .gitignore
  2. +4 −3 public/index.html
  3. +6 −0 public/js/client.coffee
  4. +8 −1 public/js/client.js
  5. +18 −0 public/js/jquery-1.6.2.min.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -2,15 +2,16 @@
<head>
<title>Hacker IRC</title>
<script src="/socket.io/socket.io.js"></script>
+ <script src="/js/jquery-1.6.2.min.js"></script>
<script src="/js/handlebars.1.0.0.beta.3.js"></script>
<script src="/js/client.js"></script>
- <script type='text/x-handlebars-template',id='entry-template'>
+ </head>
+ <body>
+ <script type='text/x-handlebars-template', id='msg-tmpl'>
<div class="msg">
<p>{{this.message}}</p>
</div>
</script>
- </head>
- <body>
<h1>Hacker IRC</h1>
<div id="msgs">
</div>
@@ -2,3 +2,9 @@ socket = io.connect "http://localhost"
socket.on "msg", (data) ->
console.log data
+ source = $("#msg-tmpl").html()
+ console.log source
+ source = source.replace(/\\n/g,"")
+ template = Handlebars.compile(source)
+ html = template(data)
+ $('#msgs').append(html)
View
@@ -2,6 +2,13 @@
var socket;
socket = io.connect("http://localhost");
socket.on("msg", function(data) {
- return console.log(data);
+ var html, source, template;
+ console.log(data);
+ source = $("#msg-tmpl").html();
+ console.log(source);
+ source = source.replace(/\\n/g, "");
+ template = Handlebars.compile(source);
+ html = template(data);
+ return $('#msgs').append(html);
});
}).call(this);
Oops, something went wrong.

0 comments on commit ec528d1

Please sign in to comment.