<commit_before>// app.MapPane.baselayerToggle
L.Control.Baselayertoggle = M.Control.extend({

	type : 'baselayertoggle',

	options: {
		collapsed: true,
		position: 'topleft',
		autoZIndex: true
	},

	onAdd: function () {
		// create div
		var className = 'leaflet-control-baselayertoggle';
		var container = this._container = L.DomUtil.create('div', className);
		return container;
	},

	_addHooks : function () {
		// add events
		M.DomEvent.on(this._container, 'mousedown', this.toggle, this);
		M.DomEvent.on(this._container, 'dblclick', M.DomEvent.stop, this);
		M.DomEvent.on(this._container, 'mouseleave', this.mouseOut, this);

		// add stops
		M.DomEvent.on(this._container, 'mousedown dblclick mouseup click', M.DomEvent.stopPropagation, this);
	},

	addTo: function (map) {

		this._map = map;

		var container = this._container = this.onAdd(map),
		    pos = this.getPosition(),
		    corner = map._controlCorners[pos];

		L.DomUtil.addClass(container, 'leaflet-control');

		// add to dom
		corner.appendChild(container);

		return this;
	},

	_on : function () {
		this._show();
	},
	_off : function () {
		this._hide();
	},
	_show : function () {
		this._container.style.display = 'block';
		this._refresh();
	},
	_hide : function () {
		this._container.style.display = 'none';
	},

	_addTo : function () {
		this.addTo(app._map);
		this._addHooks();
		this._added = true;
	},

	_refresh : function () {
		if (!this._added) this._addTo();

		// get control active setting from project
		var active = this._project.getControls()[this.type];
		
		// if not active in project, hide
		if (!active) return this._hide();

		// remove old content
		this._flush();

		// init content
		this._initContent();

	},

	_flush : function () {
		// empty old
		if (this._list) {
			M.DomUtil.remove(this._list);
			this._list = null;
		}

		this._layers = null;
		this._layers = {};

	},

	_initContent : function () {
		
		// create wrapper
		this._list = L.DomUtil.create('div', 'baselayertoggle-list', this._container);
		M.DomEvent.on(this._list, 'dblclick', M.DomEvent.stop, this);

		// build menu
		var baseLayers = this._getBaselayers();

		baseLayers.forEach(function (b) {
			var baseLayer = {
				layer : this._project.getLayer(b.uuid),
				baseLayer : b
			};
			this.addLayer(baseLayer);
		}, this);

		// Add blank baselayer (NONE)
		this.addBlankLayer();

	},

	_getBaselayers : function () {
		var layers = this._project.getLayers();
		var filtered = this._filterBackgroundLayersByProvider(layers);
		var formatted = this._formatBackgroundLayersObject(filtered);
		return formatted;
	},

	_formatBackgroundLayersObject : function (layers) {
		var result = [];
		layers.forEach(function (l, n) {
			result.push({
				uuid : l.getUuid(),
				zIndex : n+1,
				opacity : 1
			});
		}, this);
		return result;
	},

	_filterBackgroundLayersByProvider : function (layers) {
		var keys = ['google', 'norkart', 'mapbox'];
		var results = [];
		keys.forEach(function (key) {<commit_msg>remove google layer<commit_after>// app.MapPane.baselayerToggle
L.Control.Baselayertoggle = M.Control.extend({

	type : 'baselayertoggle',

	options: {
		collapsed: true,
		position: 'topleft',
		autoZIndex: true
	},

	onAdd: function () {
		// create div
		var className = 'leaflet-control-baselayertoggle';
		var container = this._container = L.DomUtil.create('div', className);
		return container;
	},

	_addHooks : function () {
		// add events
		M.DomEvent.on(this._container, 'mousedown', this.toggle, this);
		M.DomEvent.on(this._container, 'dblclick', M.DomEvent.stop, this);
		M.DomEvent.on(this._container, 'mouseleave', this.mouseOut, this);

		// add stops
		M.DomEvent.on(this._container, 'mousedown dblclick mouseup click', M.DomEvent.stopPropagation, this);
	},

	addTo: function (map) {

		this._map = map;

		var container = this._container = this.onAdd(map),
		    pos = this.getPosition(),
		    corner = map._controlCorners[pos];

		L.DomUtil.addClass(container, 'leaflet-control');

		// add to dom
		corner.appendChild(container);

		return this;
	},

	_on : function () {
		this._show();
	},
	_off : function () {
		this._hide();
	},
	_show : function () {
		this._container.style.display = 'block';
		this._refresh();
	},
	_hide : function () {
		this._container.style.display = 'none';
	},

	_addTo : function () {
		this.addTo(app._map);
		this._addHooks();
		this._added = true;
	},

	_refresh : function () {
		if (!this._added) this._addTo();

		// get control active setting from project
		var active = this._project.getControls()[this.type];
		
		// if not active in project, hide
		if (!active) return this._hide();

		// remove old content
		this._flush();

		// init content
		this._initContent();

	},

	_flush : function () {
		// empty old
		if (this._list) {
			M.DomUtil.remove(this._list);
			this._list = null;
		}

		this._layers = null;
		this._layers = {};

	},

	_initContent : function () {
		
		// create wrapper
		this._list = L.DomUtil.create('div', 'baselayertoggle-list', this._container);
		M.DomEvent.on(this._list, 'dblclick', M.DomEvent.stop, this);

		// build menu
		var baseLayers = this._getBaselayers();

		baseLayers.forEach(function (b) {
			var baseLayer = {
				layer : this._project.getLayer(b.uuid),
				baseLayer : b
			};
			this.addLayer(baseLayer);
		}, this);

		// Add blank baselayer (NONE)
		this.addBlankLayer();

	},

	_getBaselayers : function () {
		var layers = this._project.getLayers();
		var filtered = this._filterBackgroundLayersByProvider(layers);
		var formatted = this._formatBackgroundLayersObject(filtered);
		return formatted;
	},

	_formatBackgroundLayersObject : function (layers) {
		var result = [];
		layers.forEach(function (l, n) {
			result.push({
				uuid : l.getUuid(),
				zIndex : n+1,
				opacity : 1
			});
		}, this);
		return result;
	},

	_filterBackgroundLayersByProvider : function (layers) {
		// var keys = ['google', 'norkart', 'mapbox'];
		var keys = ['norkart', 'mapbox'];
		var results = [];
		keys.forEach(function (key) {
{'fraction_non_alphanumeric': 0.15503233294644336, 'fraction_numerical': 0.000663239927043608, 'mean_word_length': 3.419047619047619, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3422041', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2035, 'n_words': 430}