Langbahn Team – Weltmeisterschaft

MediaWiki talk:GeoHack.js: Difference between revisions

Content deleted Content added
Para (talk | contribs)
Service shuffler: drags and drops now
HTTPS fix: new section
Line 83: Line 83:
:I've thought about this and to me its too much effort for something that will disappear if you clear your cookies or move to another computer. It might be easier if it were drag and drop. Another possibility is to simply list the last five links a user click on at the top of the page. — [[User:Dispenser|Dispenser]] 16:38, 20 October 2009 (UTC)
:I've thought about this and to me its too much effort for something that will disappear if you clear your cookies or move to another computer. It might be easier if it were drag and drop. Another possibility is to simply list the last five links a user click on at the top of the page. — [[User:Dispenser|Dispenser]] 16:38, 20 October 2009 (UTC)
::True, moving anything one by one on a 30 row list is a pain. So I searched for some drag&drop code, and merged it with mine at [[tools:~para/temp/GeoHack-dragdrop.html]]. Seems to work. Moving rows without the user explicitly making the move would confuse people when they're looking for services from the alphabetical list, I think. Copying often used rows and changing the style might be better. This row moving thing could use some styling magic as well, especially if the popularity of services is going to be indicated with background colours. --[[User:Para|Para]] ([[User talk:Para|talk]]) 22:34, 21 October 2009 (UTC)
::True, moving anything one by one on a 30 row list is a pain. So I searched for some drag&drop code, and merged it with mine at [[tools:~para/temp/GeoHack-dragdrop.html]]. Seems to work. Moving rows without the user explicitly making the move would confuse people when they're looking for services from the alphabetical list, I think. Copying often used rows and changing the style might be better. This row moving thing could use some styling magic as well, especially if the popularity of services is going to be indicated with background colours. --[[User:Para|Para]] ([[User talk:Para|talk]]) 22:34, 21 October 2009 (UTC)

== HTTPS fix ==

Per [http://lists.wikimedia.org/pipermail/wikitech-l/2013-August/thread.html#71571], I've [https://en.wikipedia.org/w/index.php?title=MediaWiki:GeoHack.js&diff=570816286&oldid=352072410 replaced the hardcoded HTTP toolserver URLs] with protocol-relative ones, fixing the mixed-content block in Firefox 23+. --[[User:Brion VIBBER|brion]] ([[User talk:Brion VIBBER|talk]]) 14:41, 30 August 2013 (UTC)

Revision as of 14:41, 30 August 2013

Let get the ball rolling

{{editprotected}} Please create this pages with the following content:

/* 
 * The file is used by [[tswiki:GeoHack]] and applies effects to [[Template:GeoTemplate]].
 */

/* basic function library */
function appendCSS(text) {
	var s = document.createElement('style');
	s.type = 'text/css';
	s.rel = 'stylesheet';
	if (s.styleSheet) s.styleSheet.cssText = text //IE
	else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
	document.getElementsByTagName('head')[0].appendChild(s);
}
window.onload = function() {
	/* Add row hover effect */
	appendCSS(".directory tr:hover {background:#fdc !important;}")
}

Dispenser 14:08, 20 July 2009 (UTC)[reply]

 Not done First, i'd like to see some links to relevant discussion as to why this should be HERE, and second, we have ways to do this. It's called appendCSS() and addOnloadHook(). —TheDJ (talk • contribs) 09:57, 21 July 2009 (UTC)[reply]
I am one of the maintainers of GeoHack. This is part of the separation of general layout. The MediaWiki namespace is best for tools to store executed JavaScript. Finally, a simple script like this is a good introduction to the possible uses before we start adding the clicktracking or WMA. — Dispenser 13:39, 21 July 2009 (UTC)[reply]
I have modified the above code to implement appendCSS() since it not available from GeoHack and call it instead. — Dispenser 13:46, 21 July 2009 (UTC)[reply]
OK, i see. The toolserver GeoHack includes this page. But then why not create a GeoHack.css and a GeoHack.js and REALLY separate layout and functionality ? It seems a bit pointless to me to include this CSS with Javascript. —TheDJ (talk • contribs) 10:37, 25 July 2009 (UTC)[reply]
The code is just suppose to be a sample just to get things started. So the CSS is just a hack to show that it does something. If you want to, I'd be find with just the header comment. In the past, Para has developed and hosted a things on his Toolserver account that should be integrated into GeoHack somehow, like that Google street view finder. — Dispenser 22:40, 25 July 2009 (UTC)[reply]

 DoneTheDJ (talk • contribs) 10:14, 26 July 2009 (UTC)[reply]

Clicker tracker

{{editprotected}}

/* Click tracker to see which services are most used */
var tracker = "http://toolserver.org/~dispenser/ghct";
function addTrackers(){
    var anchors = document.getElementById('mw_content').getElementsByTagName('A');
    for(var i=0; anchors[i]!=null; i++){
        anchors[i].onmousedown = function(){if(document.images){(new Image).src=[tracker,'/',(this.textContent||this.innerText||"NA").replace(/\W/g,'').toLowerCase(),'/',this.href.replace(/[\w+]+:\/*([0-9A-Za-z.\-]*).*/,"$1")].join("");return true;};
        }
    }
}
window.onload = function() {
    addTrackers();

Per Template talk:GeoTemplate#Please please please... we would like to have this code added. — Dispenser 02:39, 27 September 2009 (UTC)[reply]

Draggable maps

{{editprotected}}

var iframeurl = 'http://stable.toolserver.org/wma/iframe.html';
var wma_class_R = /\bWMA:(\S+)/;
function addWikiMiniAtlas() {
	var arrElements = document.getElementById('mw_content').getElementsByTagName('DIV');
	var mapparams, container;
	for(var i=0; (container=arrElements[i]); i++){
		mapparams = container.className.match(wma_class_R);
		if(mapparams){
			iframe = document.createElement('iframe');
			iframe.frameBorder = 0;
			iframe.scrolling = 'no';
			iframe.src = iframeurl + '?' + mapparams[1];
			iframe.style.width = mapparams[1].split('_')[2]+'px';
			iframe.style.height = mapparams[1].split('_')[3]+'px';
			while(container.firstChild)
				container.removeChild(container.firstChild);
			container.appendChild(iframe); // set attributes before insertion - IE6
			container.style.display = '';
		}
	}
}
Also add addWikiMiniAtlas(); to the onload function.

This code will replace the contents of div tags with special classes with an instance of WikiMiniAtlas. In the future we can change this to OSM at some point, but the OSM folks are worried about load. — Dispenser 01:34, 28 September 2009 (UTC)[reply]

Service shuffler

So the click tracker works fine (I wouldn't have expected the image url to load when the browser is leaving the page, but it does!). While waiting for some statistics to be published, I had a sneak peek, and it seems people have no trouble finding the Google links that aren't the very first map links. Encouraged by this, I finished the service shuffler script: GeoHack where you choose the service order. The code is at tools:~para/temp/GeoHack-shuffle.js. Should we add this or something like it? --Para (talk) 19:31, 14 October 2009 (UTC)[reply]

I've thought about this and to me its too much effort for something that will disappear if you clear your cookies or move to another computer. It might be easier if it were drag and drop. Another possibility is to simply list the last five links a user click on at the top of the page. — Dispenser 16:38, 20 October 2009 (UTC)[reply]
True, moving anything one by one on a 30 row list is a pain. So I searched for some drag&drop code, and merged it with mine at tools:~para/temp/GeoHack-dragdrop.html. Seems to work. Moving rows without the user explicitly making the move would confuse people when they're looking for services from the alphabetical list, I think. Copying often used rows and changing the style might be better. This row moving thing could use some styling magic as well, especially if the popularity of services is going to be indicated with background colours. --Para (talk) 22:34, 21 October 2009 (UTC)[reply]

HTTPS fix

Per [1], I've replaced the hardcoded HTTP toolserver URLs with protocol-relative ones, fixing the mixed-content block in Firefox 23+. --brion (talk) 14:41, 30 August 2013 (UTC)[reply]