MediaWiki:Gadget-Links.js

De WikiEducator
Saltar a: navegación, buscar

Nota: después de guardar, quizás necesites refrescar la caché de tu navegador para ver los cambios.

  • Firefox / Safari: Mantén presionada Mayús mientras pulsas el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presiona Ctrl+Shift+R (⌘+Mayús+R en Mac)
  • Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar, o presiona Ctrl+F5
  • Opera: vacía la caché en Herramientas → Preferencias
/* add Links button with permanent link, short link, and iframe snippets for each
 * 2010-12-21 http://WikiEducator.org/User:JimTittsler
 * short links derived from [[commons:Bugzilla:021572]] -- [[commons:meta:user:Platonides]]
 */
 
$( function() {
	var plink = document.getElementById("t-permalink");
 
	if (wgArticleId && plink) {
		var permanent_link = wgScript + '?oldid=' + wgCurRevisionId;
		var short_url = wgScript + '?curid=' + wgArticleId;
		var height = document.getElementById('content').offsetHeight;
		plink.innerHTML = ['<a href="#" title="Permanent and short URLs, IFrame snippets for this page" onClick="var weLinks=document.getElementById(\'weLinks\'); if (weLinks.style.display == \'none\') { weLinks.style.display = \'block\'; weSelectMe(document.getElementById(\'we_page_iframe\'));} else { weLinks.style.display = \'none\'; } return false;">Links</a>'
			, '<ul id="weLinks" style="display:none;">'
			, '<li><a href="' + permanent_link + '" title="Permanent link to this revision">Permanent Link</a></li>'
			, '<li>IFrame snippet to this revision:<br>'
			, '<span class="weLinkSelect">&lt;iframe src="' + wgServer + permanent_link + '" width="100%" height="'
			, height
			, '"&gt;WikiEducator &lt;/iframe&gt;</span></li>'
			, '<li><a href="' + short_url + '" title="Reference page by article id">Short URL</a></li>'
			, '<li>IFrame snippet to this page:<br>'
			, '<span id="we_page_iframe" class="weLinkSelect">&lt;iframe src="' + wgServer + short_url + '" width="100%" height="'
			, height
			, '"&gt;WikiEducator &lt;/iframe&gt;</span></li>'
			, '</ul>'
		].join('');
		// copy to clipboard on click
		$('.weLinkSelect').click(function() {
			var node = $(this)[0];
			var selection, range, doc, win;
			if ((doc = node.ownerDocument) && (win=doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') {
				range = doc.createRange();
				range.selectNode(node);
				selection.removeAllRanges();
				selection.addRange(range);
			} else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())) { /* IE */
				range.moveToElementText(node);
				range.select();
			}
		});
	}
} );