<commit_before>// TODO: add play/pause/next/previous functionality to all algorithms
// TODO: complete the insertion/deletion methods for heap

var Vis = require('vis');
var fs = require('fs');

var network;

$(document).ready(function () {
    $('#insert-btn').click(function () {
        insertItem();
    });
    $('#delete-btn').click(function () {
        deleteItem();
    });

    $('#random-btn').click(function () {
        var numberOfNodes = Math.floor((Math.random() * 30) + 10);
        if (network !== null) {
            network.destroy();
        }
        var data = getFreeScaleNetworkWithWeights(numberOfNodes);
        network = new Vis.Network(container, data, options);
    });
});

var container = $('#tree-simple')[0];

var options = {
    autoResize: true,
    layout: {
        hierarchical: {
            enabled: true,
            parentCentralization: true,
            sortMethod: "directed",
            edgeMinimization: true
        }
    },
    interaction: {
        navigationButtons: true
    },
    physics: {
        enabled: false
    }
};

network = new Vis.Network(container, [], options);

function insertItem() {

}

function deleteItem() {

}

function impose() {

}<commit_msg>adding custom methods for adding/deleting node via popups<commit_after>// TODO: add play/pause/next/previous functionality to all algorithms
// TODO: complete the insertion/deletion methods for heap

var Vis = require('vis');
var fs = require('fs');

var network;

$(document).ready(function () {
    $('#insert-btn').click(function () {
        addHeapNode();
    });

    $('#delete-btn').click(function () {
        deleteHeapNode();
    });

    $('#random-btn').click(function () {
        var numberOfNodes = Math.floor((Math.random() * 30) + 10);
        if (network !== null) {
            network.destroy();
        }
        var data = getFreeScaleNetworkWithWeights(numberOfNodes);
        network = new Vis.Network(container, data, options);
    });
});

var container = $('#tree-simple')[0];

var options = {
    autoResize: true,
    layout: {
        hierarchical: {
            enabled: true,
            parentCentralization: true,
            sortMethod: "directed",
            edgeMinimization: true
        }
    },
    interaction: {
        navigationButtons: true
    },
    physics: {
        enabled: false
    }
};

network = new Vis.Network(container, [], options);

function insertItem(item) {

}

function deleteItem() {

}

function impose() {

}

function addHeapNode() {
    $('#node-label-text').removeClass('is-empty');
    document.getElementById('node-saveButton').onclick = saveNodeData.bind(this);
    document.getElementById('node-cancelButton').onclick = cancelNodeEdit.bind(this);
    document.getElementById('close-x1').onclick = cancelNodeEdit.bind(this);
    $('#node-popUp').css('display', 'block');
}

function deleteHeapNode() {
    $('#node-label-text').removeClass('is-empty');
    document.getElementById('node-saveButton').onclick = saveNodeData.bind(this);
    document.getElementById('node-cancelButton').onclick = cancelNodeEdit.bind(this);
    document.getElementById('close-x1').onclick = cancelNodeEdit.bind(this);
    $('#node-popUp').css('display', 'block');
}

function clearNodePopUp() {
    $('#node-saveButton').click(null);
    $('#node-cancelButton').click(null);
    $('#close-x1').click(null);
    $('#node-popUp').css('display', 'none');
}

function cancelNodeEdit() {
    clearNodePopUp();
}

function saveNodeData() {
    var nodeLabel = parseInt($('#node-label').val());
    if (!checkIfLabelExists(nodeLabel, network.body.data.nodes.get())) {
        clearNodePopUp();
        $("#n-label-text").text("Change node label");
        insertItem(nodeLabel);
    }
    else {
        $("#node-label-text").addClass("has-error");
        $("#n-label-text").text("Label already exists - please input another one");
    }
}
{'fraction_non_alphanumeric': 0.16798772692406033, 'fraction_numerical': 0.0033239580669905395, 'mean_word_length': 2.983706720977597, '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': '864969', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1145, 'n_words': 219}