2
1
mirror of https://github.com/s00500/nodeMessageBoard.git synced 2024-11-21 13:10:55 +00:00
nodeMessageBoard/board.html

91 lines
2.5 KiB
HTML

<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<!--<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" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="/socket.io/socket.io.js">
</script>
<script>
const toDisplay = 5; //define the number of messages to show
var iosocket;
var currentMessageCount = 0;
function initSocketIO()
{
iosocket = io.connect();
iosocket.on('onconnection', function() {
initButton();
iosocket.on('debugMessage', function(message) {
alert(message);
});
iosocket.on('newMessage', function(time,number,message) {
var censoredNumber = number.substring(0,3) + "********" +number.substring(number.length - 3, number.length);
var mainTable = document.getElementById("mainTable");
var newRow = mainTable.insertRow(mainTable.rows.length);
var dateCell = newRow.insertCell(0);
var numberCell = newRow.insertCell(1);
var textCell = newRow.insertCell(2);
dateCell.innerHTML = time;
numberCell.innerHTML = censoredNumber;
textCell.innerHTML = message;
currentMessageCount++;
if(currentMessageCount > toDisplay)
{
//Remove the top row
mainTable.deleteRow(1);
currentMessageCount--;
}
});
});
}
function initButton()
{
$("#check").button();
}
window.onload = function() {
initSocketIO();
iosocket.emit('getLastMessages',toDisplay);
};
$(document).ready(function() {
$('#check').click(function() {
iosocket.emit('sendAT',toggleVal);
});
});
</script>
</head>
<body>
<div style="text-align:center;" >
<h1 style="color:#000066;">SMS Message Board</h1>
<hr>
<br>
<h3>Send an SMS with a message to <span style="color:#3399ff;">+43 681 2033 4015</span></h3>
<br>
<table id="mainTable" border="1" align="center" class="table table-striped">
<tr>
<td><h4>Uhrzeit</h4></td><td><h4>Nummer</h4></td><td><h4>Nachricht</h4></td>
</tr>
</table>
<h3>Send an SMS with a message to <span style="color:#3399ff;">+43 681 2033 4015</span></h3>
<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>
</body>
</html>