-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloworld.html
More file actions
executable file
·45 lines (38 loc) · 923 Bytes
/
helloworld.html
File metadata and controls
executable file
·45 lines (38 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<head>
<title>nowjs test</title>
<script src="/nowjs/now.js"></script>
<script type="text/javascript" src="/jquery.min.js"></script>
<script>
function talk() {
now.distributeMessage($('#text-input').val());
$("#text-input").val("");
}
$(document).ready(function(){
now.name = prompt("What's your name?", "");
now.receiveMessage = function(name, message){
addMessage(name+" : "+ message);
}
now.loginNotice = function(name) {
addMessage(name+" joined the chat...");
}
var addMessage = function(message) {
$("#messages").append('<br>'+message);
}
$("#send-button").click(function(){
talk();
});
$(window).keypress(function(e) {
if(e.keyCode == 13) {
talk();
}
});
});
</script>
</head>
<body>
<div id="messages"></div>
<input type="text" id="text-input" style="width: 400px;">
<input type="button" value="Send" id="send-button">
</body>
</html>