<commit_before>var shapeDivisions = [{
        division: "circleShape",
        display_division: "Circle"
    }, {
        division: "squareShape",
        display_division: "Square"
    }, {
        division: "triangleShape",
        display_division: "Triangle"
    }, {
        division: "starShape",
        display_division: "Star"
    }, {
        division: "rectangleShape",
        display_division: "Rectangle"
    }, {
        division: "diamondShape",
        display_division: "Diamond"
    }
];

// Menu, stocking the divisions of our menu, and subdivisions
var menuAction = [{
    division: "addNode",
    display_division: "Add Node",
    subDivisions : [{
        division: "substituentNode",
        display_division: "Substituent",
        subDivisions: shapeDivisions
    }, {
        division: "monosaccharideNode",
        display_division: "Monosaccharide",
        subDivisions: shapeDivisions
    }]
}, {
    division: "addStructure",
    display_division: "Add Structure",
    subDivisions : [{
        division: "subStruct",
        display_division: "Sub Struct",
        subDivisions: [{
            division: "subStruct1",
            display_division: "SubStruct 1"
        },{
            division: "subStruct2",
            display_division:"SubStruct 2"
        }
        ]
    }]
}, {
    division: "changeMono",
    display_division: "Change Mono"
}];

function updateMenu(chosenDivision) {
    // Size and margin properties
    var cDim = {
        height: 50,
        width: 500,
        barMargin: 0
    };

    d3.select("#actions").selectAll("*").remove(); // Reinitialize the svg actions menu
    d3.select("#labels").selectAll("*").remove(); // Reinitialize the svg labels menu
    var actions = d3.select("#actions"); // Actions
    var labels = d3.select("#labels"); // Labels

    // Height of our menu
    var maxHeight = 10;

    // Scale function with heights.
    var barHeight = d3.scale.linear()
        .domain([0, maxHeight])
        .range([0, cDim.height]);
    // Set the height and width of our SVG element
    var svgMenu = d3.select("#svgMenu").attr({
        height: cDim.height,
        width: cDim.width
    });
    var newMenuAction = [];

    if (typeof chosenDivision === 'undefined') { // First menu
        newMenuAction = menuAction;
    } else {
        newMenuAction = getSubDivisions(menuAction, chosenDivision)
    }
    if (typeof newMenuAction === 'undefined') {
        d3.select("#svgMenu").style("display", "none");
        return;
    }
    // Figure out how much space is actually available for the divisions
    var marginlessWidth = cDim.width - (cDim.barMargin * (newMenuAction.length - 1));
    cDim.barWidth = marginlessWidth / newMenuAction.length;
    bars = actions.selectAll("rect").data(newMenuAction);
    bars.enter().append("rect")
        .attr("width", function (d, i) {
            return cDim.barWidth
        })
        .attr("height", function (d, i) {
            return barHeight(10)
        })
        .attr("y", function (d, i) {
            return cDim.height - barHeight(10);
        })
        .attr("x", function (d, i) {
            return (cDim.barWidth + cDim.barMargin) * i;
        })
        .attr("id", function (d) {
            return d.division;
        })
        .attr("class", function(d) {
            return "bar choice"
        })
        .on("click", function(d) {
            updateMenu(d.division);
        });

    /*
     *  Label drawing block
     */

    textNodes = labels.selectAll("text").data(newMenuAction);

    textNodes.enter().append("text")
        .attr("class", "label")
        .attr("x", function (d, i) {
            return ((cDim.barWidth + cDim.barMargin) * i) + (cDim.barWidth / 2);
        })
        .attr("y", function (d, i) {
            return cDim.height - barHeight(10) + 8;
        })
        .text(function (d, i) {
            return d.display_division;
        });
    // remove old elements
    bars.exit().remove();
    textNodes.exit().remove();
}

/**
 * Get SubDivisions of a searched division, using recursive calls
 * @param divisionToCheck
 * @param searchedDivision
 * @returns {*}
 */
function getSubDivisions (divisionToCheck, searchedDivision) {
    if (divisionToCheck) {
        for (var div of divisionToCheck) {
            if (div.division == searchedDivision) {
                return div.subDivisions;
            }

            var found = getSubDivisions(div.subDivisions, searchedDivision);
            if (found) return found;
        }
    }
}<commit_msg>Link between shapes and colors, menu size to think about<commit_after>// Shape Divisions with all possible monosaccharide shapes
var shapeDivisions = [{
        division: "circleShape",
        display_division: "Circle"
    }, {
        division: "squareShape",
        display_division: "Square"
    }, {
        division: "triangleShape",
        display_division: "Triangle"
    }, {
        division: "starShape",
        display_division: "Star"
    }, {
        division: "rectangleShape",
        display_division: "Rectangle"
    }, {
        division: "diamondShape",
        display_division: "Diamond"
    }
];

// Color Divisions with all possible colors
var colorDivisions = [{
        division: "whiteColor",
        display_division: "White"
    }, {
        division: "blueColor",
        display_division: "Blue"
    }, {
        division: "greenColor",
        display_division: "Green"
    }, {
        division: "yellowColor",
        display_division: "Yellow"
    }, {
        division: "orangeColor",
        display_division: "Orange"
    }, {
        division: "pinkColor",
        display_division: "Pink"
    }, {
        division: "purpleColor",
        display_division: "Purple"
    }, {
        division:"lightBlueColor",
        display_division: "Light Blue"
    }, {
        division:"brownColor",
        display_division: "Brown"
    }, {
        division:"redCOlor",
        display_division: "Red"
    }
];

// Menu, stocking the divisions of our menu, and subdivisions
var menuAction = [{
    division: "addNode",
    display_division: "Add Node",
    subDivisions : [{
        division: "substituentNode",
        display_division: "Substituent",
        subDivisions: shapeDivisions
    }, {
        division: "monosaccharideNode",
        display_division: "Monosaccharide",
        subDivisions: shapeDivisions
    }]
}, {
    division: "addStructure",
    display_division: "Add Structure",
    subDivisions : [{
        division: "subStruct",
        display_division: "Sub Struct",
        subDivisions: [{
            division: "subStruct1",
            display_division: "SubStruct 1"
        },{
            division: "subStruct2",
            display_division:"SubStruct 2"
        }
        ]
    }]
}, {
    division: "changeMono",
    display_division: "Change Mono"
}];

function updateMenu(chosenDivision) {
    // Size and margin properties
    var cDim = {
        height: 50,
        width: 500,
        barMargin: 0
    };

    d3.select("#actions").selectAll("*").remove(); // Reinitialize the svg actions menu
    d3.select("#labels").selectAll("*").remove(); // Reinitialize the svg labels menu
    var actions = d3.select("#actions"); // Actions
    var labels = d3.select("#labels"); // Labels

    // Height of our menu
    var maxHeight = 10;

    // Scale function with heights.
    var barHeight = d3.scale.linear()
        .domain([0, maxHeight])
        .range([0, cDim.height]);
    // Set the height and width of our SVG element
    var svgMenu = d3.select("#svgMenu").attr({
        height: cDim.height,
        width: cDim.width
    });
    var newMenuAction = [];

    if (typeof chosenDivision === 'undefined') { // First menu
        newMenuAction = menuAction;
    } else {
        newMenuAction = getSubDivisions(menuAction, chosenDivision)
    }
    if (typeof newMenuAction === 'undefined') {
        d3.select("#svgMenu").style("display", "none");
        return;
    }
    // Figure out how much space is actually available for the divisions
    var marginlessWidth = cDim.width - (cDim.barMargin * (newMenuAction.length - 1));
    cDim.barWidth = marginlessWidth / newMenuAction.length;
    bars = actions.selectAll("rect").data(newMenuAction);
    bars.enter().append("rect")
        .attr("width", function (d, i) {
            return cDim.barWidth
        })
        .attr("height", function (d, i) {
            return barHeight(10)
        })
        .attr("y", function (d, i) {
            return cDim.height - barHeight(10);
        })
        .attr("x", function (d, i) {
            return (cDim.barWidth + cDim.barMargin) * i;
        })
        .attr("id", function (d) {
            return d.division;
        })
        .attr("class", function(d) {
            return "bar choice"
        })
        .on("click", function(d) {
            updateMenu(d.division);
        });

    /*
     *  Label drawing block
     */

    textNodes = labels.selectAll("text").data(newMenuAction);

    textNodes.enter().append("text")
        .attr("class", "label")
        .attr("x", function (d, i) {
            return ((cDim.barWidth + cDim.barMargin) * i) + (cDim.barWidth / 2);
        })
        .attr("y", function (d, i) {
            return cDim.height - barHeight(10) + 8;
        })
        .text(function (d, i) {
            return d.display_division;
        });
    // remove old elements
    bars.exit().remove();
    textNodes.exit().remove();
}

/**
 * Get SubDivisions of a searched division, using recursive calls
 * @param divisionToCheck
 * @param searchedDivision
 * @returns {*}
 */
function getSubDivisions (divisionToCheck, searchedDivision) {
    if (searchedDivision.indexOf("Shape") > -1) {
        return colorDivisions;
    }
    if (divisionToCheck) {
        for (var div of divisionToCheck) {
            if (div.division == searchedDivision) {
                return div.subDivisions;
            }

            var found = getSubDivisions(div.subDivisions, searchedDivision);
            if (found) return found;
        }
    }
}
{'fraction_non_alphanumeric': 0.13337296868806975, 'fraction_numerical': 0.0060443915973047956, 'mean_word_length': 2.1364201367308886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1527291', 'n_tokens_mistral': 3048, 'n_tokens_neox': 2905, 'n_words': 682}