mirror of
https://github.com/s00500/nodeMessageBoard.git
synced 2024-12-22 03:00:50 +00:00
Fixed Emoji Support
This commit is contained in:
parent
2ac350b87c
commit
de9908122c
@ -59,11 +59,15 @@
|
||||
iosocket.emit('getLastMessages',toDisplay);
|
||||
};
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#check').click(function() {
|
||||
iosocket.emit('sendAT',toggleVal);
|
||||
});
|
||||
//$('#debugOut').html(String.fromCharCode(parseInt(s, 16),parseInt("DE03",16)));
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
@ -82,9 +86,11 @@
|
||||
<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">
|
||||
<div style="display:none;" id="btnHolder">
|
||||
<h2>Debug functions</h2>
|
||||
<input type="checkbox" id="check" value="toggle"/><label for="check">Send AT</label>
|
||||
</div>
|
||||
|
||||
<div id="debugOut"> </div>
|
||||
</body>
|
||||
</html>
|
||||
|
26
db.json
26
db.json
@ -1,16 +1,28 @@
|
||||
{
|
||||
"messages": [
|
||||
{
|
||||
"numberString": "+CMT: \"+4369910088886\",\"\",\"16/03/08,12:21:34+04\"\r",
|
||||
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,14:26:33+04\"\r",
|
||||
"number": "+4369910088886",
|
||||
"time": "12:21:34",
|
||||
"message": "Test6\r"
|
||||
"time": "14:26:33",
|
||||
"message": "1"
|
||||
},
|
||||
{
|
||||
"numberString": "+CMT: \"+4369910088886\",\"\",\"16/03/08,12:22:09+04\"\r",
|
||||
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/09,14:26:37+04\"\r",
|
||||
"number": "+4369910088886",
|
||||
"time": "12:22:09",
|
||||
"message": "Lol\r"
|
||||
"time": "14:26:37",
|
||||
"message": "2😉"
|
||||
},
|
||||
{
|
||||
"numberString": "+CMT: \"002B003400330036003600340035003300300035003900390036\",\"\",\"16/03/09,14:43:49+04\"\r",
|
||||
"number": "+436645305996",
|
||||
"time": "14:43:49",
|
||||
"message": "Spruch des Tages:\n💤😀😇"
|
||||
},
|
||||
{
|
||||
"numberString": "+CMT: \"002B003400330036003600340035003300300035003900390036\",\"\",\"16/03/09,14:42:55+04\"\r",
|
||||
"number": "+436645305996",
|
||||
"time": "14:42:55",
|
||||
"message": "Spruch des Tages:\n💤😀😇"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
25
server.js
25
server.js
@ -6,7 +6,7 @@ serialport = require("serialport");
|
||||
low = require('lowdb'),
|
||||
storage = require('lowdb/file-async'),
|
||||
db = low('db.json', { storage });
|
||||
|
||||
const port = 3000;
|
||||
var SerialPort = serialport.SerialPort;
|
||||
|
||||
var socketServer;
|
||||
@ -15,7 +15,18 @@ var portName = '/dev/tty.usbmodemFD121'; //change this to your Arduino port
|
||||
|
||||
var numberStringRecieved = "";
|
||||
var numberRecieved = "";
|
||||
var timeRecieved = ""
|
||||
var timeRecieved = "";
|
||||
|
||||
// utility function for ucs2 decode
|
||||
function ucs2Parse(ucs2){
|
||||
codeArray = ucs2.match(/.{1,4}/g);
|
||||
var returnString = "";
|
||||
for(i=0;i<codeArray.length;i++){
|
||||
returnString += String.fromCharCode(parseInt(codeArray[i], 16));
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
||||
// handle contains locations to browse to (vote and poll); pathnames.
|
||||
function startServer(route,handle,debug)
|
||||
@ -30,8 +41,8 @@ function startServer(route,handle,debug)
|
||||
var content = route(handle,pathname,response,request,debug);
|
||||
}
|
||||
|
||||
var httpServer = http.createServer(onRequest).listen(1337, function(){
|
||||
console.log("Listening at: http://localhost:1337");
|
||||
var httpServer = http.createServer(onRequest).listen(port, function(){
|
||||
console.log("Listening at: http://localhost:"+port);
|
||||
console.log("Server is up");
|
||||
});
|
||||
serialListener(debug);
|
||||
@ -87,14 +98,16 @@ function serialListener(debug)
|
||||
if(data.startsWith("+CMT:")){ // if message ok
|
||||
numberStringRecieved = data;
|
||||
numberRecieved = data.substring(data.indexOf('+CMT: "') + 7, data.indexOf('",'));
|
||||
numberRecieved = ucs2Parse(numberRecieved);
|
||||
timeRecieved = data.substring(data.indexOf('","","') + 15, data.indexOf('+04'));
|
||||
} else if (data.length > 1) {
|
||||
|
||||
if(numberRecieved){
|
||||
//console.log("emit");
|
||||
db('messages').push({ numberString: numberStringRecieved,number: numberRecieved, time: timeRecieved, message: data });
|
||||
var messageRecieved = ucs2Parse(data);
|
||||
db('messages').push({ numberString: numberStringRecieved,number: numberRecieved, time: timeRecieved, message: messageRecieved });
|
||||
//add a new message to the board directly
|
||||
socketServer.emit('newMessage', timeRecieved, numberRecieved, data);
|
||||
socketServer.emit('newMessage', timeRecieved, numberRecieved, messageRecieved);
|
||||
numberStringRecieved = null;
|
||||
numberRecieved = null;
|
||||
timeRecieved = null;
|
||||
|
Loading…
Reference in New Issue
Block a user