Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

MediaWiki:Mobile.js

Aus imedwiki
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Gehe zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* Das JavaScript hier wird für die Benutzer der mobilen Website geladen. */
if($("#log")){$("#log").append("<p>Javascript begin</p>")}

$(document).on("ready", function(e){
/* this structure is assumed (as provided by Vorlage:AufKarteZeigen):
<span class=".Kartenlink"><a href="URL#divId">LINKTEXT</a><span class="coords"><span class="coordvalues">lat,long</span></span></span>
The map has to be enclosed by a div with id divId. It works as link target on page and to identify the map.
*/

if($("#log")){$("#log").append("<p>append links</p>")}

$(".Kartenlink a").on('click', function() {
	divId = $(this).attr("href").split('#').pop(); 
	if($("#log")){$("#log").append("<p>"+divId+"</p>")}
	for (var i = 0; i < mapsLeafletList.length; i++) {
      if ($(mapsLeafletList[i][0]).parents("#"+divId).length) {
      	coords = $(this).parent().find("span.coordvalues").html();
      	var latLng=L.latLng(coords.split(","));
      	mapsLeafletList[i].map.flyTo(latLng, 16);
      }
    } 
});
});

/* dealing with interwikilinks */

var interwikiSuffixes = Array();

/* this function returns all interwikilinks 
return jQuery results */
function getAllInterwikiLinks() {
	interwikilinks = $("#content a.extiw");
	return interwikilinks;
}

/* return destination of interwikilink

extract information from link title (i.e. "wikipedia:Hauptseite"). 
Title gets split by : and the first part is returned */
function getInterwikiDest(link) {
	return link.title.split(":")[0];
}

function getInterwikiLinkSuffix(interwiki) {
	if (interwiki in interwikiSuffixes) return interwikiSuffixes[interwiki];
	
	textObject = JSON.parse(
    	$.ajax({
        	url:mw.util.wikiScript('api'),
        	data: { action: 'parse', text: '{{Vorlage:InterwikilinkWikipedia}}', format: 'json', contentmodel: 'wikitext'},
        	async:false
    	}).responseText
    );
    text = textObject.parse.text["*"];
    $suffix = $(text).find("p").html();
    
    if (!(interwiki in interwikiSuffixes)) interwikiSuffixes[interwiki] = $suffix;
    
    return $suffix;
}

/* append suffix to interwikilink */
function appendInterwikiLinkSuffix(link){
	dest = getInterwikiDest(link);
	interwikiLinkSuffix =getInterwikiLinkSuffix(dest);
	link.innerHTML += interwikiLinkSuffix;
}

/* allInterwikiLinksAppendSuffix 

append link suffix to all interwikilinks on page in content area */
function allInterwikiLinksAppendSuffix() {
	interwikiLinks = getAllInterwikiLinks();
	for (var i = 0; i < interwikiLinks.length; i++) {
		interwikiLink = interwikiLinks[i];
		appendInterwikiLinkSuffix(interwikiLink);
	}
}

allInterwikiLinksAppendSuffix();

if($("#log")){$("#log").append("<p>Javascript end</p>")}