<commit_before>(function(){
    var drawnItems = new L.FeatureGroup();
    var crimes = new L.FeatureGroup();
    var beats = new L.FeatureGroup();
    var map;
    var meta = L.control({position: 'bottomright'});
    var meta_data;
    meta.onAdd = function(map){
        this._div = L.DomUtil.create('div', 'meta');
        return this._div;
    }
    meta.update = function(meta_data){
        if(typeof meta_data !== 'undefined'){
            var tpl = new EJS({url: 'js/views/metaTemplate.ejs?2'});
            $(this._div).html(tpl.render(meta_data.totals_by_type));
        } else {
            $(this._div).empty();
            meta.removeFrom(map);
        }
    }
    //var endpoint = 'http://localhost:7777';
    var endpoint = 'http://crime-weather.smartchicagoapps.org';
    var AddressSearch = L.Control.extend({
        options: {
            position: 'topleft',
            keepOpen: false,
        },
        _toggle: function(e) {
            if (e) L.DomEvent.stop(e);
            if (L.DomUtil.hasClass(this._container, 'active')) {
                L.DomUtil.removeClass(this._container, 'active');
                this._results.innerHTML = '';
                this._input.blur();
            } else {
                L.DomUtil.addClass(this._container, 'active');
                this._input.focus();
                this._input.select();
            }
        },
        _closeIfOpen: function(e) {
            if (L.DomUtil.hasClass(this._container, 'active') &&
                !this.options.keepOpen) {
                L.DomUtil.removeClass(this._container, 'active');
                this._results.innerHTML = '';
                this._input.blur();
            }
        },
        onAdd: function(map) {
            var container = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder leaflet-bar leaflet-control'),
                link = L.DomUtil.create('a', 'leaflet-control-mapbox-geocoder-toggle mapbox-icon mapbox-icon-geocoder', container),
                results = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder-results', container),
                wrap = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder-wrap', container),
                form = L.DomUtil.create('form', 'leaflet-control-mapbox-geocoder-form', wrap),
                input  = L.DomUtil.create('input', '', form);

            link.href = '#';
            link.innerHTML = '&nbsp;';

            input.type = 'text';
            input.setAttribute('placeholder', 'Search');

            L.DomEvent.addListener(form, 'submit', this._geocode, this);
            L.DomEvent.disableClickPropagation(container);

            this._map = map;
            this._input = input;
            this._form = form;
            this._results = results;

            if (this.options.keepOpen) {
                L.DomUtil.addClass(container, 'active');
            } else {
                this._map.on('click', this._closeIfOpen, this);
                L.DomEvent.addListener(link, 'click', this._toggle, this);
            }
            return container;
        },
        _geocode: function(e){
            L.DomEvent.preventDefault(e);
            L.DomUtil.addClass(this._container, 'searching');
            var map = this._map;
            var container = this._container;
            var results = this._results;
            var self = this;
            var onload = L.bind(function(resp, err){
                L.DomUtil.removeClass(container, 'searching');
                results.innerHTML = '';
                var locations = resp.results[0].locations;
                if (locations.length === 1){
                    var latlng = [locations[0].latLng.lat, locations[0].latLng.lng];
                    map.setView(latlng, 17);
                    var mark = L.marker(latlng)
                    mark.addTo(map);
                    //self._fetch_near(mark); //Add in the $near query
                } else {
                    for (var i = 0, l = Math.min(locations.length, 5); i < l; i++) {
                        var name = [];
                        if (locations[i].street) name.push(locations[i].street);
                        if (!name.length) continue;

                        var r = L.DomUtil.create('a', '', this._results);
                        r.innerHTML = name.join(', ');
                        r.href = '#';

                        (L.bind(function(result) {
                            L.DomEvent.addListener(r, 'click', function(e) {
                                var lat = result.latLng.lat;
                                var lng = result.latLng.lng;
                                map.setView(L.latLng(lat, lng), 16);
                                var mark = L.marker([lat,lng]);
                                mark.addTo(map);
                                L.DomEvent.stop(e);
                                self._toggle();
                                //self._fetch_near(mark);
                                // add in the $near query
                            }, this);
                        }, this))(locations[i]);
                    }
                    if (resp.results.length > 5) {
                        var outof = L.DomUtil.create('span', '', this._results);
                        outof.innerHTML = 'Top 5 of ' + locations.length + '  results';
                    }
                }
            }, this);
            var query = this._input.value + ' Chicago, IL';
            var bbox = "42.023134979999995,-87.52366115999999,41.644286009999995,-87.94010087999999";
            var params = {
                key: '<KEY>',
                location: query,
                boundingBox: bbox
            }
            $.ajax({
                url:'http://open.mapquestapi.com/geocoding/v1/address',
                data: params,
                dataType: 'jsonp',
                success: onload
            });
        },
        _fetch_near: function(point){
            var geo = point.toGeoJSON()['geometry'];
            var query = {};
            query['location__nearSphere'] = JSON.stringify(geo);
            query['maxDistance'] = 500;
            var start = $('.start').val().replace('Start Date: ', '');
            var end = $('.end').val().replace('End Date: ', '');
            start = moment(start)
            end = moment(end)
            start = start.startOf('day').unix();
            end = end.endOf('day').unix();
            query['date__lte'] = end;
            query['date__gte'] = start;
            $.when(get_results(query)).then(
                function(resp){
                    add_resp_to_map(query, resp);
                    if (crimes.getLayers().length > 0){
                        map.fitBounds(crimes.getBounds());
                    }
                }
            )
        }
    });
    $(document).ready(function(){
        $('.full-height').height(window.innerHeight - 45);
        window.onresize = function(event){
            resize_junk();
        }
        map = L.mapbox.map('map', 'ericvanzanten.map-7b7muw9h', {attributionControl: false})
            .fitBounds([[41.644286009999995, -87.94010087999999], [42.023134979999995, -87.52366115999999]]);
        map.addLayer(drawnItems);
        var drawControl = new L.Control.Draw({
            edit: {
                    featureGroup: drawnItems
            },
            draw: {
                polyline: false,
                circle: false,
                marker: false
            }
        });
        drawControl.setPosition('topright')
        map.addControl(drawControl);
        map.on('draw:created', draw_create);
        map.on('draw:edited', draw_edit);<commit_msg>switched base map account to datamade<commit_after>(function(){
    var drawnItems = new L.FeatureGroup();
    var crimes = new L.FeatureGroup();
    var beats = new L.FeatureGroup();
    var map;
    var meta = L.control({position: 'bottomright'});
    var meta_data;
    meta.onAdd = function(map){
        this._div = L.DomUtil.create('div', 'meta');
        return this._div;
    }
    meta.update = function(meta_data){
        if(typeof meta_data !== 'undefined'){
            var tpl = new EJS({url: 'js/views/metaTemplate.ejs?2'});
            $(this._div).html(tpl.render(meta_data.totals_by_type));
        } else {
            $(this._div).empty();
            meta.removeFrom(map);
        }
    }
    //var endpoint = 'http://localhost:7777';
    var endpoint = 'http://crime-weather.smartchicagoapps.org';
    var AddressSearch = L.Control.extend({
        options: {
            position: 'topleft',
            keepOpen: false,
        },
        _toggle: function(e) {
            if (e) L.DomEvent.stop(e);
            if (L.DomUtil.hasClass(this._container, 'active')) {
                L.DomUtil.removeClass(this._container, 'active');
                this._results.innerHTML = '';
                this._input.blur();
            } else {
                L.DomUtil.addClass(this._container, 'active');
                this._input.focus();
                this._input.select();
            }
        },
        _closeIfOpen: function(e) {
            if (L.DomUtil.hasClass(this._container, 'active') &&
                !this.options.keepOpen) {
                L.DomUtil.removeClass(this._container, 'active');
                this._results.innerHTML = '';
                this._input.blur();
            }
        },
        onAdd: function(map) {
            var container = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder leaflet-bar leaflet-control'),
                link = L.DomUtil.create('a', 'leaflet-control-mapbox-geocoder-toggle mapbox-icon mapbox-icon-geocoder', container),
                results = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder-results', container),
                wrap = L.DomUtil.create('div', 'leaflet-control-mapbox-geocoder-wrap', container),
                form = L.DomUtil.create('form', 'leaflet-control-mapbox-geocoder-form', wrap),
                input  = L.DomUtil.create('input', '', form);

            link.href = '#';
            link.innerHTML = '&nbsp;';

            input.type = 'text';
            input.setAttribute('placeholder', 'Search');

            L.DomEvent.addListener(form, 'submit', this._geocode, this);
            L.DomEvent.disableClickPropagation(container);

            this._map = map;
            this._input = input;
            this._form = form;
            this._results = results;

            if (this.options.keepOpen) {
                L.DomUtil.addClass(container, 'active');
            } else {
                this._map.on('click', this._closeIfOpen, this);
                L.DomEvent.addListener(link, 'click', this._toggle, this);
            }
            return container;
        },
        _geocode: function(e){
            L.DomEvent.preventDefault(e);
            L.DomUtil.addClass(this._container, 'searching');
            var map = this._map;
            var container = this._container;
            var results = this._results;
            var self = this;
            var onload = L.bind(function(resp, err){
                L.DomUtil.removeClass(container, 'searching');
                results.innerHTML = '';
                var locations = resp.results[0].locations;
                if (locations.length === 1){
                    var latlng = [locations[0].latLng.lat, locations[0].latLng.lng];
                    map.setView(latlng, 17);
                    var mark = L.marker(latlng)
                    mark.addTo(map);
                    //self._fetch_near(mark); //Add in the $near query
                } else {
                    for (var i = 0, l = Math.min(locations.length, 5); i < l; i++) {
                        var name = [];
                        if (locations[i].street) name.push(locations[i].street);
                        if (!name.length) continue;

                        var r = L.DomUtil.create('a', '', this._results);
                        r.innerHTML = name.join(', ');
                        r.href = '#';

                        (L.bind(function(result) {
                            L.DomEvent.addListener(r, 'click', function(e) {
                                var lat = result.latLng.lat;
                                var lng = result.latLng.lng;
                                map.setView(L.latLng(lat, lng), 16);
                                var mark = L.marker([lat,lng]);
                                mark.addTo(map);
                                L.DomEvent.stop(e);
                                self._toggle();
                                //self._fetch_near(mark);
                                // add in the $near query
                            }, this);
                        }, this))(locations[i]);
                    }
                    if (resp.results.length > 5) {
                        var outof = L.DomUtil.create('span', '', this._results);
                        outof.innerHTML = 'Top 5 of ' + locations.length + '  results';
                    }
                }
            }, this);
            var query = this._input.value + ' Chicago, IL';
            var bbox = "42.023134979999995,-87.52366115999999,41.644286009999995,-87.94010087999999";
            var params = {
                key: '<KEY>',
                location: query,
                boundingBox: bbox
            }
            $.ajax({
                url:'http://open.mapquestapi.com/geocoding/v1/address',
                data: params,
                dataType: 'jsonp',
                success: onload
            });
        },
        _fetch_near: function(point){
            var geo = point.toGeoJSON()['geometry'];
            var query = {};
            query['location__nearSphere'] = JSON.stringify(geo);
            query['maxDistance'] = 500;
            var start = $('.start').val().replace('Start Date: ', '');
            var end = $('.end').val().replace('End Date: ', '');
            start = moment(start)
            end = moment(end)
            start = start.startOf('day').unix();
            end = end.endOf('day').unix();
            query['date__lte'] = end;
            query['date__gte'] = start;
            $.when(get_results(query)).then(
                function(resp){
                    add_resp_to_map(query, resp);
                    if (crimes.getLayers().length > 0){
                        map.fitBounds(crimes.getBounds());
                    }
                }
            )
        }
    });
    $(document).ready(function(){
        $('.full-height').height(window.innerHeight - 45);
        window.onresize = function(event){
            resize_junk();
        }
        map = L.mapbox.map('map', 'datamade.hnmob3j3', {attributionControl: false})
            .fitBounds([[41.644286009999995, -87.94010087999999], [42.023134979999995, -87.52366115999999]]);
        map.addLayer(drawnItems);
        var drawControl = new L.Control.Draw({
            edit: {
                    featureGroup: drawnItems
            },
            draw: {
                polyline: false,
                circle: false,
                marker: false
            }
        });
        drawControl.setPosition('topright')
        map.addControl(drawControl);
        map.on('draw:created', draw_create);
        map.on('draw:edited', draw_edit);
{'fraction_non_alphanumeric': 0.135869918699187, 'fraction_numerical': 0.02061788617886179, 'mean_word_length': 1.3901756567697807, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4058220', 'n_tokens_mistral': 4513, 'n_tokens_neox': 4121, 'n_words': 720}