1
0

added some style and changed to divs

This commit is contained in:
Lukas Bachschwell 2016-03-09 16:06:26 +01:00
parent de9908122c
commit b6164a0eae
2 changed files with 49 additions and 19 deletions

View File

@ -2,7 +2,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<html> <html>
<head> <head>
<title>SMS Board</title>
<!--<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />--> <!--<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" /> <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/jquery-1.8.3.js"></script>
@ -11,7 +11,7 @@
</script> </script>
<script> <script>
const toDisplay = 5; //define the number of messages to show const toDisplay = 4; //define the number of messages to show
var iosocket; var iosocket;
var currentMessageCount = 0; var currentMessageCount = 0;
@ -29,19 +29,27 @@
iosocket.on('newMessage', function(time,number,message) { iosocket.on('newMessage', function(time,number,message) {
var censoredNumber = number.substring(0,3) + "********" +number.substring(number.length - 3, number.length); 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 messages = document.getElementById('messagesBody');
var dateCell = newRow.insertCell(0); var newDiv = document.createElement('div');
var numberCell = newRow.insertCell(1); var newH1 = document.createElement('h1');
var textCell = newRow.insertCell(2); var newP = document.createElement('p');
dateCell.innerHTML = time; newH1.innerHTML = message;
numberCell.innerHTML = censoredNumber; newP.innerHTML = "by "+censoredNumber+" at "+time;
textCell.innerHTML = message; newDiv.style="background:#428bca !important; padding:10px 0;";
newDiv.className="jumbotron";
newDiv.appendChild(newH1);
newDiv.appendChild(newP);
messages.appendChild(newDiv);
currentMessageCount++; currentMessageCount++;
if(currentMessageCount > toDisplay) if(currentMessageCount > toDisplay)
{ {
//Remove the top row //Remove the top row
mainTable.deleteRow(1); $('#messagesBody').find('div').first().remove();
//messages.removeChild(messages.firstChild);
//mainTable.deleteRow(1);
currentMessageCount--; currentMessageCount--;
} }
}); });
@ -73,18 +81,16 @@
</head> </head>
<body> <body>
<div style="text-align:center;" > <div style="text-align:center;" >
<h1 style="color:#000066;">SMS Message Board</h1> <!--<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> <h3>Send an SMS with a message to <span style="color:#3399ff;">+43 681 2033 4015</span></h3>
<br> <br>
<table id="mainTable" border="1" align="center" class="table table-striped"> <div id="messagesBody">
<tr>
<td><h4>Uhrzeit</h4></td><td><h4>Nummer</h4></td><td><h4>Nachricht</h4></td> </div>
</tr>
</table>
<h3>Send an SMS with a message to <span style="color:#3399ff;">+43 681 2033 4015</span></h3> <h3>Send an SMS with a message to <span style="color:#3399ff;">+43 681 2033 4015</span></h3>
<br>
<br> <br>
<div style="display:none;" id="btnHolder"> <div style="display:none;" id="btnHolder">
<h2>Debug functions</h2> <h2>Debug functions</h2>

24
db.json
View File

@ -23,6 +23,30 @@
"number": "+436645305996", "number": "+436645305996",
"time": "14:42:55", "time": "14:42:55",
"message": "Spruch des Tages:\n💤😀😇" "message": "Spruch des Tages:\n💤😀😇"
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,16:03:56+04\"\r",
"number": "+4369910088886",
"time": "16:03:56",
"message": "Test 400"
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,16:04:09+04\"\r",
"number": "+4369910088886",
"time": "16:04:09",
"message": "Haha"
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,16:04:47+04\"\r",
"number": "+4369910088886",
"time": "16:04:47",
"message": "Hahi"
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,16:05:47+04\"\r",
"number": "+4369910088886",
"time": "16:05:47",
"message": "W"
} }
] ]
} }