<commit_before>/////////////////////
// Project JS      //
/////////////////////
(function(global, factory) {
    if (typeof define === 'function' && define.amd) {
        define(['jquery', 'js/logFeed', 'osfutils'], factory);
    } else {
        factory(jQuery, global.LogFeed);
    }
}(this, function($, LogFeed) {

    window.NodeActions = {}; // Namespace for NodeActions

    // TODO: move me to the NodeControl or separate module
    NodeActions.beforeForkNode = function(url, done) {
        $.ajax({
            url: url,
            contentType: 'application/json'
        }).done(function(response) {
            bootbox.confirm(
                $.osf.joinPrompts(response.prompts, 'Are you sure you want to fork this project?'),
                function(result) {
                    if (result) {
                        done && done();
                    }
                }
            );
        }).fail(
            $.osf.handleJSONError
        );
    };

    NodeActions.forkNode = function() {
        NodeActions.beforeForkNode(nodeApiUrl + 'fork/before/', function() {
            // Block page
            $.osf.block();
            // Fork node
            $.osf.postJSON(
                nodeApiUrl + 'fork/',
                {}
            ).done(function(response) {
                window.location = response;
            }).fail(function(response) {
                $.osf.unblock();
                if (response.status === 403) {
                    bootbox.alert('Sorry, you do not have permission to fork this project');
                } else {
                    bootbox.alert('Forking failed');
                }
            });
        });
    };

    NodeActions.forkPointer = function(pointerId) {
        bootbox.confirm('Are you sure you want to fork this project?',
            function(result) {
                if (result) {
                    // Block page
                    $.osf.block();

                    // Fork pointer
                    $.osf.postJSON(
                        nodeApiUrl + 'pointer/fork/',
                        {pointerId: pointerId}
                    ).done(function() {
                        window.location.reload();
                    }).fail(function() {
                        $.osf.unblock();
                        bootbox.alert('Could not fork link.');
                    });
                }
            }
        );
    };

    NodeActions.beforeTemplate = function(url, done) {
        $.ajax({
            url: url,
            contentType: 'application/json'
        }).success(function(response) {
            bootbox.confirm(
                $.osf.joinPrompts(response.prompts,
                    ('Are you sure you want to create a new project using this project as a template? ' +
                     'Any add-ons configured for this project will not be authenticated in the new project.')),
                function (result) {
                    if (result) {
                        done && done();
                    }
                }
            );
        });
    };

    NodeActions.addonFileRedirect = function(item) {
        window.location.href = item.params.urls.view;
        return false;
    };

    NodeActions.useAsTemplate = function() {
        NodeActions.beforeTemplate('/project/new/' + nodeId + '/beforeTemplate/', function () {
            $.osf.block();

            $.osf.postJSON('/api/v1/project/new/' + nodeId + '/',
                function (data) {
                    window.location = data.url;
                }).fail(function (response) {
                    $.osf.unblock();
                    $.osf.handleJSONError(response);
                });
            });
        };

    $(function() {

        $('#newComponent form').on('submit', function(e) {

            $('#add-component-submit')
                .attr('disabled', 'disabled')
                .text('Adding');

            if ($.trim($('#title').val()) === '') {

                $('#alert').text('The new component title cannot be empty');
<commit_msg>Fix templating bug due to improper use of $.osf.postJSON<commit_after>/////////////////////
// Project JS      //
/////////////////////
(function(global, factory) {
    if (typeof define === 'function' && define.amd) {
        define(['jquery', 'js/logFeed', 'osfutils'], factory);
    } else {
        factory(jQuery, global.LogFeed);
    }
}(this, function($, LogFeed) {

    window.NodeActions = {}; // Namespace for NodeActions

    // TODO: move me to the NodeControl or separate module
    NodeActions.beforeForkNode = function(url, done) {
        $.ajax({
            url: url,
            contentType: 'application/json'
        }).done(function(response) {
            bootbox.confirm(
                $.osf.joinPrompts(response.prompts, 'Are you sure you want to fork this project?'),
                function(result) {
                    if (result) {
                        done && done();
                    }
                }
            );
        }).fail(
            $.osf.handleJSONError
        );
    };

    NodeActions.forkNode = function() {
        NodeActions.beforeForkNode(nodeApiUrl + 'fork/before/', function() {
            // Block page
            $.osf.block();
            // Fork node
            $.osf.postJSON(
                nodeApiUrl + 'fork/',
                {}
            ).done(function(response) {
                window.location = response;
            }).fail(function(response) {
                $.osf.unblock();
                if (response.status === 403) {
                    bootbox.alert('Sorry, you do not have permission to fork this project');
                } else {
                    bootbox.alert('Forking failed');
                }
            });
        });
    };

    NodeActions.forkPointer = function(pointerId) {
        bootbox.confirm('Are you sure you want to fork this project?',
            function(result) {
                if (result) {
                    // Block page
                    $.osf.block();

                    // Fork pointer
                    $.osf.postJSON(
                        nodeApiUrl + 'pointer/fork/',
                        {pointerId: pointerId}
                    ).done(function() {
                        window.location.reload();
                    }).fail(function() {
                        $.osf.unblock();
                        bootbox.alert('Could not fork link.');
                    });
                }
            }
        );
    };

    NodeActions.beforeTemplate = function(url, done) {
        $.ajax({
            url: url,
            contentType: 'application/json'
        }).success(function(response) {
            bootbox.confirm(
                $.osf.joinPrompts(response.prompts,
                    ('Are you sure you want to create a new project using this project as a template? ' +
                     'Any add-ons configured for this project will not be authenticated in the new project.')),
                function (result) {
                    if (result) {
                        done && done();
                    }
                }
            );
        });
    };

    NodeActions.addonFileRedirect = function(item) {
        window.location.href = item.params.urls.view;
        return false;
    };

    NodeActions.useAsTemplate = function() {
        NodeActions.beforeTemplate('/project/new/' + nodeId + '/beforeTemplate/', function () {
            $.osf.block();

            $.osf.postJSON(
                '/api/v1/project/new/' + nodeId + '/',
                {}
            ).done(function(response) {
                window.location = response.url;
            }).fail(function(response) {
                $.osf.unblock();
                $.osf.handleJSONError(response);
            });
        });
    };

    $(function() {

        $('#newComponent form').on('submit', function(e) {

            $('#add-component-submit')
                .attr('disabled', 'disabled')
                .text('Adding');

            if ($.trim($('#title').val()) === '') {

                $('#alert').text('The new component title cannot be empty');

{'fraction_non_alphanumeric': 0.13999511360860004, 'fraction_numerical': 0.0009772782799902272, 'mean_word_length': 1.223519826181423, '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': '1657403', 'n_tokens_mistral': 2096, 'n_tokens_neox': 1964, 'n_words': 435}