-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
84 lines (60 loc) · 2.07 KB
/
index.html
File metadata and controls
84 lines (60 loc) · 2.07 KB
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
<script type="text/javascript">
function postIt(skipPost) {
if(skipPost) {
var t = "";
} else {
var t = document.getElementById("t").value;
}
var xhr = new XMLHttpRequest();
xhr.open("POST","/",false);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.send(t);
if(!skipPost) {
document.getElementById("t").value = "";
}
if(xhr.responseText.trim() != "") {
var scrollToBottom = ((window.innerHeight + window.scrollY) >= document.body.offsetHeight);
var messages = xhr.responseText.split("`").slice(1);
for(var i=0; i<messages.length;i++) {
var textColor = "#" + messages[i].split(";",1)[0];
var message = messages[i].split(";",2)[1];
var messageBox = document.createElement("div");
messageBox.style.borderRadius = "5px";
messageBox.style.border = "1px solid";
messageBox.style.backgroundColor = textColor;
messageBox.style.padding = "9px";
messageBox.style.color = "#000000";
messageBox.style.fontFamily = "Helvetica";
messageBox.style.display = "inline-block";
messageBox.style.marginBottom = "5px";
messageBox.appendChild(document.createTextNode(message));
var br = document.createElement("br");
document.getElementById("textBox").appendChild(messageBox);
document.getElementById("textBox").appendChild(br);
}
if(scrollToBottom) {
window.scrollTo(0,document.body.scrollHeight);
}
}
}
document.onkeypress = function (e) {
e = e || window.event;
if(e.keyCode == 13) {
postIt(false);
}
};
setInterval(postIt,1000,true);
</script>
<html style="background-color:#eeeeee">
<body style="margin-bottom:25px;">
<div id="wrapper" style="min-height:100%">
<div id="content" style="overflow:auto;">
<div id="textBox"></div>
</div>
<!--<input style="width:10;" type="button" value="send" onclick="postIt(false);">-->
</div>
</body>
<div id="footer">
<input style="position:fixed;height: 25px;bottom:0;left:0;right:0;width:100%;margin-bottom:0px;" type="text" id="t">
</div>
</html>