<commit_before>/**
 * Initialization code for the dashboard pages. Starts up the Project Organizer
 * and binds the onboarder Knockout components.
 */

'use strict';

var Raven = require('raven-js');
var ko = require('knockout');
var $ = require('jquery');
var jstz = require('jstimezonedetect');
var bootbox = require('bootbox');

// Knockout components for the onboarder
require('js/onboarder.js');
var $osf = require('js/osfHelpers');
var LogFeed = require('js/logFeed');
var ProjectOrganizer = require('js/projectorganizer').ProjectOrganizer;

var url = '/api/v1/dashboard/get_nodes/';

var request = $.getJSON(url, function(response) {
    var allNodes = response.nodes;
    //  For uploads, only show nodes for which user has write or admin permissions
    var uploadSelection = ko.utils.arrayFilter(allNodes, function(node) {
        return $.inArray(node.permissions, ['write', 'admin']) !== -1;
    });

    // If we need to change what nodes can be registered, filter here
    var registrationSelection = ko.utils.arrayFilter(allNodes, function(node) {
        return $.inArray(node.permissions, ['admin']) !== -1;
    });
    $osf.applyBindings({nodes: allNodes}, '#obGoToProject');
    $osf.applyBindings({nodes: registrationSelection, enableComponents: true}, '#obRegisterProject');
    $osf.applyBindings({nodes: uploadSelection}, '#obUploader');
    $osf.applyBindings({nodes: allNodes}, '#obCreateProject');
});
request.fail(function(xhr, textStatus, error) {
    Raven.captureMessage('Could not fetch dashboard nodes.', {
        url: url, textStatus: textStatus, error: error
    });
});

var confirmedEmailURL = window.contextVars.confirmedEmailURL;
var removeConfirmedEmailURL = window.contextVars.removeConfirmedEmailURL;

function confirm_emails(emails) {
    if (emails.length > 0) {
        var email = emails.splice(0,1);

        var title = email[0]['user_merge'] ? 'Merge account' : 'Add email';

        var merge_message = email[0]['user_merge'] ? 'Would you like to merge ' + email[0].address +
        ' into your account?  This action is irreversable.' : 'Would you like to add ' + email[0].address +
        ' to your account?';

        bootbox.confirm({
            title: title,
            message: merge_message,
            callback: function(confirmed) {
                if (confirmed) {
                    $osf.putJSON(
                        confirmedEmailURL,
                        email[0]
                    ).done(function() {
                        confirm_emails(emails);
                    }).fail(function() {<commit_msg>change notation on object<commit_after>/**
 * Initialization code for the dashboard pages. Starts up the Project Organizer
 * and binds the onboarder Knockout components.
 */

'use strict';

var Raven = require('raven-js');
var ko = require('knockout');
var $ = require('jquery');
var jstz = require('jstimezonedetect');
var bootbox = require('bootbox');

// Knockout components for the onboarder
require('js/onboarder.js');
var $osf = require('js/osfHelpers');
var LogFeed = require('js/logFeed');
var ProjectOrganizer = require('js/projectorganizer').ProjectOrganizer;

var url = '/api/v1/dashboard/get_nodes/';

var request = $.getJSON(url, function(response) {
    var allNodes = response.nodes;
    //  For uploads, only show nodes for which user has write or admin permissions
    var uploadSelection = ko.utils.arrayFilter(allNodes, function(node) {
        return $.inArray(node.permissions, ['write', 'admin']) !== -1;
    });

    // If we need to change what nodes can be registered, filter here
    var registrationSelection = ko.utils.arrayFilter(allNodes, function(node) {
        return $.inArray(node.permissions, ['admin']) !== -1;
    });
    $osf.applyBindings({nodes: allNodes}, '#obGoToProject');
    $osf.applyBindings({nodes: registrationSelection, enableComponents: true}, '#obRegisterProject');
    $osf.applyBindings({nodes: uploadSelection}, '#obUploader');
    $osf.applyBindings({nodes: allNodes}, '#obCreateProject');
});
request.fail(function(xhr, textStatus, error) {
    Raven.captureMessage('Could not fetch dashboard nodes.', {
        url: url, textStatus: textStatus, error: error
    });
});

var confirmedEmailURL = window.contextVars.confirmedEmailURL;
var removeConfirmedEmailURL = window.contextVars.removeConfirmedEmailURL;

function confirm_emails(emails) {
    if (emails.length > 0) {
        var email = emails.splice(0,1);
        var title = email[0].user_merge ? 'Merge account' : 'Add email';

        var merge_message = email[0].user_merge ? 'Would you like to merge ' + email[0].address +
        ' into your account?  This action is irreversable.' : 'Would you like to add ' + email[0].address +
        ' to your account?';

        bootbox.confirm({
            title: title,
            message: merge_message,
            callback: function(confirmed) {
                if (confirmed) {
                    $osf.putJSON(
                        confirmedEmailURL,
                        email[0]
                    ).done(function() {
                        confirm_emails(emails);
                    }).fail(function() {
{'fraction_non_alphanumeric': 0.13093162889792756, 'fraction_numerical': 0.004261088514429595, 'mean_word_length': 3.1016679904686257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3618953', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1447, 'n_words': 383}