<commit_before>
var lat=48.2;
var lon=16.35;
var zoom=12;

var map;
var select;

function get_icon(feature, mapping){
	if (feature.data.tags[mapping['key']]) {
		if (mapping['value']) {
			for (var i=0; i<feature.data.tags[mapping['key']].length; i++) {
				if (feature.data.tags[mapping['key']][i] == mapping['value']) {
	                return {icon: mapping['icon'], tag: mapping['key'] + ' = ' + mapping['value']};
				}
			}
		}
		else {
            return {icon: mapping['icon'], tag: mapping['key'] + ' = *'};
		}
	}  
	return null;
}

function get_icons(feature) {
	var icons = [];
	var first_is_subicon = false;
	for (var i=0; i<icon_mappings.length; i++) {
	    var mapping = icon_mappings[i];
	    if (icons.length == 0) {
	    	// if we find the first icon, remeber if it should be a subicon
	    	first_is_subicon = mapping['subicon_only'];
	    }
	    if (feature.cluster) {
	        for (var j=0; j<feature.cluster.length; j++) {
	            var icon = get_icon(feature.cluster[j], mapping)
	            if (icon) {
	                icons.push(icon);
	                break;
	            }
	        }
	    }
	    else {
	        var icon = get_icon(feature, mapping)
	        if (icon) {
	            icons.push(icon);
	        }
	    }
	}
	if (first_is_subicon || icons.length == 0) {
		icons.splice(0, 0, {icon: DEFAULT_ICON});
	}
	return icons;
}

OpenLayers.Layer.MapsWithoutBorders = OpenLayers.Class(OpenLayers.Layer.OSM, {
    /**
     * Constructor: OpenLayers.Layer.MapsWithoutBorders
     *
     * Parameters:
     * name - {String}
     * options - {Object} Hashtable of extra options to tag onto the layer
     */
    initialize: function(name, options) {
        options = OpenLayers.Util.extend({
            numZoomLevels: 19,
            buffer: 0,
            transitionEffect: "resize",
            base_url: 'http://tiles.mapswithoutborders.eu/',
            style: 'default'
        }, options);
        this.noborders_urls = [
            options.base_url + options.style + "/${z}/${x}/${y}.png"
        ];
        this.osm_urls = [
            "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
            "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
            "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
        ];
        this.noborders_max_zoom = 6;
        var newArguments = [name, this.osm_urls, options];
        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);

        this.attribution = 'Maps &amp; Data by <a href="http://www.naturalearthdata.com/" target="_blank">Natural Earth</a>, CC-by-SA <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>, <a href="http://www.mapswithoutborders.eu/" target="_blank">Mapswithoutborders.eu</a>';
    },

    getURL: function (bounds) {
        var res = this.map.getResolution();
        var xyz = {};
        xyz.x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        xyz.y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
        xyz.z = this.map.getZoom() + this.zoomOffset;

        // trunk
        //var xyz = this.getXYZ(bounds);

        var url = this.noborders_urls[0];
        if (xyz.z > this.noborders_max_zoom) {
            url = this.osm_urls;
            if (url instanceof Array) {
                var s = '' + xyz.x + xyz.y + xyz.z;
                url = this.selectUrl(s, url);
            }
        }
        
        return OpenLayers.String.format(url, xyz);
    },

    CLASS_NAME: "OpenLayers.Layer.MapsWithoutBorders"
});<commit_msg>dynamic attribution for mwob layer<commit_after>
var lat=48.2;
var lon=16.35;
var zoom=12;

var map;
var select;

function get_icon(feature, mapping){
	if (feature.data.tags[mapping['key']]) {
		if (mapping['value']) {
			for (var i=0; i<feature.data.tags[mapping['key']].length; i++) {
				if (feature.data.tags[mapping['key']][i] == mapping['value']) {
	                return {icon: mapping['icon'], tag: mapping['key'] + ' = ' + mapping['value']};
				}
			}
		}
		else {
            return {icon: mapping['icon'], tag: mapping['key'] + ' = *'};
		}
	}  
	return null;
}

function get_icons(feature) {
	var icons = [];
	var first_is_subicon = false;
	for (var i=0; i<icon_mappings.length; i++) {
	    var mapping = icon_mappings[i];
	    if (icons.length == 0) {
	    	// if we find the first icon, remeber if it should be a subicon
	    	first_is_subicon = mapping['subicon_only'];
	    }
	    if (feature.cluster) {
	        for (var j=0; j<feature.cluster.length; j++) {
	            var icon = get_icon(feature.cluster[j], mapping)
	            if (icon) {
	                icons.push(icon);
	                break;
	            }
	        }
	    }
	    else {
	        var icon = get_icon(feature, mapping)
	        if (icon) {
	            icons.push(icon);
	        }
	    }
	}
	if (first_is_subicon || icons.length == 0) {
		icons.splice(0, 0, {icon: DEFAULT_ICON});
	}
	return icons;
}

OpenLayers.Layer.MapsWithoutBorders = OpenLayers.Class(OpenLayers.Layer.OSM, {
    /**
     * Constructor: OpenLayers.Layer.MapsWithoutBorders
     *
     * Parameters:
     * name - {String}
     * options - {Object} Hashtable of extra options to tag onto the layer
     */
    initialize: function(name, options) {
        options = OpenLayers.Util.extend({
            numZoomLevels: 19,
            buffer: 0,
            transitionEffect: "resize",
            base_url: 'http://tiles.mapswithoutborders.eu/',
            style: 'default'
        }, options);
        this.noborders_urls = [
            options.base_url + options.style + "/${z}/${x}/${y}.png"
        ];
        this.osm_urls = [
            "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
            "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
            "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
        ];
        this.noborders_max_zoom = 6;
        var newArguments = [name, this.osm_urls, options];
        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);

        this.mwob_attribution = 'Map CC-by-SA <a href="http://www.mapswithoutborders.eu/" target="_blank">Mapswithoutborders.eu</a>, Data by <a href="http://www.naturalearthdata.com/" target="_blank">Natural Earth</a> &amp; CC-by-SA <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>';
        this.osm_attribution = 'Map Data CC-by-SA <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>';
        this.attribution = this.mwob_attribution;
    
        this.events.register("moveend",this,function(event){
            if (event.zoomChanged && this.map) {
                //alert("zoom changed");
                if (this.map.getZoom() > this.noborders_max_zoom) {
                    this.attribution = this.osm_attribution;
                }
                else {
                    this.attribution = this.mwob_attribution;
                }
                this.map.events.triggerEvent('changelayer',{property:'attribution'});
            }
        });

    },

    getURL: function (bounds) {
        var res = this.map.getResolution();
        var xyz = {};
        xyz.x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        xyz.y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
        xyz.z = this.map.getZoom() + this.zoomOffset;

        // trunk
        //var xyz = this.getXYZ(bounds);

        var url = this.noborders_urls[0];
        if (xyz.z > this.noborders_max_zoom) {
            url = this.osm_urls;
            if (url instanceof Array) {
                var s = '' + xyz.x + xyz.y + xyz.z;
                url = this.selectUrl(s, url);
            }
        }
        
        return OpenLayers.String.format(url, xyz);
    },

    CLASS_NAME: "OpenLayers.Layer.MapsWithoutBorders"
});
{'fraction_non_alphanumeric': 0.16154041687849516, 'fraction_numerical': 0.005338078291814947, 'mean_word_length': 2.1053670086819256, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 7, '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': '7194878', 'n_tokens_mistral': 2794, 'n_tokens_neox': 2595, 'n_words': 475}