Skip to content

Commit 269350b

Browse files
committed
Makes sure /old is still functional
1 parent 598038e commit 269350b

File tree

5 files changed

+449
-47
lines changed

5 files changed

+449
-47
lines changed

app.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ presence.on 'change', ()->
9191

9292
# Render the homepage
9393
app.get "/", (req, res) ->
94+
res.sendfile "public/index.html"
95+
96+
app.get "/old", (req, res) ->
9497
res.sendfile "index.html"
9598

9699
app.listen process.env.PORT || 3000

index.html

+15-28
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,32 @@
33
<head>
44
<title>chat with sdslabs</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6-
<link rel="stylesheet" href="style.css">
7-
<link rel="stylesheet" href="normalize.css">
8-
<link rel="stylesheet" href="skeleton.css">
6+
<link rel="stylesheet" href="old-style.css">
97
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
108
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.4.0/jquery.timeago.min.js"></script>
119
<script src="//cdnjs.cloudflare.com/ajax/libs/mustache.js/0.8.1/mustache.min.js"></script>
1210
<script src="//cdn.jsdelivr.net/emojione/1.2.2/lib/js/emojione.min.js"></script>
1311
<link rel="stylesheet" href="//cdn.jsdelivr.net/emojione/1.2.2/assets/css/emojione.min.css" type="text/css" media="all">
1412
</head>
1513
<body>
16-
<div class="container u-full-width">
17-
<div class="row">
18-
<h2>chat</h2>
19-
</div>
20-
<div class="row u-full-width">
21-
<div class="ten columns u-full-width">
22-
<div class="channel-log u-full-width">
23-
<table>
24-
<tbody></tbody>
25-
</table>
14+
15+
<div id="slate">
16+
<div id="content">
17+
<div id="channels">
18+
<div class="channel focused">
19+
<h2>chat</h2>
20+
21+
<div class="channel-log">
22+
<table class="">
23+
<tbody>
24+
</tbody>
25+
</table>
26+
</div>
2627
</div>
2728
</div>
28-
<div class="two columns" id="userlist">
29-
List of users
30-
</div>
31-
</div>
32-
<div class="row">
33-
<textarea id="message-input" class="u-fill-width" placeholder="Message
34-
Start a message with ! to mark it private"></textarea>
3529
</div>
36-
</div>
37-
38-
3930

31+
<textarea id="message-input" placeholder="Message"></textarea>
4032
</div>
4133
<script src="/socket.io/socket.io.js"></script>
4234
<script src="app.js"></script>
@@ -47,10 +39,5 @@ <h2>chat</h2>
4739
<td class="date timeago" title="{{timestamp}}"></td>
4840
</tr>
4941
</script>
50-
<script id="template-users" type="x-tmpl-mustache">
51-
{{#users}}
52-
<h5>{{username}}</h5>
53-
{{/users}}
54-
</script>
5542
</body>
5643
</html>

public/app.js

+2-19
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@ $(function(){
1111

1212
// Compile template function
1313
var template = $('#template-message').text();
14-
var userTemplate = $('#template-users').text();
1514
Mustache.parse(template);
16-
Mustache.parse(userTemplate);
1715

1816
var app = {
1917
chatHandler: function(data){
2018
var timestamp = new Date(data.timestamp).toISOString();
2119
// Escape the message and run it through emojione
2220
var message = emojione.shortnameToImage(Mustache.escape(data.message));
23-
if(data.private){
24-
data.classes+=" private";
25-
}
2621
var templateData = {
2722
classes: data.classes,
2823
message: message,
@@ -39,7 +34,7 @@ $(function(){
3934
scrollTop: $('.channel-log')[0].scrollHeight
4035
});
4136
}
42-
};
37+
}
4338

4439
// Attach event handler
4540
$('#message-input').keydown(function(e){
@@ -64,28 +59,16 @@ $(function(){
6459
});
6560

6661
socket.on('chat:log', function(msgs){
67-
for(var i in msgs){
62+
for(i in msgs){
6863
var msg = msgs[i];
6964
app.chatHandler(msg);
7065
}
7166
// Scroll to Bottom after everything's done
7267
app.scroll();
7368
});
7469

75-
socket.on('presence:list', function(list){
76-
var data = list.map(function(u){
77-
return {"username": u};
78-
});
79-
data = {"users":data};
80-
console.log(data);
81-
var html = Mustache.render(userTemplate, data);
82-
console.log(html);
83-
$('#userlist').html(html);
84-
});
85-
8670
socket.on('connect', function(){
8771
socket.emit('chat:demand');
88-
socket.emit('presence:demand');
8972
});
9073
socket.on('reconnect', function(){
9174
$('#message-input').removeClass('disconnected').attr('placeholder', "Message");
File renamed without changes.

0 commit comments

Comments
 (0)