-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.html
168 lines (139 loc) · 3.89 KB
/
board.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<title>SMS Board</title>
<link rel='stylesheet' href='sprite/emoji.css' >
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<script src="/js/jquery-1.12.1.min"></script>
<script src="/js/jquery-ui.js"></script>
<script src="/socket.io/socket.io.js">
</script>
<style>
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
height: 100px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
<script>
const toDisplay = 4; //define the number of messages to show
var iosocket;
var currentMessageCount = 0;
var newDiv;
var mynumber;
function getColor(num){
switch(num){
case 0:
return "#428bca"; //blue
break;
case 1:
return "#5cb85c"; //green
break;
case 2:
return "#5bc0de"; //lightblue
break;
case 3:
return "#f0ad4e"; //orange
break;
case 4:
return "#d9534f"; //red
break;
}
}
function initSocketIO()
{
iosocket = io.connect();
iosocket.on('clientrefresh', function() {
location.reload();
});
iosocket.on('connect', function() {
iosocket.on('debugMessage', function(message) {
alert(message);
});
iosocket.on('config', function(phonenumber) {
mynumber = phonenumber;
$( "span.number" ).html(mynumber);
});
iosocket.on('newMessage', function(time,number,message,color) {
var censoredNumber = number.substring(0,3) + "********" +number.substring(number.length - 3, number.length);
var messages = document.getElementById('messagesBody');
newDiv = document.createElement('div');
var newH1 = document.createElement('h1');
var newP = document.createElement('p');
newH1.innerHTML = message;
newP.innerHTML = "by "+censoredNumber+" at "+time;
newDiv.style.backgroundColor = getColor(color); //need this on both for some browsers (especially safari) to recognize...
newDiv.style="background-color:"+getColor(color)+" !important; padding:10px 0; margin:10px 0;";
newDiv.className="jumbotron";
newDiv.appendChild(newH1);
newDiv.appendChild(newP);
currentMessageCount++;
if(currentMessageCount > toDisplay)
{
//Remove the top div
$('#messagesBody').find('div').first().slideUp(function() {
$(this).remove();
document.getElementById('messagesBody').appendChild(newDiv);
});
currentMessageCount--;
}else{
document.getElementById('messagesBody').appendChild(newDiv);
}
});
});
}
function initButton()
{
$("#check").button();
}
window.onload = function() {
initSocketIO();
iosocket.emit('getLastMessages',toDisplay);
iosocket.emit('getConfig');
};
$(document).ready(function() {
$('#check').click(function() {
iosocket.emit('sendAT',toggleVal);
});
});
</script>
</head>
<body style="/*background-color: #D4D4D4;*/">
<div style="text-align:center;" >
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
<div id="wrap">
<div id="messagesBody">
</div>
<br>
<br>
<div style="display:none;" id="btnHolder">
<h2>Debug functions</h2>
<input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label>
<div id="debugOut"> </div>
</div>
</div>
<!-- <div id="footer">
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
</div>
-->
</body>
</html>