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