MediaWiki:Gadget-AltresViccionari.js
Nota: Després de desar, heu de netejar la memòria cau del navegador per veure els canvis. En la majoria de navegadors amb Windows o Linux, premeu Ctrl+F5 o bé premeu Shift i cliqueu el botó "Actualitza" (Ctrl i "Actualitza" amb Internet Explorer). Vegeu més informació i instruccions per a cada navegador a Viquipèdia:Neteja de la memòria cau.
/**
* Afegeix Viccionari en la secció "En altres projectes" de la barra lateral
*
* Versió inicial de w:es:Mediawiki:Common.js, molt modificada. Relacionat: wikt:en:MediaWiki:Gadget-AggregateInterprojectLinks.js
*
* A eliminar quan els enllaços estiguin disponibles a Wikidata com els altres projectes germans
*/
var iProject = function ($) {
var elementos = document.getElementsByClassName("interProject");
if (elementos.length > 0) {
if (document.getElementById('p-wikibase-otherprojects')) {
var target = elementos[0].getElementsByTagName('a')[0].href;
mw.util.addPortletLink('p-wikibase-otherprojects', target, 'Viccionari');
}
else {
mw.util.addCSS('#interProject {display: none; speak: none;} #p-tb .pBody {padding-right: 0;}');
var portal = document.createElement('nav');
portal.setAttribute("id", "p-wikibase-otherprojects");
portal.setAttribute("class", "mw-portlet mw-portlet-wikibase-otherprojects vector-menu vector-menu-portal portal");
portal.setAttribute("aria-labelledby", "p-wikibase-otherprojects-label");
var tit = document.createElement('label');
tit.setAttribute("id", "p-wikibase-otherprojects-label");
tit.setAttribute("class", "vector-menu-heading");
tit.setAttribute("aria-label", "");
tit.setAttribute("aria-hidden", "true");
var titlabel = document.createElement('span');
titlabel.setAttribute('class', "vector-menu-heading-label");
titlabel.setAttribute("lang", "ca");
titlabel.appendChild(document.createTextNode('En altres projectes'));
tit.appendChild(titlabel);
portal.appendChild(tit);
var IPY = document.createElement('div');
IPY.setAttribute('class', "pBody body vector-menu-content");
var ul = document.createElement('ul');
ul.setAttribute('class', "vector-menu-content-list");
IPY.appendChild(ul);
var li = document.createElement('li');
li.setAttribute('class', "wb-otherproject-link wb-otherproject-wiktionary mw-list-item");
li.innerHTML = elementos[0].innerHTML;
ul.appendChild(li);
portal.appendChild(IPY);
var printExport = document.getElementById("p-coll-print_export");
if (printExport && printExport.nextSibling) {
printExport.parentNode.insertBefore(portal, document.getElementById("p-coll-print_export").nextSibling);
} else if (printExport){
printExport.parentNode.appendChild(portal);
}
}
}
};
$(document).ready(iProject);