<commit_before>var instance = jsPlumb.getInstance({
    Endpoint: ["Dot", {radius: 2}],
    Connector: "StateMachine",
    HoverPaintStyle: {strokeStyle: "#f44336", lineWidth: 2},
    ConnectionOverlays: [
        ["Arrow", {
            location: 1,
            id: "arrow",
            length: 14,
            foldback: 0.8
        }]
    ],
    Container: "canvas"
});

instance.registerConnectionType("basic", {anchor: "Continuous", connector: "StateMachine"});

window.jsp = instance;

var canvas = document.getElementById("canvas");
var windows = jsPlumb.getSelector(".statemachine-demo .w");


instance.bind("click", function (c) {
    instance.detach(c);
});


jsPlumb.fire("jsPlumbDemoLoaded", instance);

var initNode = function (el) {
    instance.draggable(el);
    instance.makeSource(el, {
        filter: ".ep",
        anchor: "Continuous",
        connectorStyle: {strokeStyle: "#26a69a", lineWidth: 2, outlineColor: "transparent", outlineWidth: 4},
        connectionType: "basic",
        extract: {
            "action": "the-action"
        }
    });
    instance.makeTarget(el, {
        dropOptions: {hoverClass: "dragHover"},
        anchor: "Continuous",
        allowLoopback: true
    });
};

var newNode = function (x, y, frontname, operation, subtype, fields) {
    var d = document.createElement("div");
    var id = jsPlumbUtil.uuid();
    d.className = "w";
    d.id = "box-" + subtype + "-" + id;

    var innerhtml = "";
    innerhtml += "<div class=\"btnClose\"><i class=\"material-icons tiny\">close</i></div>";
    innerhtml += "<div style=\"height:20px\">";
    if (fields != null && fields.length > 0) {
        innerhtml += "<div class=\"btnSettings\" style=\"float:left\"><i class=\"tiny material-icons\">mode_edit</i></div>&nbsp;&nbsp;";
    }
    innerhtml += frontname;
    innerhtml += "</div>";
    if (fields != null && fields.length > 0) {
        innerhtml += "<div class=\"settings\" style=\"display:none\">";
        innerhtml += fields;
        innerhtml += "</div>";
    }
    innerhtml += "<div class=\"res\"></div>";
    innerhtml += "<div class=\"ep\"></div>";


    d.innerHTML = innerhtml;
    d.style.left = x + "px";
    d.style.top = y + "px";
    d.setAttribute("data-operation", operation);
    d.setAttribute("data-subtype", subtype);

    document.getElementById("canvas").appendChild(d);
    initNode(d);

    if (fields != null && fields.length > 0) {
        $("#" + d.id + " > div > .btnSettings").click(function () {
            $("#" + d.id + " > .settings").toggle("slow");
        });
    }

    $("#" + d.id + " > .btnClose").click(function (e) {
        instance.remove($("#" + d.id));
        e.stopPropagation();
    });

    return d;
};


//init
for (var i = 0; i < windows.length; i++) {
    initNode(windows[i], true);
}

//add index
$("#btnAddIndex").click(function () {
    var option = $("#indextype option[value=" + $("#indextype").val() + "]");
    var frontname = option.text();
    var operation = option.data("operation");
    var subtype = option.data("subtype");
    var details = option.data("details");
    newNode(0, 0, frontname, operation, subtype, details);
});

//add operation
$("#btnAddOperation").click(function () {
    var option = $("#indexoperation option[value=" + $("#indexoperation").val() + "]");
    var frontname = option.text();
    var operation = option.data("operation");
    var subtype = option.data("subtype");
    var details = option.data("details");
    newNode(0, 0, frontname, operation, subtype, details);
});


//submit operation
$("#btnSubmit").click(function () {
    if ($("#entityname").val().length === 0) {
        showAlert(" Please specify an entity.");
        return;
    }

    if ($("#query").val().length === 0) {
        showAlert(" Please specify a query vector.");
        return;
    }

    if ($("#column").val().length === 0) {
        showAlert(" Please specify an attribute.");
        return;
    }

    $("#btnSubmit").addClass('disabled');
    $("#btnSubmit").prop('disabled', true);

    $("#progress").show();


    $.ajax("/query/compound", {
        data: JSON.stringify(evaluate("box-start")),
        contentType: 'application/json',
        type: 'POST',
        success: function (data) {
            if (data.code === 200) {
                $.each(data.details.intermediate_responses, function (idx, val) {
                    if (val.id.length > 0) {
                        $("#" + val.id + " > .res").html("execution time: " + val.time + "ms" + "<br/>" + "results: " + val.results.length);

                        var slicedData = val.results.slice(0, Math.min(150, val.results.length));
                        $("#" + val.id).data("results", slicedData);

                        $("#" + val.id).click(function () {
                            $("#resultbox").show();
                            var results = $("#" + val.id).data("results");

                            if (results.length > 0) {
                                var innerhtml = '';
                                innerhtml += '<table class="striped highlight">';
                                innerhtml += '<thead><tr>';

                                $.each(results[0], function (key, value) {
                                    innerhtml += "<th>" + key + "</th>"
                                });

                                innerhtml += '</tr></thead>';
                                innerhtml += '<tbody>';


                                $.each(results, function (key, value) {
                                    innerhtml += "<tr>";
                                    $.each(value, function (attributekey, attributevalue) {
                                        innerhtml += "<td>" + attributevalue + "</td>"
                                    });
                                    innerhtml += "</tr>";
                                });

                                innerhtml += '</tbody>';

                                innerhtml += '</table>';
                            }


                            $("#results").html(innerhtml);
                        });
                    }
                });
            } else {<commit_msg>result displayal in compound query<commit_after>var instance = jsPlumb.getInstance({
    Endpoint: ["Dot", {radius: 2}],
    Connector: "StateMachine",
    HoverPaintStyle: {strokeStyle: "#f44336", lineWidth: 2},
    ConnectionOverlays: [
        ["Arrow", {
            location: 1,
            id: "arrow",
            length: 14,
            foldback: 0.8
        }]
    ],
    Container: "canvas"
});

instance.registerConnectionType("basic", {anchor: "Continuous", connector: "StateMachine"});

window.jsp = instance;

var canvas = document.getElementById("canvas");
var windows = jsPlumb.getSelector(".statemachine-demo .w");


instance.bind("click", function (c) {
    instance.detach(c);
});


jsPlumb.fire("jsPlumbDemoLoaded", instance);

var initNode = function (el) {
    instance.draggable(el);
    instance.makeSource(el, {
        filter: ".ep",
        anchor: "Continuous",
        connectorStyle: {strokeStyle: "#26a69a", lineWidth: 2, outlineColor: "transparent", outlineWidth: 4},
        connectionType: "basic",
        extract: {
            "action": "the-action"
        }
    });
    instance.makeTarget(el, {
        dropOptions: {hoverClass: "dragHover"},
        anchor: "Continuous",
        allowLoopback: true
    });
};

var newNode = function (x, y, frontname, operation, subtype, fields) {
    var d = document.createElement("div");
    var id = jsPlumbUtil.uuid();
    d.className = "w";
    d.id = "box-" + subtype + "-" + id;

    var innerhtml = "";
    innerhtml += "<div class=\"btnClose\"><i class=\"material-icons tiny\">close</i></div>";
    innerhtml += "<div style=\"height:20px\">";
    if (fields != null && fields.length > 0) {
        innerhtml += "<div class=\"btnSettings\" style=\"float:left\"><i class=\"tiny material-icons\">mode_edit</i></div>&nbsp;&nbsp;";
    }
    innerhtml += frontname;
    innerhtml += "</div>";
    if (fields != null && fields.length > 0) {
        innerhtml += "<div class=\"settings\" style=\"display:none\">";
        innerhtml += fields;
        innerhtml += "</div>";
    }
    innerhtml += "<div class=\"res\"></div>";
    innerhtml += "<div class=\"ep\"></div>";


    d.innerHTML = innerhtml;
    d.style.left = x + "px";
    d.style.top = y + "px";
    d.setAttribute("data-operation", operation);
    d.setAttribute("data-subtype", subtype);

    document.getElementById("canvas").appendChild(d);
    initNode(d);

    if (fields != null && fields.length > 0) {
        $("#" + d.id + " > div > .btnSettings").click(function () {
            $("#" + d.id + " > .settings").toggle("slow");
        });
    }

    $("#" + d.id + " > .btnClose").click(function (e) {
        instance.remove($("#" + d.id));
        e.stopPropagation();
    });

    return d;
};


//init
for (var i = 0; i < windows.length; i++) {
    initNode(windows[i], true);
}

//add index
$("#btnAddIndex").click(function () {
    var option = $("#indextype option[value=" + $("#indextype").val() + "]");
    var frontname = option.text();
    var operation = option.data("operation");
    var subtype = option.data("subtype");
    var details = option.data("details");
    newNode(0, 0, frontname, operation, subtype, details);
});

//add operation
$("#btnAddOperation").click(function () {
    var option = $("#indexoperation option[value=" + $("#indexoperation").val() + "]");
    var frontname = option.text();
    var operation = option.data("operation");
    var subtype = option.data("subtype");
    var details = option.data("details");
    newNode(0, 0, frontname, operation, subtype, details);
});


//submit operation
$("#btnSubmit").click(function () {
    if ($("#entityname").val().length === 0) {
        showAlert(" Please specify an entity.");
        return;
    }

    if ($("#query").val().length === 0) {
        showAlert(" Please specify a query vector.");
        return;
    }

    if ($("#column").val().length === 0) {
        showAlert(" Please specify an attribute.");
        return;
    }

    $("#btnSubmit").addClass('disabled');
    $("#btnSubmit").prop('disabled', true);

    $("#progress").show();


    $.ajax("/query/compound", {
        data: JSON.stringify(evaluate("box-start")),
        contentType: 'application/json',
        type: 'POST',
        success: function (data) {
            if (data.code === 200) {
                $.each(data.details.intermediate_responses, function (idx, val) {
                    if (val.id.length > 0) {
                        $("#" + val.id + " > .res").html("execution time: " + val.time + "ms" + "<br/>" + "results: " + val.results.length);

                        var slicedData = val.results.slice(0, Math.min(150, val.results.length));
                        $("#" + val.id).data("results", slicedData);

                        $("#" + val.id).click(function () {
                            $("#resultbox").show();
                            var results = $("#" + val.id).data("results");

                            var innerhtml = '';
                            if (results != null && results.length > 0) {
                                innerhtml += '<table class="striped highlight">';
                                innerhtml += '<thead><tr>';

                                $.each(results[0], function (key, value) {
                                    innerhtml += "<th>" + key + "</th>"
                                });

                                innerhtml += '</tr></thead>';
                                innerhtml += '<tbody>';


                                $.each(results, function (key, value) {
                                    innerhtml += "<tr>";
                                    $.each(value, function (attributekey, attributevalue) {
                                        innerhtml += "<td>" + attributevalue + "</td>"
                                    });
                                    innerhtml += "</tr>";
                                });

                                innerhtml += '</tbody>';

                                innerhtml += '</table>';
                            }


                            $("#results").html(innerhtml);
                        });
                    }
                });
            } else {
{'fraction_non_alphanumeric': 0.18282504012841092, 'fraction_numerical': 0.006581059390048154, 'mean_word_length': 1.8135019191691126, 'pattern_counts': {'":': 2, '<': 67, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1455691', 'n_tokens_mistral': 3543, 'n_tokens_neox': 3371, 'n_words': 720}