-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
141 lines (123 loc) · 3.17 KB
/
index.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<html>
<head>
<style>
#name
{
text-decoration:bold;
font-size:24px;
font-family:Georgia;
}
#name1
{
font-weight:bold;
}
.textbox {
background-color:#FFFFFF;
background-repeat: no-repeat;
background-position:left;
width:270px;
font:normal 16px Arial;
height:35px;
color: #787878;
padding:3px 5px 3px 19px;
border:1px solid black;
margin-left:0px;
margin-top:8px;
}
.buttons {
background:black;
font-size:12px;
color: #fff;
padding: 6px 14px;
border-width: 2px;
border-style: solid;
border-color: #fff #d8d8d0 #d8d8d0 #fff;
text-decoration: none;
text-transform:uppercase;
font-weight:bold;
}
.buttons:hover {
cursor:pointer;
opacity:.8;
}
.button_div {
width:287px;
float:left;
text-align:left;
height:35px;
margin-top:3px;
padding:5px 32px 3px;
margin-left:115px;
}
</style>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="nowjs/now.js"></script>
<script>
$(function(){
var name = prompt("What's your first name?", "");
name = name.replace(/ /g,"_");
$("#online").prepend("<span id = 'name'>Hello, "+ name + "<br /><br /></span>").addClass("name");
$("body").mouseover(function(){
now.distributeAlert(name);
});
$("body").one("mouseover", function(){
now.printDatabase();
});
now.peopleOnline = function(name){
addPeople(name);
};
now.receiveMessage = function(name, msg){
$("<div></div>").html("<span id='name1'>"+ name + "</span>: " + msg).appendTo("#msg");
};
$("#chatForm").submit(function(){
now.distributeMessage(name,$("#text-input").val());
now.saveDB(name, $("#text-input").val());
$("#text-input").val("");
return false;
});
//A user closes the browser window
$(window).unload(function() {
//Call the leaving function on the server
now.leaving(name);
});
now.removeUsers = function(name){
removePeople(name);
};
now.printData = function(name, body){
$("#msg").append("<span id = 'name1'>"+ name+ "</span>: "+ body +"<br />");
};
});
</script>
</head>
<body>
<div id = "right" style="float:left;width:400px;border:1px solid dashed">
<div id="online">People Online</div>
</div>
<div id = "left" style="float:left;width:400px;">
<form id = "chatForm">
<input type="text" id="text-input" class="textbox" />
<input type="submit" value="Send Message" id="send-button" class="buttons">
</form>
<div id="msg" style="width:400px;height:500px;overflow:scroll;border: 1px solid black"></div>
</div>
<script type="text/javascript">
function addPeople(person)
{
var personToAdd = "#"+ person;
if($(personToAdd).length > 0)
{
}
else
{
$("#right").append("<div style='float:left;' id="+ person +"><br /><br /> "+ person +"<img src = 'http://timemap.googlecode.com/svn/tags/2.0/images/green-circle.png' style='margin-bottom:-3px;float:left;' /></div><br /><br /><br />");
}
}
function removePeople(person)
{
var personToRemove = "#"+ person;
$(personToRemove).hide();
}
</script>
</body>
</html>