2
1
mirror of https://github.com/s00500/nodeMessageBoard.git synced 2024-11-21 23:20:53 +00:00
nodeMessageBoard/board.html

116 lines
2.4 KiB
HTML
Raw Normal View History

2016-03-07 20:48:50 +00:00
<!DOCTYPE html>
<meta charset="UTF-8">
2016-03-07 20:14:16 +00:00
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<style>
body {
margin: 0px;
padding: 0px;
}
#rData{
float:left;
margin-left:100px;
margin-right:auto;
width:470px;
}
#sData{
float: left;
margin-left:100px;
margin-right:auto;
width:470px;
}
h2{
text-align:center;
}
#myCanvas {
border: 2px dashed grey;
}
#btnHolder, #sliderTxt{
text-align:center;
}
</style>
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>
<script src="/socket.io/socket.io.js"></script>
<script>
2016-03-08 11:27:22 +00:00
const toDisplay = 5; //define the number of messages to show
2016-03-07 20:14:16 +00:00
var iosocket;
2016-03-08 11:27:22 +00:00
var currentMessageCount = 0;
2016-03-07 20:14:16 +00:00
//var onOff = false;
var toggleVal = 0;
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-08 11:07:56 +00:00
iosocket.on('debugMessage', function(message) {
alert(message);
2016-03-07 20:14:16 +00:00
});
2016-03-07 20:48:50 +00:00
2016-03-08 11:27:22 +00:00
iosocket.on('newMessage', function(time,number,message) {
2016-03-07 20:48:50 +00:00
var mainTable = document.getElementById("mainTable");
var newRow = mainTable.insertRow(mainTable.rows.length);
var dateCell = newRow.insertCell(0);
2016-03-08 11:07:56 +00:00
var numberCell = newRow.insertCell(1);
var textCell = newRow.insertCell(2);
2016-03-08 11:27:22 +00:00
dateCell.innerHTML = time;
2016-03-08 11:07:56 +00:00
numberCell.innerHTML = number;
2016-03-07 20:48:50 +00:00
textCell.innerHTML = message;
2016-03-08 11:27:22 +00:00
currentMessageCount++;
if(currentMessageCount > toDisplay)
{
//Remove the top row
mainTable.deleteRow(1);
currentMessageCount--;
}
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-07 20:14:16 +00:00
};
2016-03-07 20:48:50 +00:00
$(document).ready(function() {
2016-03-08 11:07:56 +00:00
//request last messages from server
2016-03-07 20:14:16 +00:00
$('#check').click(function() {
toggleVal += 1;
toggleVal %= 2;
2016-03-07 20:48:50 +00:00
iosocket.emit('sendAT',toggleVal);
2016-03-07 20:14:16 +00:00
});
});
</script>
</head>
<body>
2016-03-08 11:07:56 +00:00
<div style="text-align:center;">
2016-03-07 20:48:50 +00:00
<h2>Data from Sim900</h2>
2016-03-08 11:07:56 +00:00
<table id="mainTable" border="1" align="center">
2016-03-07 20:48:50 +00:00
<tr>
2016-03-08 11:07:56 +00:00
<td>Uhrzeit</td><td>Nummer</td><td>Nachricht</td>
2016-03-07 20:48:50 +00:00
</tr>
</table>
2016-03-08 11:07:56 +00:00
<br>
<br>
2016-03-07 20:48:50 +00:00
<h2>Debug functions</h2>
2016-03-07 20:14:16 +00:00
<div id="btnHolder">
2016-03-08 11:07:56 +00:00
<input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label>
2016-03-07 20:14:16 +00:00
</div>
</body>
</html>