<commit_before>/*jshint browser: true, jquery: true */
/*global app, clique, _, tangelo */

function randomGraph(n, pct) {
    "use strict";

    var alphabet = "abcdefghijklmnopqrstuvwxyz",
        nodes = [],
        links = [];

    _.each(_.range(n), function (i) {
        nodes.push({
            name: alphabet[i]
        });
    });

    _.each(_.range(n), function (source, i) {
        _.each(_.range(i + 1, n), function (target) {
            if (Math.random() < pct) {
                links.push({
                    source: source,
                    target: target
                });
            }
        });
    });

    return {
        nodes: nodes,
        links: links
    };
}

$(function () {
    "use strict";

    var launch = function (cfg) {
        var graphData,
            graph,
            view,
            mode,
            info;

        mode = tangelo.queryArguments().mode || cfg.mode || "demo";

        if (mode === "demo") {
            mode = "demo";

            window.graphData = graphData = randomGraph(26, 0.20);

            window.graph = graph = new clique.Graph({
                adapter: clique.adapter.NodeLinkList,
                options: graphData
            });
        } else if (mode === "xdata") {
            mode = "xdata";

            window.graph = graph = new clique.Graph({
                adapter: tangelo.getPlugin("mongo-xdata").MongoXdata,
                options: {
                    host: cfg.xdataHost || "localhost",
                    database: cfg.xdataDatabase || "year3_graphs",
                    collection: cfg.xdataCollection || "mentions_monica_nino_2hop_mar12"
                }
            });
        } else if (mode === "mongo") {
            mode = "mongo";

            window.graph = graph = new clique.Graph({
                adapter: tangelo.getPlugin("mongo").Mongo,
                options: {
                    host: cfg.mongoHost || "localhost",
                    database: cfg.mongoDatabase || "year3_graphs",
                    collection: cfg.mongoCollection || "twittermentions"
                }
            });
        }

        $("#seed").on("click", function () {
            var name = $("#name").val().trim(),
                spec,
                radiusText = $("#radius").val().trim(),
                radius = Number(radiusText),
                delsearch = $("#delsearch").prop("checked");

            if (name === "" || radiusText === "" || isNaN(radius)) {
                return;
            }

            spec = {
                queryOp: "==",
                field: mode === "xdata" ? "username" : "name",
                value: name
            };
            graph.adapter.findNode(spec)
                .then(function (center) {
                    if (center) {
                        graph.addNeighborhood({
                            center: center,
                            radius: radius,
                            deleted: delsearch
                        });
                    }
                });
        });

        $("#save").on("click", function () {
            graph.adapter.sync();
        });

        window.view = view = new clique.view.Cola({
            model: graph,
            el: "#content"
        });

        window.info = info = new app.view.SelectionInfo({
            model: view.selection,
            el: "#info",
            graph: graph
        });
        info.render();
    };

    $.getJSON("clique.json").then(launch, _.bind(launch, {}));
});<commit_msg>Removing "mode" stuff to simplify application<commit_after>/*jshint browser: true, jquery: true */
/*global app, clique, _ */

function randomGraph(n, pct) {
    "use strict";

    var alphabet = "abcdefghijklmnopqrstuvwxyz",
        nodes = [],
        links = [];

    _.each(_.range(n), function (i) {
        nodes.push({
            name: alphabet[i]
        });
    });

    _.each(_.range(n), function (source, i) {
        _.each(_.range(i + 1, n), function (target) {
            if (Math.random() < pct) {
                links.push({
                    source: source,
                    target: target
                });
            }
        });
    });

    return {
        nodes: nodes,
        links: links
    };
}

$(function () {
    "use strict";

    var graphData,
        graph,
        view,
        info;

    graphData = randomGraph(26, 0.20);
    graph = new clique.Graph({
        adapter: clique.adapter.NodeLinkList,
        options: graphData
    });

    $("#seed").on("click", function () {
        var name = $("#name").val().trim(),
            spec,
            radiusText = $("#radius").val().trim(),
            radius = Number(radiusText),
            delsearch = $("#delsearch").prop("checked");

        if (name === "" || radiusText === "" || isNaN(radius)) {
            return;
        }

        spec = {
            queryOp: "==",
            field: "name",
            value: name
        };
        graph.adapter.findNode(spec)
            .then(function (center) {
                if (center) {
                    graph.addNeighborhood({
                        center: center,
                        radius: radius,
                        deleted: delsearch
                    });
                }
            });
    });

    $("#save").on("click", function () {
        graph.adapter.sync();
    });

    view = new clique.view.Cola({
        model: graph,
        el: "#content"
    });

    info = new app.view.SelectionInfo({
        model: view.selection,
        el: "#info",
        graph: graph
    });
    info.render();
});
{'fraction_non_alphanumeric': 0.1463587921847247, 'fraction_numerical': 0.003019538188277087, 'mean_word_length': 1.254203362690152, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1150022', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1484, 'n_words': 311}