<commit_before>"use strict";

var $ = require('jquery'),
    _ = require('underscore'),
    BU = require('treemap/baconUtils');

exports.init = function(options) {
    var config = options.config,
        $delete = $(options.delete),
        $deleteConfirm = $(options.deleteConfirm),
        $deleteCancel = $(options.deleteCancel),
        $deleteConfirmationBox = $(options.deleteConfirmationBox),
        plotId = $('div[data-field="plot.id"]').attr('data-value'),

        // tree id is the sole datapoint used to determine the state
        // of the plot to be acted upon. this information is used for:
        // * deciding which warning message to show
        // * The url to post a delete verb to
        // * the url to redirect to
        getTreeId = function () {
            return $(options.treeIdColumn).attr('data-tree-id');
        },
        
        // query whether a tree exists and
        // show or hide the plot/tree warning
        // finally, hide the whole containing box
        resetUIState = function () {
            if (getTreeId() === '') {
                $('#delete-plot-warning').show();
                $('#delete-tree-warning').hide();
            } else {
                $('#delete-tree-warning').show();
                $('#delete-plot-warning').hide();
            }
            $deleteConfirmationBox.hide();
        },

        // sends the appropriate deletion request to the server based on
        // the treeId value, then redirects to the correct page after
        // receiving a response. Tree deletions redirect back to plot detail,
        // plot deletions redirect to the map page.
        executeServerDelete = function () {
            var treeId = getTreeId(),
                deleteUrlBase = '',
                deleteUrl = treeId === '' ? deleteUrlBase :
                    deleteUrlBase + 'trees/' + treeId + '/',
                afterDeleteUrl = treeId === '' ? config.instance.mapUrl : '';

            $.ajax({
                url: deleteUrl,
                type: 'DELETE',
                success: function () {
                    window.location = afterDeleteUrl; 
                }
            });
        };

    // events
    $deleteConfirm.click(executeServerDelete);
    $deleteCancel.click(resetUIState);
    $delete.click(function () { 
        resetUIState();
        $deleteConfirmationBox.show(); 
    });
};
<commit_msg>Remove unused requirement<commit_after>"use strict";

var $ = require('jquery'),
    _ = require('underscore'),

exports.init = function(options) {
    var config = options.config,
        $delete = $(options.delete),
        $deleteConfirm = $(options.deleteConfirm),
        $deleteCancel = $(options.deleteCancel),
        $deleteConfirmationBox = $(options.deleteConfirmationBox),
        plotId = $('div[data-field="plot.id"]').attr('data-value'),

        // tree id is the sole datapoint used to determine the state
        // of the plot to be acted upon. this information is used for:
        // * deciding which warning message to show
        // * The url to post a delete verb to
        // * the url to redirect to
        getTreeId = function () {
            return $(options.treeIdColumn).attr('data-tree-id');
        },
        
        // query whether a tree exists and
        // show or hide the plot/tree warning
        // finally, hide the whole containing box
        resetUIState = function () {
            if (getTreeId() === '') {
                $('#delete-plot-warning').show();
                $('#delete-tree-warning').hide();
            } else {
                $('#delete-tree-warning').show();
                $('#delete-plot-warning').hide();
            }
            $deleteConfirmationBox.hide();
        },

        // sends the appropriate deletion request to the server based on
        // the treeId value, then redirects to the correct page after
        // receiving a response. Tree deletions redirect back to plot detail,
        // plot deletions redirect to the map page.
        executeServerDelete = function () {
            var treeId = getTreeId(),
                deleteUrlBase = '',
                deleteUrl = treeId === '' ? deleteUrlBase :
                    deleteUrlBase + 'trees/' + treeId + '/',
                afterDeleteUrl = treeId === '' ? config.instance.mapUrl : '';

            $.ajax({
                url: deleteUrl,
                type: 'DELETE',
                success: function () {
                    window.location = afterDeleteUrl; 
                }
            });
        };

    // events
    $deleteConfirm.click(executeServerDelete);
    $deleteCancel.click(resetUIState);
    $delete.click(function () { 
        resetUIState();
        $deleteConfirmationBox.show(); 
    });
};

{'fraction_non_alphanumeric': 0.12578484721640854, 'fraction_numerical': 0.0, 'mean_word_length': 1.7640254482359745, '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': '4998730', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1158, 'n_words': 326}