1
0

First edit for better readability

This commit is contained in:
eorg_oz 2017-03-10 21:31:57 +01:00
parent 9c0c30c5c2
commit d131979c5d
3 changed files with 356 additions and 403 deletions

View File

@ -1,168 +1,144 @@
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="UTF-8">
<html> <html>
<head> <head>
<meta charset="UTF-8">
<title>SMS Board</title> <title>SMS Board</title>
<link rel='stylesheet' href='sprite/emoji.css' > <link rel='stylesheet' href='sprite/emoji.css' >
<link rel="stylesheet" href="/css/bootstrap.min.css" /> <link rel="stylesheet" href="/css/bootstrap.min.css" />
<script src="/js/jquery-1.12.1.min"></script> <script src="/js/jquery-1.12.1.min"></script>
<script src="/js/jquery-ui.js"></script> <script src="/js/jquery-ui.js"></script>
<script src="/socket.io/socket.io.js"> <script src="/socket.io/socket.io.js"></script>
</script> <style>
<style> /* Sticky footer styles
/* Sticky footer styles -------------------------------------------------- */
-------------------------------------------------- */ html, body {
height: 100%;
html, /* The html and body elements cannot have any padding or margin. */
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;
} }
} /* 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() function initSocketIO() {
{ iosocket = io.connect();
iosocket = io.connect(); iosocket.on('clientrefresh', function() {
location.reload();
});
iosocket.on('clientrefresh', function() { iosocket.on('connect', function() {
location.reload(); iosocket.on('debugMessage', function(message) {
}); alert(message);
});
iosocket.on('connect', function() { 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');
var 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++;
iosocket.on('debugMessage', function(message) { if(currentMessageCount > toDisplay) {
alert(message); //Remove the top div
}); $('#messagesBody').find('div').first().slideUp(function() {
$(this).remove();
document.getElementById('messagesBody').appendChild(newDiv);
});
currentMessageCount--;
} else {
document.getElementById('messagesBody').appendChild(newDiv);
}
});
});
};
iosocket.on('config', function(phonenumber) { function initButton() {
mynumber = phonenumber; $("#check").button();
$( "span.number" ).html(mynumber); };
});
window.onload = function() {
initSocketIO();
iosocket.emit('getLastMessages',toDisplay);
iosocket.emit('getConfig');
};
iosocket.on('newMessage', function(time,number,message,color) { $(document).ready(function() {
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() { $('#check').click(function() {
iosocket.emit('sendAT',toggleVal); iosocket.emit('sendAT',toggleVal);
}); });
}); });
</script>
</script>
</head> </head>
<body style="/*background-color: #D4D4D4;*/"> <body style="/*background-color: #D4D4D4;*/">
<div style="text-align:center;" > <div style="text-align:center;" >
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2> <div id="wrap">
<div id="wrap"> <div id="messagesBody"></div>
<div id="messagesBody"> <br>
</div> <br>
<div style="display:none;" id="btnHolder">
<br> <h2>Debug functions</h2>
<br> <input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label>
<div style="display:none;" id="btnHolder"> <div id="debugOut"> </div>
<h2>Debug functions</h2> </div>
<input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label> </div>
<div id="debugOut"> </div> <div id="footer">
</div> <h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
</div> </div>
<!-- <div id="footer"> </div>
<h2>Send an SMS with a message to <span class="number" style="color:#3399ff;"></span></h2>
</div>
-->
</body> </body>
</html> </html>

View File

@ -1,63 +1,54 @@
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="UTF-8"> <html>
<html> <head>
<head> <meta charset="UTF-8">
<title>Clear Board</title> <title>Clear Board</title>
<link rel='stylesheet' href='sprite/emoji.css' > <link rel='stylesheet' href='sprite/emoji.css' >
<link rel="stylesheet" href="/css/bootstrap.min.css" /> <link rel="stylesheet" href="/css/bootstrap.min.css" />
<script src="/js/jquery-1.12.1.min"></script> <script src="/js/jquery-1.12.1.min"></script>
<script src="/js/jquery-ui.js"></script> <script src="/js/jquery-ui.js"></script>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script>
<script> var iosocket;
var iosocket; function initSocketIO() {
iosocket = io.connect();
function initSocketIO() iosocket.on('connect', function() {
{ iosocket.on('debugMessage', function(message) {
iosocket = io.connect(); alert(message);
iosocket.on('connect', function() { });
});
iosocket.on('debugMessage', function(message) { };
alert(message); window.onload = function() {
}); initSocketIO();
});
}
window.onload = function() {
initSocketIO();
}; };
$(document).ready(function() {
$(document).ready(function() { $('#clear').click(function() {
$('#clear').click(function() { var number = $('#number').val();
var number = $('#number').val(); iosocket.emit('clear',number);
iosocket.emit('clear',number); alert("cleared");
alert("cleared"); });
}); $('#refresh').click(function() {
$('#refresh').click(function() { iosocket.emit('refreshClients');
iosocket.emit('refreshClients'); });
}); });
}); </script>
</head>
<body>
</script> <div style="text-align:center;" >
</head> <div id="wrap">
<body> <div id="btnHolder">
<div style="text-align:center;" > <h2>Functions</h2>
<div id="wrap"> <input type="number" id="number" value="1" min="1"/>
<div id="btnHolder"> <label for="number">Number</label>
<h2>Functions</h2> <br>
<input type="number" id="number" value="1" min="1"/><label for="number">Number</label><br> <input type="button" id="clear" value="clear"/>
<input type="button" id="clear" value="clear"/> <br>
<br> <input type="button" id="refresh" value="refresh"/>
<input type="button" id="refresh" value="refresh"/> <div id="debugOut"></div>
<div id="debugOut"> </div> </div>
</div> </div>
</div> </div>
</body>
</body> </html>
</html>

374
demo.html
View File

@ -1,220 +1,206 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=320, initial-scale=1"> <meta name="viewport" content="width=320, initial-scale=1">
<title>Chat</title> <title>Chat</title>
<script src="/js/jquery-1.12.1.min"></script> <script src="/js/jquery-1.12.1.min"></script>
<script src="/js/jquery-ui.js"></script> <script src="/js/jquery-ui.js"></script>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
</head> <script type="text/javascript">
var iosocket;
<script type="text/javascript"> function initSocketIO() {
var iosocket; iosocket = io.connect();
function initSocketIO() iosocket.on('connect', function() {
{ createSystemMessage('[Connected]');
iosocket = io.connect(); console.log("connect");
iosocket.on('connect', function() { iosocket.on('debugMessage', function(message) {
createSystemMessage('[Connected]'); alert(message);
console.log("connect"); });
iosocket.on('disconnect', function() {
createSystemMessage('[Disconnected]');
});
});
}
window.onload = function() {
iosocket.on('debugMessage', function(message) { initSocketIO();
alert(message);
});
iosocket.on('disconnect', function() {
createSystemMessage('[Disconnected]');
});
});
}
window.onload = function() {
initSocketIO();
}; };
function createSystemMessage(message) {
var message = document.createTextNode(message);
function createSystemMessage(message) { var messageBox = document.createElement('p');
var message = document.createTextNode(message); messageBox.className = 'system';
var messageBox = document.createElement('p'); messageBox.appendChild(message);
messageBox.className = 'system';
messageBox.appendChild(message); var chat = document.getElementById('chat_box');
chat.appendChild(messageBox);
}
var chat = document.getElementById('chat_box'); function createUserMessage(user, message) {
chat.appendChild(messageBox); var user = document.createTextNode(user + ': ');
}
function createUserMessage(user, message) { var userBox = document.createElement('span');
var user = document.createTextNode(user + ': '); userBox.className = 'username';
userBox.appendChild(user);
var userBox = document.createElement('span'); var message = document.createTextNode(message);
userBox.className = 'username';
userBox.appendChild(user);
var message = document.createTextNode(message); var messageBox = document.createElement('p');
messageBox.appendChild(userBox);
messageBox.appendChild(message);
var messageBox = document.createElement('p'); var chat = document.getElementById('chat_box');
messageBox.appendChild(userBox); chat.appendChild(messageBox);
messageBox.appendChild(message); }
var chat = document.getElementById('chat_box'); function sendMessage() {
chat.appendChild(messageBox); var user = document.getElementById('user');
} var message = document.getElementById('message');
var number = document.getElementById('number');
var currentDate = new Date();
var time = currentDate.toLocaleTimeString();
var date = currentDate.getDate()+"/"+currentDate.getMonth()+"/"+currentDate.getFullYear();
iosocket.emit('demoMessage',number.value.toString(),date,time,message.value);
createUserMessage(time,message.value);
message.value = "";
};
function sendMessage() { // added a little wrapper for enter submit
var user = document.getElementById('user'); function submitEnter(e){
var message = document.getElementById('message'); if (( e.keyCode == 13 )&&(e.shiftKey === false)) {
var number = document.getElementById('number'); sendMessage();
var currentDate = new Date(); }
var time = currentDate.toLocaleTimeString(); }
var date = currentDate.getDate()+"/"+currentDate.getMonth()+"/"+currentDate.getFullYear(); </script>
<style type="text/css">
* {
font-family: "Arial";
font-size: 24px;
}
iosocket.emit('demoMessage',number.value.toString(),date,time,message.value); html, body, #wrapper {
createUserMessage(time,message.value); margin: 0;
message.value = ""; padding: 0;
}; height: 100%;
}
// added a little wrapper for enter submit #wrapper {
function submitEnter(e){ background-color: #ecf0f1;
if (( e.keyCode == 13 )&&(e.shiftKey === false)) { }
sendMessage();
}
} #chat_box {
box-sizing: border-box;
height: 100%;
overflow: auto;
padding-bottom: 50px;
}
#footer {
box-sizing: border-box;
position: fixed;
bottom: 0;
height: 50px;
width: 100%;
background-color: #2980b9;
}
</script> #footer .content {
padding-top: 4px;
position: relative;
}
<body> #user { width: 20%; }
<div id="wrapper"> #message { width: 68%; }
<div id="chat_box" class="content"></div> #send_btn {
width: 10%;
position: absolute;
right: 0;
bottom: 0;
margin: 0;
}
<div id="footer"> .content {
<div class="content"> width: 70%;
<input type="text" id="number" value="+4301234567890" /> margin: 0 auto;
<input type="text" id="message" onkeypress="return submitEnter(event)" placeholder="Enter a Test Message! (Or emoji!, google if if you don't know how)" /> }
<input type="button" id="send_btn" value="Send" onclick="sendMessage()">
input[type="text"],
input[type="button"] {
border: 0;
color: #fff;
}
input[type="text"] {
background-color: #146EA8;
padding: 3px 10px;
}
input[type="button"] {
background-color: #f39c12;
border-right: 2px solid #e67e22;
border-bottom: 2px solid #e67e22;
min-width: 70px;
display: inline-block;
}
input[type="button"]:hover {
background-color: #e67e22;
border-right: 2px solid #f39c12;
border-bottom: 2px solid #f39c12;
cursor: pointer;
}
.system,
.username {
color: #aaa;
font-style: italic;
font-family: monospace;
font-size: 16px;
}
@media(max-width: 1000px) {
.content { width: 90%; }
}
@media(max-width: 780px) {
#footer { height: 91px; }
#chat_box { padding-bottom: 91px; }
#user { width: 100%; }
#message { width: 80%; }
}
@media(max-width: 400px) {
#footer { height: 135px; }
#chat_box { padding-bottom: 135px; }
#message { width: 100%; }
#send_btn {
position: relative;
margin-top: 3px;
width: 100%;
}
}
</style>
</head>
<body>
<div id="wrapper">
<div id="chat_box" class="content"></div>
<div id="footer">
<div class="content">
<input type="text" id="number" value="+4301234567890" />
<input type="text" id="message" onkeypress="return submitEnter(event)" placeholder="Enter a Test Message! (Or emoji!, google if if you don't know how)" />
<input type="button" id="send_btn" value="Send" onclick="sendMessage()">
</div>
</div>
</div> </div>
</div> </body>
</div> </html>
</body>
</html>
<style type="text/css">
* {
font-family: "Arial";
font-size: 24px;
}
html, body, #wrapper {
margin: 0;
padding: 0;
height: 100%;
}
#wrapper {
background-color: #ecf0f1;
}
#chat_box {
box-sizing: border-box;
height: 100%;
overflow: auto;
padding-bottom: 50px;
}
#footer {
box-sizing: border-box;
position: fixed;
bottom: 0;
height: 50px;
width: 100%;
background-color: #2980b9;
}
#footer .content {
padding-top: 4px;
position: relative;
}
#user { width: 20%; }
#message { width: 68%; }
#send_btn {
width: 10%;
position: absolute;
right: 0;
bottom: 0;
margin: 0;
}
.content {
width: 70%;
margin: 0 auto;
}
input[type="text"],
input[type="button"] {
border: 0;
color: #fff;
}
input[type="text"] {
background-color: #146EA8;
padding: 3px 10px;
}
input[type="button"] {
background-color: #f39c12;
border-right: 2px solid #e67e22;
border-bottom: 2px solid #e67e22;
min-width: 70px;
display: inline-block;
}
input[type="button"]:hover {
background-color: #e67e22;
border-right: 2px solid #f39c12;
border-bottom: 2px solid #f39c12;
cursor: pointer;
}
.system,
.username {
color: #aaa;
font-style: italic;
font-family: monospace;
font-size: 16px;
}
@media(max-width: 1000px) {
.content { width: 90%; }
}
@media(max-width: 780px) {
#footer { height: 91px; }
#chat_box { padding-bottom: 91px; }
#user { width: 100%; }
#message { width: 80%; }
}
@media(max-width: 400px) {
#footer { height: 135px; }
#chat_box { padding-bottom: 135px; }
#message { width: 100%; }
#send_btn {
position: relative;
margin-top: 3px;
width: 100%;
}
}
</style>