Changed tabs to spaces & removed trailing spaces

This commit is contained in:
quenenni 2013-03-27 02:19:27 +01:00
parent 907ecb9a7b
commit 7d3d2a2920
7 changed files with 64 additions and 63 deletions

View file

@ -5,13 +5,6 @@ exports.eejsBlock_scripts = function (hook_name, args, cb) {
return cb();
};
/*
exports.eejsBlock_embedPopup = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_email_notifications/templates/embedFrame.html", {}, module);
return cb();
};
*/
exports.eejsBlock_mySettings = function (hook_name, args, cb) {
args.content = args.content + eejs.require('ep_email_notifications/templates/email_notifications_settings.ejs');
return cb();
@ -20,4 +13,3 @@ exports.eejsBlock_mySettings = function (hook_name, args, cb) {
exports.eejsBlock_styles = function (hook_name, args, cb) {
args.content = args.content + '<link href="../static/plugins/ep_email_notifications/static/css/email_notifications.css" rel="stylesheet">';
};

View file

@ -6,8 +6,8 @@
"padUpdate": "ep_email_notifications/update",
"handleMessage": "ep_email_notifications/handleMessage",
"eejsBlock_scripts": "ep_email_notifications/client",
"eejsBlock_mySettings": "ep_email_notifications/client:eejsBlock_mySettings",
"eejsBlock_styles": "ep_email_notifications/client:eejsBlock_styles"
"eejsBlock_mySettings": "ep_email_notifications/client:eejsBlock_mySettings",
"eejsBlock_styles": "ep_email_notifications/client:eejsBlock_styles"
},
"client_hooks": {
"postAceInit":"ep_email_notifications/static/js/ep_email:postAceInit",

View file

@ -33,20 +33,21 @@ exports.handleMessage = function(hook_name, context, callback){
}); // end async for each
}
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
// SUbscription
console.debug("email ", context.message.data.userInfo.email, "already subscribed to ", context.message.data.padId, " so sending message to client");
if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == true){
// SUbscription
console.debug("email ", context.message.data.userInfo.email, "already subscribed to ", context.message.data.padId, " so sending message to client");
context.client.json.send({ type: "COLLABROOM",
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailSubscriptionSuccess",
payload: false
}
});
} else if(context.message.data.userInfo.email_option == 'subscribe' && alreadyExists == false){
// SUbscription
// SUbscription
var validatesAsEmail = check(context.message.data.userInfo.email).isEmail();
if(!validatesAsEmail){ // send validation failed if it's malformed.. y'know in general fuck em!
if(!validatesAsEmail){
// Subscription -> failed coz mail malformed.. y'know in general fuck em!
console.warn("Dropped email subscription due to malformed email address");
context.client.json.send({ type: "COLLABROOM",
data:{
@ -55,12 +56,13 @@ exports.handleMessage = function(hook_name, context, callback){
}
});
} else {
// Subscription -> Go for it
console.debug ("Subscription: Wrote to the database and sent client a positive response ",context.message.data.userInfo.email);
exports.setAuthorEmail(
context.message.data.userInfo.userId,
context.message.data.userInfo,
callback
callback
);
exports.setAuthorEmailRegistered(
@ -75,15 +77,15 @@ exports.handleMessage = function(hook_name, context, callback){
payload: true
}
});
}
}
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == true) {
// Unsubscription
// Unsubscription -> Go for it
console.debug ("Unsubscription: Remove from the database and sent client a positive response ",context.message.data.userInfo.email);
exports.unsetAuthorEmail(
exports.unsetAuthorEmail(
context.message.data.userInfo.userId,
context.message.data.userInfo,
callback
callback
);
exports.unsetAuthorEmailRegistered(
@ -98,17 +100,17 @@ exports.handleMessage = function(hook_name, context, callback){
payload: true
}
});
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) {
// Unsubscription
console.debug ("Unsubscription: Send client a negative response ",context.message.data.userInfo.email);
} else if(context.message.data.userInfo.email_option == 'unsubscribe' && alreadyExists == false) {
// Unsubscription -> Send failed as email not found
console.debug ("Unsubscription: Send client a negative response ",context.message.data.userInfo.email);
context.client.json.send({ type: "COLLABROOM",
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailUnsubscriptionSuccess",
payload: false
}
});
}
}
}); // close db get
callback([null]); // don't run onto passing colorId or anything else to the message handler
@ -121,7 +123,7 @@ exports.handleMessage = function(hook_name, context, callback){
console.debug(context.message);
var userIdFound = false;
// does email Subscription already exist for this name and padID?
// does email Subscription already exist for this UserId?
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds){
if(userIds){
async.forEach(Object.keys(userIds), function(user, cb){
@ -129,7 +131,7 @@ exports.handleMessage = function(hook_name, context, callback){
console.debug("Options for this pad ", userIds[user].authorId, " found in the Db");
userIdFound = true;
// We send back the options set for this user
// We send back the options associated to this userId
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailNotificationGetUserInfo",
@ -152,13 +154,13 @@ exports.handleMessage = function(hook_name, context, callback){
});
if (!userIdFound) {
// We send back the options set for this user
// No options set for this userId
context.client.json.send({ type: "COLLABROOM",
data:{
type: "emailNotificationGetUserInfo",
payload: {
success:false
}
}
}
});
}
@ -197,19 +199,26 @@ exports.setAuthorEmailRegistered = function(datas, authorId, padId){
// Updates the database by removing the email record for that AuthorId
exports.unsetAuthorEmail = function (author, datas, callback){
db.get("globalAuthor:" + author, function(err, value){ // get the current value
// Remove the email option from the datas
delete value['email'];
// Write the modified datas back in the Db
db.set("globalAuthor:" + author, value);
});
}
// Remove email and padId from the database
// Remove email, options and padId from the database
exports.unsetAuthorEmailRegistered = function(datas, authorId, padId){
console.debug("unregistered", datas.email, " to ", padId);
// Here we have to basically hack a new value into the database, this isn't clean or polite.
db.get("emailSubscription:" + padId, function(err, value){ // get the current value
delete value[datas.email]; // remove the registered values to the object
console.warn("written to database");
db.set("emailSubscription:" + padId, value); // stick it in the database
});
db.get("emailSubscription:" + padId, function(err, value){ // get the current value
// remove the registered options from the object
delete value[datas.email];
// Write the modified datas back in the Db
console.warn("written to database");
db.set("emailSubscription:" + padId, value);
});
}

View file

@ -1,10 +1,10 @@
.ep_email_settings {
display: none;
padding-left: 1.5em;
padding: .2em;
display: none;
padding-left: 1.5em;
padding: .2em;
}
.ep_email_input {
padding:.2em;
width:177px;
padding:.2em;
width:177px;
}

View file

@ -22,14 +22,14 @@ exports.postAceInit = function(hook, context){
// Prepare subscription before submit form
$('#ep_email_subscribe').on('click', function() {
$('#ep_email_option').val('subscribe');
checkAndSend();
$('#ep_email_option').val('subscribe');
checkAndSend();
});
// Prepare unsubscription before submit form
$('#ep_email_unsubscribe').on('click', function() {
$('#ep_email_option').val('unsubscribe');
checkAndSend();
$('#ep_email_option').val('unsubscribe');
checkAndSend();
});
// subscribe by email can be active..

View file

@ -2,19 +2,19 @@
<input type="checkbox" id="options-emailNotifications"></input>
<label for="options-emailNotifications">Email Notifications</label>
<div class="ep_email_settings">
<form class='ep_email_form'>
<input id='ep_email' class='ep_email_input' placeholder='your@email.com' type=email>
<label>Send a mail when someone..</label>
<br />
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onStart"></input>
<label for="ep_email_onStart">starts editing the pad</label>
<br />
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onEnd"></input>
<label for="ep_email_onEnd">finish editing the pad</label>
<input id='ep_email_option'type=hidden >
</form>
<br />
<input style="padding:5px;" id='ep_email_subscribe' type=button value=subscribe>
<input style="padding:5px;" id='ep_email_unsubscribe'type=button value=unsubscribe>
<form class='ep_email_form'>
<input id='ep_email' class='ep_email_input' placeholder='your@email.com' type=email>
<label>Send a mail when someone..</label>
<br />
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onStart"></input>
<label for="ep_email_onStart">starts editing the pad</label>
<br />
<input type="checkbox" style="margin-left:0.3em;" id="ep_email_onEnd"></input>
<label for="ep_email_onEnd">finish editing the pad</label>
<input id='ep_email_option'type=hidden >
</form>
<br />
<input style="padding:5px;" id='ep_email_subscribe' type=button value=subscribe>
<input style="padding:5px;" id='ep_email_unsubscribe'type=button value=unsubscribe>
</div>
</p>

View file

@ -45,8 +45,8 @@ exports.notifyBegin = function(padId){
async.forEach(Object.keys(recipients), function(recipient, cb){
// Is this recipient already on the pad?
exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the pad?
var onStart = typeof(recipients[recipient].onStart) == "undefined" || recipients[recipient].onStart?true:false; // In case onStart wasn't defined we set it to true
if(!userIsOnPad && onStart){
var onStart = typeof(recipients[recipient].onStart) == "undefined" || recipients[recipient].onStart?true:false; // In case onStart wasn't defined we set it to true
if(!userIsOnPad && onStart){
console.debug("Emailing "+recipient +" about a new begin update");
server.send({
text: "Your pad at "+urlToPads+padId +" is being edited, we're just emailing you let you know :)",
@ -77,7 +77,7 @@ exports.notifyEnd = function(padId){
async.forEach(Object.keys(recipients), function(recipient, cb){
// Is this recipient already on the pad?
exports.isUserEditingPad(padId, recipients[recipient].authorId, function(err,userIsOnPad){ // is the user already on the$
var onEnd = typeof(recipients[recipient].onEnd) == "undefined" || recipients[recipient].onEnd?true:false; // In case onEnd wasn't defined we set it to true
var onEnd = typeof(recipients[recipient].onEnd) == "undefined" || recipients[recipient].onEnd?true:false; // In case onEnd wasn't defined we set it to false
if(!userIsOnPad && onEnd){
console.debug("Emailing "+recipient +" about a pad finished being updated");