User:Darthmelak/common.js

jQuery(function ($) {	console.log('stuff running')   var regex = /^.*\s?lat\s+(\d+\.?\d{0,2}),\s+lon\s+(\d+\.?\d{0,2})\s?.*$/m    const addElement = function  {		if ($(this).children.length > 0) {			return;		}		var dash = this.title.indexOf('-')		var text = this.title.substr(0, dash != -1 ? dash : undefined)		if (dash == -1) {			console.log(this.title)			var m = regex.exec(this.title)			console.log(m)			if (m) {				text = m[1] + ' ' + m[2]			}		}       var $el = $(' ').css({ position: 'absolute', backgroundColor: 'rgba(0, 0, 0, .6)', color: '#ffffff', fontSize: '9px', lineHeight: 1, padding: '1px', marginTop: '10px', whiteSpace: 'nowrap', transform: 'translateX(-40%)', textAlign: 'center', }).text(text)		$el.prependTo(this)   }

$('[style*="relative"] [style*="absolute"], .map-container .dot, .map-container .dots > *').each(addElement) var $mapContainer = $('.map-container') if ($mapContainer.length) { var debounceTimeout = undefined var observer = new MutationObserver(function {	    	if (debounceTimeout) { clearTimeout(debounceTimeout) }	    	debounceTimeout = setTimeout(function  { $mapContainer.find('.dot').each(addElement) $mapContainer.find('.dots > *').each(addElement) debounceTimeout = undefined }, 400)	   })	    observer.observe($mapContainer.get(0), {childList: true, subtree: true}) } });