<commit_before>if ( typeof L === "object") {
    (function() {
        //forEach Polyfill
        // Reference:
        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
        if (!Array.prototype.forEach) {
            Array.prototype.forEach = function(callback, thisArg) {
                var T, k;
                if (this == null) {
                    throw new TypeError(' this is null or not defined');
                }
                var O = Object(this);
                var len = O.length >>> 0;
                if ( typeof callback !== "function") {
                    throw new TypeError(callback + ' is not a function');
                }
                if (arguments.length > 1) {
                    T = thisArg;
                }
                k = 0;
                while (k < len) {
                    var kValue;
                    if ( k in O) {
                        kValue = O[k];

                        callback.call(T, kValue, k, O);
                    }
                    k++;
                }
            };
        }

        var extentNodeList = document.querySelectorAll('section.extent-section');
        var extents = Array.prototype.slice.call(extentNodeList);

        var mqAttr = '<p>Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png"></p>';
        var osmAttr = '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>';

        L.TileLayer.OSM = L.TileLayer.extend({
            initialize: function(options) {
                L.TileLayer.prototype.initialize.call(this, 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.png', {
                    subdomains: '1234',
                    type: 'osm',
                    attribution: 'Map data ' + osmAttr + ', ' + mqAttr
                });
            }
        });

        var check = function(i, me) {
            if (i < 3) {
                var resize = me.getSize().x === 0 && me.getContainer().offsetWidth > 0;
                console.info('norez');

                me.invalidateSize();
                if (resize) {
                    console.info('rez');
                    me.setView([0, 0], 2);
                } else {
                    i++;
                    setTimeout(function() {
                        check(i, me);
                    }, 100);
                }
            }
        };

        extents.forEach(function(extent, idx, arr) {
            var map = L.map(extent.querySelector('div.map'));
            var header = extent.querySelector('summary.map-header');

            L.DomEvent.addListener(header, 'click', function() {
                var me = this;
                var i = 0;

                //if (resize) {
                setTimeout(function() {
                    check(i, me);
                }, 100);
                //}
            }, map);

            console.info( map1 = map);
            map.setView([0, 0], 2);
            map.addLayer(new L.TileLayer.OSM());
        });
    })();
}<commit_msg>Finish up initial map implementation for HTML writer.<commit_after>if ( typeof L === "object") {
    (function() {
        //forEach Polyfill, Reference: https://goo.gl/hFIfSd
        if (!Array.prototype.forEach) {
            Array.prototype.forEach = function(callback, thisArg) {
                var T, k;
                if (this == null) {
                    throw new TypeError(' this is null or not defined');
                }
                var O = Object(this);
                var len = O.length >>> 0;
                if ( typeof callback !== "function") {
                    throw new TypeError(callback + ' is not a function');
                }
                if (arguments.length > 1) {
                    T = thisArg;
                }
                k = 0;
                while (k < len) {
                    var kValue;
                    if ( k in O) {
                        kValue = O[k];
                        callback.call(T, kValue, k, O);
                    }
                    k++;
                }
            };
        }

        var extentNodeList = document.querySelectorAll('section.extent-section');
        var extents = Array.prototype.slice.call(extentNodeList);

        var mqAttr = '<span>Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png"></span>';
        var osmAttr = '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>';

        L.TileLayer.OSM = L.TileLayer.extend({
            initialize: function(options) {
                L.TileLayer.prototype.initialize.call(this, 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.png', {
                    subdomains: '1234',
                    type: 'osm',
                    attribution: 'Map data ' + osmAttr + ', ' + mqAttr
                });
            }
        });

        var check = function(i, me, bnds) {
            if (i < 3) {
                var resize = me.getSize().x === 0 && me.getContainer().offsetWidth > 0;

                me.invalidateSize();
                if (resize) {
                    me.fitBounds(bnds);
                } else {
                    i++;
                    setTimeout(function() {
                        check(i, me, bnds);
                    }, 100);
                }
            }
        };

        extents.forEach(function(extent, idx, arr) {
            var map = L.map(extent.querySelector('div.map'));
            var header = extent.querySelector('summary.map-header');
            var geoNodelist = extent.querySelectorAll('div.geojson');
            var geoArray = Array.prototype.slice.call(geoNodelist);
            var geojson = [];

            geoArray.forEach(function(geo, geoIdx, geoArr) {
                var json = JSON.parse(geo.textContent || geo.innerText);
                var bbox = json.bbox;
                if (json.geometry === null && bbox) {
                    json.geometry = {
                        "type": "Polygon",
                        "coordinates": [[[bbox[2], bbox[3]], [bbox[0], bbox[3]], [bbox[0], bbox[1]], [bbox[2], bbox[1]], [bbox[2], bbox[3]]]]
                    };
                    if (!json.properties) {
                        json.properties = {};
                    }
                    json.properties.style = {
                        color: '#f00',
                        fill: false
                    };
                }

                geojson.push(json);
            });

            var geoLayer = L.geoJson(geojson, {
                style: function(feature) {
                    return feature.properties.style || {};
                }
            }).addTo(map);

            var bnds = geoLayer.getBounds();

            L.DomEvent.addListener(header, 'click', function() {
                var me = this;
                var i = 0;

                setTimeout(function() {
                    check(i, me, bnds);
                }, 100);

            }, map);

            map.fitBounds(bnds);
            map.addLayer(new L.TileLayer.OSM());
        });
    })();
}
{'fraction_non_alphanumeric': 0.1394470667565745, 'fraction_numerical': 0.008496291301416048, 'mean_word_length': 1.1914893617021276, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2560134', 'n_tokens_mistral': 2148, 'n_tokens_neox': 1952, 'n_words': 393}