1
0

Added handlers and emojize for apple style sprite emoji

This commit is contained in:
Lukas Bachschwell 2016-03-15 10:42:21 +01:00
parent 097faef1a5
commit 4aeef6c8db
8 changed files with 5230 additions and 2 deletions

2
app.js
View File

@ -7,5 +7,7 @@ var debug = false;
var handle = {} var handle = {}
handle["/"] = requestHandlers.sendInterface; handle["/"] = requestHandlers.sendInterface;
handle["/interface"] = requestHandlers.sendInterface; handle["/interface"] = requestHandlers.sendInterface;
handle["/sprite/emoji.css"] = requestHandlers.sendCss;
handle["/sprite/emoji.png"] = requestHandlers.sendPng;
server.start(router.route,handle,debug); server.start(router.route,handle,debug);

View File

@ -2,6 +2,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<html> <html>
<head> <head>
<link rel='stylesheet' href='sprite/emoji.css' >
<title>SMS Board</title> <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" />-->

154
db.json
View File

@ -167,6 +167,160 @@
"time": "09:25:17", "time": "09:25:17",
"message": "More", "message": "More",
"color": 3 "color": 3
},
{
"numberString": "+CMT: \"002B003400330036003600340031003200320031003500310038\",\"\",\"16/03/10,11:53:09+04\"\r",
"number": "+436641221518",
"time": "11:53:09",
"message": "HALLO",
"color": 4
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/10,15:50:34+04\"\r",
"number": "+4369910088886",
"time": "15:50:34",
"message": "One more 👌",
"color": 0
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/10,15:51:17+04\"\r",
"number": "+4369910088886",
"time": "15:51:17",
"message": "Message Board finished ✅",
"color": 1
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/10,15:51:43+04\"\r",
"number": "+4369910088886",
"time": "15:51:43",
"message": "Hallo xaver",
"color": 2
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/10,16:24:20+04\"\r",
"number": "+4369910088886",
"time": "16:24:20",
"message": "Hallo Armin 😶",
"color": 3
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/10,16:24:33+04\"\r",
"number": "+4369910088886",
"time": "16:24:33",
"message": "😳",
"color": 4
},
{
"numberString": "+CMT: \"002B003400330036003700360034003100350033003800300038\",\"\",\"16/03/10,16:30:11+04\"\r",
"number": "+436764153808",
"time": "16:30:11",
"message": "Hallo 1 2 3",
"color": 0
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,12:28:50+04\"\r",
"number": "+4369910088886",
"time": "12:28:50",
"message": "Sms message board",
"color": 1
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,12:31:01+04\"\r",
"number": "+4369910088886",
"time": "12:31:01",
"message": "Hallo message board",
"color": 2
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,12:41:55+04\"\r",
"number": "+4369910088886",
"time": "12:41:55",
"message": "Still up 😃👍👌",
"color": 3
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,12:58:36+04\"\r",
"number": "+4369910088886",
"time": "12:58:36",
"message": "Hallo Conny 😉",
"color": 4
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,13:07:35+04\"\r",
"number": "+4369910088886",
"time": "13:07:35",
"message": "Hallo klaus",
"color": 0
},
{
"numberString": "+CMT: \"002B003400330036003600340034003900370035003200320033\",\"\",\"16/03/11,13:46:53+04\"\r",
"number": "+436644975223",
"time": "13:46:53",
"message": "Hallo Lukas 😁",
"color": 1
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,14:21:20+04\"\r",
"number": "+4369910088886",
"time": "14:21:20",
"message": "Guten Tag 😃",
"color": 2
},
{
"numberString": "+CMT: \"002B003400330036003700360036003000370039003900320037\",\"\",\"16/03/11,14:24:06+04\"\r",
"number": "+436766079927",
"time": "14:24:06",
"message": "Hey",
"color": 3
},
{
"numberString": "+CMT: \"002B003400330036003600300037003000310031003900390037\",\"\",\"16/03/11,14:57:43+04\"\r",
"number": "+436607011997",
"time": "14:57:43",
"message": "FH St.Pölten open day",
"color": 4
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,14:59:00+04\"\r",
"number": "+4369910088886",
"time": "14:59:00",
"message": "Hollo 300",
"color": 0
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003400390039003700320030\",\"\",\"16/03/11,15:00:06+04\"\r",
"number": "+4369910499720",
"time": "15:00:06",
"message": "Hi",
"color": 1
},
{
"numberString": "+CMT: \"002B003400330036003600300039003000310031003100390037\",\"\",\"16/03/11,15:01:33+04\"\r",
"number": "+436609011197",
"time": "15:01:33",
"message": "Hoi! ^w^",
"color": 2
},
{
"numberString": "+CMT: \"002B003400330036003800300033003100320036003300370034\",\"\",\"16/03/11,15:18:07+04\"\r",
"number": "+436803126374",
"time": "15:18:07",
"message": "<img src=\"http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=|1&chl=Hi!!\">",
"color": 3
},
{
"numberString": "+CMT: \"002B0034003300360039003900310030003000380038003800380036\",\"\",\"16/03/11,15:32:36+04\"\r",
"number": "+4369910088886",
"time": "15:32:36",
"message": "Hallo openday 😜",
"color": 4
},
{
"numberString": "+CMT: \"002B003400330036003500300034003100310031003100340036\",\"\",\"16/03/11,17:23:55+04\"\r",
"number": "+436504111146",
"time": "17:23:55",
"message": "Elektronik-Labor :D",
"color": 0
} }
] ]
} }

View File

@ -4,6 +4,7 @@
"description": "A SMS Messageboard built using node and express", "description": "A SMS Messageboard built using node and express",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
"emojize": "^0.2.0",
"lowdb": "^0.12.5", "lowdb": "^0.12.5",
"serialport": "^2.0.6", "serialport": "^2.0.6",
"socket.io": "^1.4.5" "socket.io": "^1.4.5"

View File

@ -12,4 +12,19 @@ function sendInterface(response) {
response.end(html); response.end(html);
} }
function sendCss(response) {
console.log("Request handler 'css' was called.");
response.writeHead(200, {"Content-Type": "text/css"});
var html = fs.readFileSync(__dirname + "/served/emoji.css")
response.end(html);
}
function sendPng(response) {
console.log("Request handler 'png' was called.");
response.writeHead(200, {"Content-Type": "image/png"});
var html = fs.readFileSync(__dirname + "/served/emoji.png")
response.end(html);
}
exports.sendPng = sendPng;
exports.sendCss = sendCss;
exports.sendInterface = sendInterface; exports.sendInterface = sendInterface;

5051
served/emoji.css Normal file

File diff suppressed because it is too large Load Diff

BIN
served/emoji.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

View File

@ -6,6 +6,9 @@ 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 });
var convert = require('emojize').emojize;
var SerialPort = serialport.SerialPort; var SerialPort = serialport.SerialPort;
var config = low('config.json', { storage }); var config = low('config.json', { storage });
var socketServer; var socketServer;
@ -34,7 +37,8 @@ function startServer(route,handle,debug)
{ {
db('messages').size(); //call this once to establish the db if there is nothing in the json file db('messages').size(); //call this once to establish the db if there is nothing in the json file
if(db('messages').size() == 0)db('messages').push({ numberString: "",number: "+43 681 2033 4015", time: "now", message: "SMS MessageBoard",color: 0 }); var mynumber = config('mainConfig').chain().find({ param: 'mynumber' }).value()['value'];
if(db('messages').size() == 0)db('messages').push({ numberString: "",number: mynumber, time: "now", message: "SMS MessageBoard",color: 0 });
// on request event // on request event
function onRequest(request, response) { function onRequest(request, response) {
@ -82,7 +86,7 @@ function initSocketIO(httpServer,debug)
var colors = db('messages').chain().takeRight(number).map('color').value(); var colors = db('messages').chain().takeRight(number).map('color').value();
for(var i = 0; i < messages.length; i++){ for(var i = 0; i < messages.length; i++){
socket.emit('newMessage',times[i],numbers[i],messages[i],colors[i]); socket.emit('newMessage',times[i],numbers[i],convert(messages[i]),colors[i]);
} }
}); });