2016-03-07 20:48:50 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<meta charset="UTF-8">
|
2016-03-07 20:14:16 +00:00
|
|
|
<html>
|
2016-03-08 11:49:28 +00:00
|
|
|
<head>
|
2016-03-15 09:42:21 +00:00
|
|
|
<link rel='stylesheet' href='sprite/emoji.css' >
|
2016-03-10 08:28:41 +00:00
|
|
|
|
2016-03-09 15:06:26 +00:00
|
|
|
<title>SMS Board</title>
|
2016-03-08 11:49:28 +00:00
|
|
|
<!--<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />-->
|
|
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
|
2016-03-07 20:48:50 +00:00
|
|
|
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
|
2016-03-07 20:14:16 +00:00
|
|
|
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
|
2016-03-08 11:49:28 +00:00
|
|
|
<script src="/socket.io/socket.io.js">
|
|
|
|
</script>
|
2016-03-10 08:28:41 +00:00
|
|
|
<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>
|
|
|
|
|
2016-03-07 20:14:16 +00:00
|
|
|
|
2016-03-08 11:49:28 +00:00
|
|
|
<script>
|
2016-03-09 15:06:26 +00:00
|
|
|
const toDisplay = 4; //define the number of messages to show
|
2016-03-08 11:49:28 +00:00
|
|
|
var iosocket;
|
2016-03-08 11:27:22 +00:00
|
|
|
var currentMessageCount = 0;
|
2016-03-10 08:28:41 +00:00
|
|
|
var newDiv;
|
2016-03-10 14:08:22 +00:00
|
|
|
var mynumber;
|
2016-03-10 08:28:41 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2016-03-07 20:14:16 +00:00
|
|
|
|
2016-03-08 11:27:22 +00:00
|
|
|
|
2016-03-07 20:14:16 +00:00
|
|
|
function initSocketIO()
|
|
|
|
{
|
|
|
|
iosocket = io.connect();
|
2016-03-08 11:27:22 +00:00
|
|
|
iosocket.on('onconnection', function() {
|
2016-03-07 20:14:16 +00:00
|
|
|
initButton();
|
|
|
|
|
2016-03-10 14:08:22 +00:00
|
|
|
iosocket.on('debugMessage', function(message) {
|
|
|
|
alert(message);
|
|
|
|
});
|
2016-03-07 20:48:50 +00:00
|
|
|
|
2016-03-10 14:08:22 +00:00
|
|
|
iosocket.on('config', function(phonenumber) {
|
|
|
|
mynumber = phonenumber;
|
|
|
|
$( "span.number" ).html(mynumber);
|
|
|
|
console.log(mynumber);
|
|
|
|
});
|
2016-03-09 15:06:26 +00:00
|
|
|
|
2016-03-10 14:08:22 +00:00
|
|
|
iosocket.on('newMessage', function(time,number,message,color) {
|
2016-03-10 08:28:41 +00:00
|
|
|
var censoredNumber = number.substring(0,3) + "********" +number.substring(number.length - 3, number.length);
|
2016-03-09 15:06:26 +00:00
|
|
|
var messages = document.getElementById('messagesBody');
|
2016-03-10 08:28:41 +00:00
|
|
|
newDiv = document.createElement('div');
|
2016-03-09 15:06:26 +00:00
|
|
|
var newH1 = document.createElement('h1');
|
|
|
|
var newP = document.createElement('p');
|
|
|
|
newH1.innerHTML = message;
|
|
|
|
newP.innerHTML = "by "+censoredNumber+" at "+time;
|
2016-03-10 08:28:41 +00:00
|
|
|
newDiv.style="background:"+getColor(color)+" !important; padding:10px 0; margin:10px 0;";
|
2016-03-09 15:06:26 +00:00
|
|
|
newDiv.className="jumbotron";
|
|
|
|
newDiv.appendChild(newH1);
|
|
|
|
newDiv.appendChild(newP);
|
|
|
|
|
2016-03-08 11:27:22 +00:00
|
|
|
currentMessageCount++;
|
|
|
|
if(currentMessageCount > toDisplay)
|
|
|
|
{
|
2016-03-10 08:28:41 +00:00
|
|
|
//Remove the top div
|
|
|
|
$('#messagesBody').find('div').first().slideUp(function() {
|
|
|
|
$(this).remove();
|
|
|
|
document.getElementById('messagesBody').appendChild(newDiv);
|
|
|
|
});
|
2016-03-08 11:27:22 +00:00
|
|
|
currentMessageCount--;
|
2016-03-10 08:28:41 +00:00
|
|
|
}else{
|
|
|
|
document.getElementById('messagesBody').appendChild(newDiv);
|
2016-03-08 11:27:22 +00:00
|
|
|
}
|
2016-03-10 08:28:41 +00:00
|
|
|
|
2016-03-07 20:14:16 +00:00
|
|
|
});
|
2016-03-07 20:48:50 +00:00
|
|
|
});
|
2016-03-07 20:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function initButton()
|
|
|
|
{
|
2016-03-08 11:07:56 +00:00
|
|
|
$("#check").button();
|
2016-03-07 20:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function() {
|
|
|
|
initSocketIO();
|
2016-03-08 11:27:22 +00:00
|
|
|
iosocket.emit('getLastMessages',toDisplay);
|
2016-03-10 14:08:22 +00:00
|
|
|
iosocket.emit('getConfig');
|
2016-03-08 11:49:28 +00:00
|
|
|
};
|
2016-03-07 20:14:16 +00:00
|
|
|
|
2016-03-09 13:51:46 +00:00
|
|
|
|
2016-03-07 20:48:50 +00:00
|
|
|
$(document).ready(function() {
|
2016-03-08 11:49:28 +00:00
|
|
|
$('#check').click(function() {
|
2016-03-07 20:48:50 +00:00
|
|
|
iosocket.emit('sendAT',toggleVal);
|
2016-03-08 11:49:28 +00:00
|
|
|
});
|
2016-03-07 20:14:16 +00:00
|
|
|
});
|
2016-03-09 13:51:46 +00:00
|
|
|
|
|
|
|
|
2016-03-08 11:49:28 +00:00
|
|
|
</script>
|
|
|
|
|
2016-03-07 20:14:16 +00:00
|
|
|
</head>
|
2016-03-10 08:28:41 +00:00
|
|
|
<body style="/*background-color: #D4D4D4;*/">
|
2016-03-08 11:49:28 +00:00
|
|
|
<div style="text-align:center;" >
|
2016-03-10 14:08:22 +00:00
|
|
|
|
|
|
|
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
|
2016-03-10 08:28:41 +00:00
|
|
|
<div id="wrap">
|
2016-03-09 15:06:26 +00:00
|
|
|
<div id="messagesBody">
|
|
|
|
</div>
|
2016-03-08 11:49:28 +00:00
|
|
|
|
2016-03-09 15:06:26 +00:00
|
|
|
<br>
|
2016-03-08 11:07:56 +00:00
|
|
|
<br>
|
2016-03-09 13:51:46 +00:00
|
|
|
<div style="display:none;" id="btnHolder">
|
2016-03-08 11:49:28 +00:00
|
|
|
<h2>Debug functions</h2>
|
2016-03-08 11:07:56 +00:00
|
|
|
<input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label>
|
2016-03-10 08:28:41 +00:00
|
|
|
<div id="debugOut"> </div>
|
2016-03-07 20:14:16 +00:00
|
|
|
</div>
|
2016-03-10 08:28:41 +00:00
|
|
|
</div>
|
|
|
|
<div id="footer">
|
2016-03-10 14:08:22 +00:00
|
|
|
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
|
2016-03-10 08:28:41 +00:00
|
|
|
</div>
|
2016-03-07 20:14:16 +00:00
|
|
|
</body>
|
|
|
|
</html>
|