-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
44 lines (43 loc) · 1.16 KB
/
script.js
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
$(document).ready(function(){
var ID = new Date().getTime();
setInterval(function () {$("#submit").click();}, 8000);
function IDchange(){
$('li').each(function(){
var currid = $(this).find("#user").text();
if(currid==ID){
$(this).find("#user").text("Me");
}
else {
$(this).find("#user").text("Stranger");
}
});
};
$("#submit").click(function(){
var text = $("#text").val();
$("#text").val('');
var currentdate = new Date();
var timestr = currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
// Returns successful data submission message when the entered information is stored in database.
if(text=='')
{
//alert("Please Fill All Fields");
text = '%'
}
var dataString = '$ID='+ ID +'&text='+ text + '&time=' + timestr;
//else
//{
// AJAX Code To Submit Form.
$.ajax({
type: 'POST',
url: 'chat',
data: dataString,
cache: false,
success: function(result){
$("#chatbox").html(result);
IDchange();
}
});
//}
return false;
});
});