<commit_before>//
// Block palette
//
var ProgramEditorBlockPalette = function(options) {

    var container = options.container;
    var programEditorPanel = options.programEditorPanel;

    var blockPalette = $('<div>', { css: {  backgroundColor: 'white' } } );

    var createSection = function(name, content) {

        var div         = $('<div>', { css: {   width: '100%',
                                                cursor: 'pointer' } } );

        var title = $('<div>', { css: {paddingLeft: '2px' }} ).text(name);
        title.click( function(e) {
            if(content.is(":visible")) {
                content.hide();
            } else {
                content.show();
            }
        });

        div.append(title); 
        div.append(content);

        return div;
    }

    var createSensorBtn = function(name) {
        var btn = $('<button>', { css: { width: '100%' } } );
        btn.text(name);
        return btn;
    };

    var temp        = createSensorBtn("Temperature");
    var humidity    = createSensorBtn("Humidity");
    var co2         = createSensorBtn("CO2");

    var sensorContent = $('<div>');
    sensorContent.append(temp);
    sensorContent.append(humidity);
    sensorContent.append(co2);

    var sensors     = createSection("Sensors", sensorContent);
    blockPalette.append(sensors);

    var filterContent = $('<div>');
    var filterButton = $('<button>', { css: { width: '100%' } } );
    filterButton.text('Filter');
    filterButton.click( function() {
        programEditorPanel.showFilterBlockSelector();
    });
    filterContent.append(filterButton);
    var filters = createSection("Filters", filterContent);
    blockPalette.append(filters);

    container.append(blockPalette);

}<commit_msg>Add filters buttons to palette.<commit_after>//
// Block palette
//
var ProgramEditorBlockPalette = function(options) {

    var container = options.container;
    var programEditorPanel = options.programEditorPanel;

    var blockPalette = $('<div>', { css: {  backgroundColor: 'white' } } );

    var createSection = function(name, content) {

        var div         = $('<div>', { css: {   width: '100%',
                                                cursor: 'pointer' } } );

        var title = $('<div>', { css: {paddingLeft: '2px' }} ).text(name);
        title.click( function(e) {
            if(content.is(":visible")) {
                content.hide();
            } else {
                content.show();
            }
        });

        div.append(title); 
        div.append(content);

        return div;
    }

    var createSensorBtn = function(name) {
        var btn = $('<button>', { css: { width: '100%' } } );
        btn.text(name);
        return btn;
    };

    var temp        = createSensorBtn("Temperature");
    var humidity    = createSensorBtn("Humidity");
    var co2         = createSensorBtn("CO2");

    var sensorContent = $('<div>');
    sensorContent.append(temp);
    sensorContent.append(humidity);
    sensorContent.append(co2);

    var sensors     = createSection("Sensors", sensorContent);
    blockPalette.append(sensors);

    var filterContent = $('<div>');

    var createFilterBtn = function(type) {
        console.log("[DEBUG] programEditorPanel", programEditorPanel);
        var btn = $('<button>', { text: type, css: { width: '100%' } } );
        btn.click(type, function(e) {
            programEditorPanel.addFilterBlock(e);
        });
        return btn;
    }

    var andButton   = createFilterBtn("and");
    var orButton    = createFilterBtn("or");
    var notButton   = createFilterBtn("not");

    var filterButton = $('<button>', { css: { width: '100%' } } );
    filterButton.text('...');
    filterButton.click( function() {
        programEditorPanel.showFilterBlockSelector();
    });

    filterContent.append(andButton);
    filterContent.append(orButton);
    filterContent.append(notButton);
    filterContent.append(filterButton);

    var filters = createSection("Filters", filterContent);

    blockPalette.append(filters);

    container.append(blockPalette);

}
{'fraction_non_alphanumeric': 0.15165530671859787, 'fraction_numerical': 0.007059396299902629, 'mean_word_length': 2.3707957342083676, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '819799', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1148, 'n_words': 233}