<commit_before>/*globals $, _, Ractive*/

var Register = Ractive.extend({
    checkEmail: function (email) {
        return $.ajax({
            type: 'POST',
            dataType: 'json',
            url: '/login/check_email',
            data: {
                email: email
            }
        });
    },
    sendResetPasswordEmail: function (email) {
        return $.ajax({
            type: 'POST',
            dataType: 'json',
            url: '/login/reset',
            data: {
                email: email
            }
        });
    }
});


module.exports = {
    indexView: function(activities){

        // add a user_images array of user images and counters
        activities = _.map(activities, function (activity) {
            activity.user_images = _.reduce(activity.changes, function (memo, change) {
                var last = _.last(memo),
                    id = change.user._id,
                    image = change.user.profile_picture_path || '/img/user.png';
                if (!last || last.id !== id) {
                    memo.push({id: id, image: image, name: change.user.name, count: 1});
                }
                else {
                    last.count += 1;
                }
                return memo;
            }, []);
            return activity;
        });
        /*
        var ractive_activities = new Ractive({
            el: '#activities',
            template: '#activity-template',
            data: {
                activities: activities,
                ago: function (date) {
                    return moment(date).from();
                },
                marked: function (text) {
                    return marked(text);
                },
                last: function (array) {
                    return array.slice(-1)[0];
                }
            }
        });
        */

    },

    registerView: function () {
        var registermodal = new Ractive({
            el: '#register-modal',
            template: '#register-modal-template'
        });
        var resetpasswordmodal = new Ractive({
            el: '#reset-password-modal',
            template: '#reset-password-modal-template'
        });
        var ractive = new Register({
            el: '#register',
            template: '#register-template',
        });

        ractive.on('registerEmail', function (event) {
            event.original.preventDefault();

            ractive.checkEmail(event.context.email)
            .then(function (data) {<commit_msg>Silly uncomment took away the activity stream<commit_after>/*globals $, _, Ractive, moment, marked*/

var Register = Ractive.extend({
    checkEmail: function (email) {
        return $.ajax({
            type: 'POST',
            dataType: 'json',
            url: '/login/check_email',
            data: {
                email: email
            }
        });
    },
    sendResetPasswordEmail: function (email) {
        return $.ajax({
            type: 'POST',
            dataType: 'json',
            url: '/login/reset',
            data: {
                email: email
            }
        });
    }
});


module.exports = {
    indexView: function(activities){

        // add a user_images array of user images and counters
        activities = _.map(activities, function (activity) {
            activity.user_images = _.reduce(activity.changes, function (memo, change) {
                var last = _.last(memo),
                    id = change.user._id,
                    image = change.user.profile_picture_path || '/img/user.png';
                if (!last || last.id !== id) {
                    memo.push({id: id, image: image, name: change.user.name, count: 1});
                }
                else {
                    last.count += 1;
                }
                return memo;
            }, []);
            return activity;
        });

        var ractive_activities = new Ractive({
            el: '#activities',
            template: '#activity-template',
            data: {
                activities: activities,
                ago: function (date) {
                    return moment(date).from();
                },
                marked: function (text) {
                    return marked(text);
                },
                last: function (array) {
                    return array.slice(-1)[0];
                }
            }
        });

        return ractive_activities;
    },

    registerView: function () {
        var registermodal = new Ractive({
            el: '#register-modal',
            template: '#register-modal-template'
        });
        var resetpasswordmodal = new Ractive({
            el: '#reset-password-modal',
            template: '#reset-password-modal-template'
        });
        var ractive = new Register({
            el: '#register',
            template: '#register-template',
        });

        ractive.on('registerEmail', function (event) {
            event.original.preventDefault();

            ractive.checkEmail(event.context.email)
            .then(function (data) {
{'fraction_non_alphanumeric': 0.12165880503144653, 'fraction_numerical': 0.0015723270440251573, 'mean_word_length': 1.271875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5240507', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1237, 'n_words': 290}