Added mail thing

This commit is contained in:
Thomas FORGIONE 2015-07-17 14:53:45 +02:00
parent f32ffe9b01
commit 0fb63b93f6
8 changed files with 264 additions and 170 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
private.js
mail.js

View File

@ -18,6 +18,7 @@ var coins = [];
var previousTime;
var pointer;
var startCanvas;
var name;
function sceneName() {
switch (initMainScene) {
@ -34,15 +35,20 @@ function sceneName() {
saveCoins = function() {
var result = '{scene: "' + sceneName() + '", coins: [';
var result = {scene: sceneName(), coins: []};
for (var i = 0; i < coins.length - 1; i++) {
result += JSON.stringify(coins[i].mesh.position) + ',';
if (name === undefined) {
name = window.prompt('Your name please ? :D');
}
result += JSON.stringify(coins[coins.length-1].mesh.position) + ']}';
var blob = new Blob([result], {type: "text/plain;charset=utf-8"});
saveAs(blob, "coins.js");
result.name = name;
for (var i = 0; i < coins.length; i++) {
if (coins[i].mesh.visible)
result.coins.push(coins[i].mesh.position);
}
L3D.BD.Private.sendData('/posts/coin-info', result, true);
};

View File

@ -2,8 +2,8 @@ L3D.BD = {};
L3D.BD.Private = {};
L3D.BD.Private.sendData = function(url, data) {
if (L3D.BD.Private.enabled) {
L3D.BD.Private.sendData = function(url, data, force) {
if (L3D.BD.Private.enabled || force) {
// Append time to data
data.time = Date.now() / 1000;

View File

@ -64,6 +64,13 @@ Log.dberror = function(error) {
);
};
Log.mailerror = function(error) {
log(
'[MLE] ' + new Date() + ' ' + error,
Colors.RED
);
}
if (isDev) {
Log.debug = function(info) {
log(

378
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,9 @@
"cookie-parser" : "1.3.4",
"cookie-session" : "1.1.0",
"socket.io" : "1.3.5",
"serve-favicon": "2.3.0"
"serve-favicon": "2.3.0",
"emailjs":"0.3.16",
"three":"0.71.0"
},
"repository" : {
"type" : "git",

19
posts/coin-info/index.js Normal file
View File

@ -0,0 +1,19 @@
var mail = require('../../lib/mail.js');
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
mail.send({
from: req.body.name + " <dragonrock.django@gmail.com>",
to: "Thomas <thomas.forgione@gmail.com>",
subject: req.body.scene,
text: JSON.stringify(req.body.coins)
}, function(err, message) {
if (err !== null) {
Log.mailerror(err);
}
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};

3
posts/coin-info/urls.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/coin-info': 'index'
};