<commit_before>var shpwrite = require('shp-write'),
    clone = require('clone'),
    geojson2dsv = require('geojson2dsv'),
    topojson = require('topojson'),
    saveAs = require('filesaver.js'),
    tokml = require('tokml'),
    githubBrowser = require('github-file-browser'),
    gistBrowser = require('gist-map-browser'),
    geojsonNormalize = require('geojson-normalize'),
    geojsonNormalizeProperties = require('../lib/geojson-normalize-properties'),
    wellknown = require('wellknown'),
    vex = require('vex-js'),
    vexDialog = require('vex-js/js/vex.dialog.js'),
    S = require('string'),
    $ = require('jquery');

require('jstree');

var flash = require('./flash'),
    zoomextent = require('../lib/zoomextent'),
    readFile = require('../lib/readfile'),
    meta = require('../lib/meta.js'),
    serializer = require('../lib/serializer'),
    loading = require('../ui/loading.js');

/**
 * This module provides the file picking & status bar above the map interface.
 * It dispatches to source implementations that interface with specific
 * sources, like GitHub.
 */
module.exports = function fileBar(context) {

    var github = require('../source/github')(context),
        config = require('../lib/config')(context),
        serie = require('../ui/serie')(context),
        shpSupport = typeof ArrayBuffer !== 'undefined'
        isAuth = context.storage.get('github_token') !== undefined;
    vex.defaultOptions.className = 'vex-theme-os';
    vexDialog.defaultOptions.showCloseButton = true;

    var exportFormats = [{
        title: 'GeoJSON',
        action: downloadGeoJSON
    }, {
        title: 'TopoJSON',
        action: downloadTopo
    }, {
        title: 'CSV',
        action: downloadDSV
    }, {
        title: 'KML',
        action: downloadKML
    }, {
        title: 'WKT',
        action: downloadWKT
    }];

    if (shpSupport) {
        exportFormats.push({
            title: 'Shapefile',
            action: downloadShp
        });
    }

    function bar(selection) {

        var actions = [{
          title: context.texts.newSerie,
          action: newSerie,
          enabled: isAuth
        }, {
          title: context.texts.openSerie,
          action: openSerie,
          enabled: isAuth
        }, {
          title: context.texts.save,
          id: 'save',
          action: saveWork,
          enabled: false
        }, {
          title: context.texts.discardChanges,
          id: 'discard',
          action: discardWork,
          enabled: false
        }, {
          title: context.texts.publish,
          id: 'publish',
          action: publishWork,
          enabled: false
        }, {
          title: context.texts.import,
          id: 'import',
          alt: context.texts.importAlt,
          action: blindImport,
          enabled: false
        }, {
          title: context.texts.export,
          id: 'export',
          children: exportFormats,
          enabled: false
        }, {
            title: context.texts.tools,
            id: 'tools',
            children: [
                {
                    title: context.texts.addMapLayer,
                    alt: context.texts.addMapLayerAlt,
                    action: function() {
                        var layerURL = prompt(context.texts.layerURL + ' \n(http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg)');
                        if (layerURL === null) return;
                        var layerName = prompt(context.texts.layerName);
                        if (layerName === null) return;
                        meta.adduserlayer(context, layerURL, layerName);
                    }
                },
                {
                    title: context.texts.zoomToFeatures,
                    alt: context.texts.zoomToFeaturesAlt,
                    action: function() {
                        meta.zoomextent(context);
                    }
                },
                {
                    title: context.texts.clear,
                    alt: context.texts.clearAlt,
                    action: function() {
                        if (confirm(context.texts.clearConfirm)) {
                            meta.clear(context);
                        }
                    }
                }
            ],
            enabled: false
        }, {
          title: 'Catalog',
          href: '/',
          enabled: true
        }];

        var items = selection.append('div')
            .attr('class', 'inline')
            .selectAll('div.item')
            .data(actions)
            .enter()
            .append('div')
            .attr('class', function(d) { return 'item' + (d.enabled ? '' : ' disabled'); })
            .attr('id', function(d) { return d.id ? 'button-' + d.id : null; });

        var buttons = items.append('a')
            .attr('class', 'parent')
            .attr('href', function(d) { return d.href ? d.href : '#'; })
            .on('click', function(d) {
                if (d.action) d.action.apply(this, d);
            })
            .text(function(d) {
                return ' ' + d.title;
            });

        items.each(function(d) {
            if (!d.children) return;<commit_msg>Fixed bug with tool buttons<commit_after>var shpwrite = require('shp-write'),
    clone = require('clone'),
    geojson2dsv = require('geojson2dsv'),
    topojson = require('topojson'),
    saveAs = require('filesaver.js'),
    tokml = require('tokml'),
    githubBrowser = require('github-file-browser'),
    gistBrowser = require('gist-map-browser'),
    geojsonNormalize = require('geojson-normalize'),
    geojsonNormalizeProperties = require('../lib/geojson-normalize-properties'),
    wellknown = require('wellknown'),
    vex = require('vex-js'),
    vexDialog = require('vex-js/js/vex.dialog.js'),
    S = require('string'),
    $ = require('jquery');

require('jstree');

var flash = require('./flash'),
    zoomextent = require('../lib/zoomextent'),
    readFile = require('../lib/readfile'),
    meta = require('../lib/meta.js'),
    serializer = require('../lib/serializer'),
    loading = require('../ui/loading.js');

/**
 * This module provides the file picking & status bar above the map interface.
 * It dispatches to source implementations that interface with specific
 * sources, like GitHub.
 */
module.exports = function fileBar(context) {

    var github = require('../source/github')(context),
        config = require('../lib/config')(context),
        serie = require('../ui/serie')(context),
        shpSupport = typeof ArrayBuffer !== 'undefined'
        isAuth = context.storage.get('github_token') !== undefined;
    vex.defaultOptions.className = 'vex-theme-os';
    vexDialog.defaultOptions.showCloseButton = true;

    var exportFormats = [{
        title: 'GeoJSON',
        action: downloadGeoJSON
    }, {
        title: 'TopoJSON',
        action: downloadTopo
    }, {
        title: 'CSV',
        action: downloadDSV
    }, {
        title: 'KML',
        action: downloadKML
    }, {
        title: 'WKT',
        action: downloadWKT
    }];

    if (shpSupport) {
        exportFormats.push({
            title: 'Shapefile',
            action: downloadShp
        });
    }

    function bar(selection) {

        var actions = [{
          title: context.texts.newSerie,
          action: newSerie,
          enabled: isAuth
        }, {
          title: context.texts.openSerie,
          action: openSerie,
          enabled: isAuth
        }, {
          title: context.texts.save,
          id: 'save',
          action: saveWork,
          enabled: false
        }, {
          title: context.texts.discardChanges,
          id: 'discard',
          action: discardWork,
          enabled: false
        }, {
          title: context.texts.publish,
          id: 'publish',
          action: publishWork,
          enabled: false
        }, {
          title: context.texts.import,
          id: 'import',
          alt: context.texts.importAlt,
          action: blindImport,
          enabled: false
        }, {
          title: context.texts.export,
          id: 'export',
          children: exportFormats,
          enabled: false
        }, {
            title: context.texts.tools,
            id: 'tools',
            children: [
                {
                    title: context.texts.addMapLayer,
                    alt: context.texts.addMapLayerAlt,
                    action: function() {
                        var layerURL = prompt(context.texts.layerURL + ' \n(http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg)');
                        if (layerURL === null) return;
                        var layerName = prompt(context.texts.layerName);
                        if (layerName === null) return;
                        meta.adduserlayer(context, layerURL, layerName);
                    }
                },
                {
                    title: context.texts.zoomToFeatures,
                    alt: context.texts.zoomToFeaturesAlt,
                    action: function() {
                        meta.zoomextent(context);
                    }
                },
                {
                    title: context.texts.clear,
                    alt: context.texts.clearAlt,
                    action: function() {
                        if (confirm(context.texts.clearConfirm)) {
                            meta.clear(context);
                        }
                    }
                }
            ],
            enabled: false
        }, {
          title: 'Catalog',
          href: '/',
          enabled: true
        }];

        var items = selection.append('div')
            .attr('class', 'inline')
            .selectAll('div.item')
            .data(actions)
            .enter()
            .append('div')
            .attr('class', function(d) { return 'item' + (d.enabled ? '' : ' disabled'); })
            .attr('id', function(d) { return d.id ? 'button-' + d.id : null; });

        var buttons = items.append('a')
            .attr('class', 'parent')
            .attr('href', function(d) { return d.href ? d.href : undefined; })
            .on('click', function(d) {
                if (d.action) d.action.apply(this, d);
            })
            .text(function(d) {
                return ' ' + d.title;
            });

        items.each(function(d) {
            if (!d.children) return;
{'fraction_non_alphanumeric': 0.13614527286702535, 'fraction_numerical': 0.0003843197540353574, 'mean_word_length': 1.5344533722912101, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6114478', 'n_tokens_mistral': 2901, 'n_tokens_neox': 2789, 'n_words': 550}