
/*
 * GET home page.
 */

var _ = require('underscore');


exports.index = function(env, ga) {
  return function(req, res) {
    res.render('index', { title: 'A memo from Santa!', env: env, ga: ga });
  }
};

exports.handleEmails = function(req, res) {
  var postData = req.body,
      mailData = {}, secretSanta;
  console.log(postData);
  mailData.event = postData.event;

  secretSanta = (function() {
    var len = postData.people.length, i;
    for(i = 0; i < len; i++) {
      _.sample(postData.people)
    }
  })();

  console.log(mailData);
  res.json(mailData);
}


@@ -206,370 +206,4 @@
 %0A%7D;%0A
-%0Aexports.handleEmails = function(req, res) %7B%0A  var postData = req.body,%0A      mailData = %7B%7D, secretSanta;%0A  console.log(postData);%0A  mailData.event = postData.event;%0A%0A  secretSanta = (function() %7B%0A    var len = postData.people.length, i;%0A    for(i = 0; i %3C len; i++) %7B%0A      _.sample(postData.people)%0A    %7D%0A  %7D)();%0A%0A  console.log(mailData);%0A  res.json(mailData);%0A%7D%0A%0A

handle emails has been moved to app.js