MediaWiki:Common.js : Diferéncia entre lei versions
Aparença
Contengut suprimit Contengut apondut
Requested in Special:Diff/2395574 |
|||
Linha 160 : | Linha 160 : | ||
*/ |
*/ |
||
var autoCollapse = 2; |
var autoCollapse = 2; |
||
var collapseCaption = '[ |
var collapseCaption = '[Enrotlar]'; |
||
var expandCaption = '[ |
var expandCaption = '[Desenrotlar]'; |
||
function collapseTable( tableIndex ) { |
function collapseTable( tableIndex ) { |
Version actuala en data del 5 setembre de 2023 a 17.58
/**
* Un JavaScript que qué siá aicí serà cargat per un utilizaire quin que siá e per cada pagina accedida.
*
* ATENCION : Abans de modificar aquesta pagina, testatz vòstres cambiaments amb vòstre monobook.js
* pròpri. Una error sus aquesta pagina pòt fara bugar lo sit entièr (e geinar l'ensemble dels
* visitors), quitament mantuna ora aprèp la modificacion !
*
* LEVAR PAS AQUÒ SIQUENON : remplaçament de las signaturas, substitucion dels modèls, ... :
* <nowiki> /!\ Levatz pas aquesta balisa
*/
function eregReplace(search, replace, subject) {
return subject.replace(new RegExp(search,'g'), replace);
}
/**
* Transformar las paginas del Tavèrna, del BA e las paginas especificadas en pagina de discussion
*/
function TransformaEnDiscussion() {
if( (mw.config.get('wgPageName').indexOf('Wikipèdia:La_Tavèrna') != -1)
|| (mw.config.get('wgPageName').indexOf('Wikipèdia:Bulletin_dels_administrators') != -1)
|| document.getElementById('transformaEnPaginaDeDiscussion'))
document.body.className = 'ns-talk';
}
$(TransformaEnDiscussion);
/**
* Transformar d'unas paginas en pseudoarticle
*/
function TransformaEnArticle() {
var transformaEnA = document.getElementById("transformaEnArticle");
if(transformaEnA) document.body.className = "ns-0";
}
$(TransformaEnArticle);
/**
* @deprecated Use mw.toolbar instead.
*/
function addCustomButton() {}
/****************************************/
/* Aplicacions per l'ensemble del sit */
/****************************************/
/**
* Tot çò que concernís la pagina d'edicion
* Veire MediaWiki:Common.js/edit.js per aquestas foncions
*/
if( mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit' ) {
importScript( 'MediaWiki:Common.js/edit.js' );
}
/**
* Ligams d'accès dirèctes per la navigacion amb lo clavièr
*/
function showSkipLinks() {
var jump_to_nav = document.getElementById('jump-to-nav');
if( !jump_to_nav ) return;
var skip_links = jump_to_nav.getElementsByTagName('A')[0];
if(skip_links) {
jump_to_nav.className='hidden';
skip_links.onfocus=function() {
jump_to_nav.className='';
};
}
}
$(showSkipLinks);
/**
* Reescritura dels títols
*
* Foncion utilizada per [[Modèl:Títol incorrècte]]
*
* La foncion cèrca un bendèl de la forma
* <div id="RealTitleBanner">
* <span id="RealTitle">títol</span>
* </div>
*
* Un element comportant id="DisableRealTitle" desactiva la foncion
*/
function rewritePageH1() {
var realTitleBanner = document.getElementById('RealTitleBanner');
if (realTitleBanner) {
if (!document.getElementById('DisableRealTitle')) {
var realTitle = document.getElementById('RealTitle');
var h1 = document.getElementsByTagName('h1')[0];
if (realTitle && h1) {
var titleText = realTitle.innerHTML;
if (titleText == '') h1.style.display = 'none';
else h1.innerHTML = titleText;
realTitleBanner.style.display = 'none';
}
}
}
}
$(rewritePageH1);
/**
* Deplaçament de coordenadas qu'apareisson ennaut de la pagina
*/
function moveCoord() {
var h1 = document.getElementsByTagName("h1")[0];
var coord = document.getElementById('coordinates');
if ( !coord || !h1 ) return;
coord.id = "coordinates-title";
h1.insertBefore(coord, h1.firstChild);
}
$(moveCoord);
/**
* Deplaçament dels [modificar]
*
* Correccion dels títols que s'afichan mal en rason de limitacions degudas a MediaWiki.
* Aqueste escript deuriá poder èsser suprimit quand lo [[bugzilla:11555]] serà resolgut (comportament equivalent)
*
* Copyright 2006, Marc Mongenet. Licéncia GPL e GFDL.
*
* The function looks for <span class="editsection">, and move them
* at the end of their parent and display them inline in small font.
* var oldEditseccionLinks=true disables the function.
*/
function setModifySectionStyle()
{
var process = function(list)
{
for(var i=0;i!=list.length;i++)
{
var span=list[i].firstChild;
if (span.className == "editsection")
{
span.style.fontSize = "xx-small";
span.style.fontWeight = "normal";
span.style.cssFloat = span.style.styleFloat = "none";
span.parentNode.appendChild(document.createTextNode(" "));
span.parentNode.appendChild(span);
}
}
};
try
{
if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
process(document.getElementsByTagName("h2"));
process(document.getElementsByTagName("h3"));
process(document.getElementsByTagName("h4"));
process(document.getElementsByTagName("h5"));
process(document.getElementsByTagName("h6"));
}
catch (e) { }
}
$(setModifySectionStyle);
/**
* Boitas desenrotlantas
*
* Per [[Modèl:Metapaleta de navigacion]]
*/
var autoCollapse = 2;
var collapseCaption = '[Enrotlar]';
var expandCaption = '[Desenrotlar]';
function collapseTable( tableIndex ) {
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) return false;
var Rows = Table.getElementsByTagName( "tr" );
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( $(Tables[i]).hasClass("collapsible" ) ) {
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
Button.style.styleFloat = "right";
Button.style.cssFloat = "right";
Button.style.fontWeight = "normal";
Button.style.textAlign = "right";
Button.style.width = "6em";
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( ButtonLink );
var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
/* only add button and increment count if there is a header row to work with */
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
for (var i = 0; i < tableIndex; i++) {
if ( $(NavigationBoxes[i]).hasClass("collapsed" ) || ( tableIndex >= autoCollapse && $(NavigationBoxes[i]).hasClass("autocollapse" ) ) ) collapseTable( i );
}
}
$(createCollapseButtons);
/**
* Per [[Modèl:Boita desenrotlanta]]
*/
var NavigationBarShowDefault = 0;
function toggleNavigationBar(indexNavigationBar) {
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) return;
// suscarga dels libellats desenrotlar/enrotlar gràcia a l'atribut title
// exemple : title="[desenrotlament]/[enrotlament]"
var caption = [expandCaption, collapseCaption];
if (NavFrame.title && NavFrame.title.length > 0) {
caption = NavFrame.title.split("/");
if (caption.length < 2) caption.push(collapseCaption);
}
// if shown now
if (NavToggle.firstChild.data == caption[1]) {
for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ($(NavChild).hasClass('NavPic')) NavChild.style.display = 'none';
if ($(NavChild).hasClass('NavContent')) NavChild.style.display = 'none';
if ($(NavChild).hasClass('NavToggle')) NavChild.firstChild.data = caption[0];
}
// if hidden now
} else if (NavToggle.firstChild.data == caption[0]) {
for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ($(NavChild).hasClass('NavPic')) NavChild.style.display = 'block';
if ($(NavChild).hasClass('NavContent')) NavChild.style.display = 'block';
if ($(NavChild).hasClass('NavToggle')) NavChild.firstChild.data = caption[1];
}
}
}
// adds show/hide-button to navigacion bars
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
// iterate over all < div >-elements
for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) {
// if found a navigacion bar
if ($(NavFrame).hasClass("NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
// suscarga dels libellats desenrotlar/enrotlar gràcia a l'atribut title
var caption = collapseCaption;
if (NavFrame.title && NavFrame.title.indexOf("/") > 0) {
caption = NavFrame.title.split("/")[1];
}
var NavToggleText = document.createTextNode(caption);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in <div class="NavFrame">
NavFrame.insertBefore( NavToggle, NavFrame.firstChild );
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for( var i=1; i<=indexNavigationBar; i++ ) {
toggleNavigationBar(i);
}
}
}
$(createNavigationBarToggleButton);
/**
* WikiMiniAtlas is a popup click and drag world map.
* See [[meta:WikiMiniAtlas]] for more information.
* Maintainers: [[w:User:Dschwen]]
*/
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
var wma_settings = {
buttonImage: '//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Geographylogo.svg/18px-Geographylogo.svg.png'
}
/**
* Utilizacion del modèl Modèl:Imatges
*/
function toggleImage(group, remindex, shwindex) {
document.getElementById("ImageGroupsGr"+group+"Im"+remindex).style.display="none";
document.getElementById("ImageGroupsGr"+group+"Im"+shwindex).style.display="inline";
}
function imageGroup(){
if (document.URL.match(/printable/g)) return;
var bc=document.getElementById("bodyContent");
if( !bc ) bc = document.getElementById("mw_contentholder");
if( !bc ) return;
var divs=bc.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length ; i++) {
if (divs[i].className != "ImageGroup") continue;
UnitNode=undefined;
search=divs[i].getElementsByTagName("div");
for (j = 0; j < search.length ; j++) {
if (search[j].className != "ImageGroupUnits") continue;
UnitNode=search[j];
break;
}
if (UnitNode==undefined) continue;
units=Array();
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (['center', 'mw-halign-center'].some(function(className) { return temp.classList.contains(className); })) { units.push(temp); }
}
var wrap;
for (j = 0 ; j < units.length ; j++) {
currentimage=units[j];
wrap = document.createElement('div');
wrap.id = "ImageGroupsGr" + i + "Im" + j;
currentimage.parentNode.insertBefore(wrap, currentimage);
wrap.appendChild(currentimage);
var imghead = document.createElement("div");
var leftlink;
var rightlink;
if (j != 0) {
leftlink = document.createElement("a");
leftlink.href = "javascript:toggleImage("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="◀";
} else {
leftlink = document.createElement("span");
leftlink.innerHTML=" ";
}
if (j != units.length - 1) {
rightlink = document.createElement("a");
rightlink.href = "javascript:toggleImage("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="▶";
} else {
rightlink = document.createElement("span");
rightlink.innerHTML=" ";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
with(imghead) {
style.fontSize="110%";
style.fontweight="bold";
appendChild(leftlink);
appendChild(comment);
appendChild(rightlink);
}
wrap.insertBefore(imghead,wrap.childNodes[0]);
if (j != 0) wrap.style.display="none";
}
}
}
$(imageGroup);
/**
* Apondon d'un estil particular als ligams interlengas cap a un bon article o
* un article de qualitat
*/
function ligamAdQoBAoPdQ() {
// links are only replaced in p-lang
if(window.disableFeaturedInterwikiLinks!=undefined) return
var pLang = document.getElementById("p-lang");
if (!pLang) return;
var lis = pLang.getElementsByTagName("li");
var l = lis.length
if(mw.config.get('wgNamespaceNumber')==0)
for (var i=0; i<l; i++)
{
// ADQ- es intencional per correspondre al modèl Ligam AdQ, on
// deu pas èsser corregit.
if (document.getElementById("BA-" + lis[i].className)) {
lis[i].className += " BA";
lis[i].title = "Ligam cap a un bon article";
} else if (document.getElementById("ADQ-" + lis[i].className)) {
lis[i].className += " AdQ";
lis[i].title = "Ligam cap a un article de qualitat";
}
}
else if(mw.config.get('wgNamespaceNumber')==100)
for (var i=0; i<l; i++)
{
if (document.getElementById("PdQ-" + lis[i].className)) {
lis[i].className += " AdQ";
lis[i].title = "Ligam cap a un portal de qualitat";
}
}
}
$(ligamAdQoBAoPdQ);
/**
* Deplaça los ligams portals cap a la boita de categoria
*
* Copyright 2007, fr:user:Aoineko. Licéncia GFDL e GPL.
*/
var gUseMovePortalToCategoryBox = 1;
function movePortalToCategoryBox() {
if(!gUseMovePortalToCategoryBox)
return;
// search for portals
var div_portal = document.getElementById('portallinks');
if(div_portal && (div_portal.className == 'movable')) {
div_portal.style.display = 'none'; // hide the portal div
var div_cat = document.getElementById('catlinks'); // get cat div
if(!div_cat) { // no category box ? then create it
var div_foot;
var divs = document.getElementsByTagName('div');
for(var i = 0; i < divs.length ; i++)
if(divs[i].className == 'printfooter')
div_foot = divs[i];
div_cat = document.createElement("div");
div_cat.setAttribute('id', 'catlinks');
div_foot.parentNode.insertBefore(div_cat, div_foot);
}
div_cat.innerHTML = div_portal.innerHTML + '<hr/>' + div_cat.innerHTML;
}
}
$(movePortalToCategoryBox);
/**
* permet d'apondre un pichon ligam (per exemple d'ajuda) a la fin del títol d'una pagina.
* known bug : conflicte amb lo cambiament de títol classic.
* Pels comentaris, mercés de contactar [[user:Plyd|Plyd]].
*/
function rewritePageH1bis() {
try {
var helpPage = document.getElementById("helpPage");
if (helpPage) {
var helpPageURL = document.getElementById("helpPageURL");
var h1 = document.getElementsByTagName("h1")[0];
if (helpPageURL && h1) {
h1.innerHTML = h1.innerHTML + '<span id="h1-helpPage">' + helpPageURL.innerHTML + '</span>';
helpPage.style.display = "none";
}
}
} catch (e) {
/* Something went wrong. */
}
}
$(rewritePageH1bis);
/**
* aplicacion de [[Wikipèdia:Presa de decision/Sistèma d'amagatal]]
* un <span class="noarchive"> a l'entorn del ligam l'empacha d'èsser pres en compte
* per aqueste unicament
* un no_external_cache=true dins un monobook personal desactiva l'escript
*/
$(function () {
if (mw.config.get('wgNamespaceNumber') == 0) {
if ((typeof no_external_cache != "undefined") && (no_external_cache)) return;
addcache();
}
function addcache() {
var external_links;
if (document.getElementsByClassName) {
external_links = document.getElementsByClassName('external');
} else {
external_links = getElementsByClassName(document.getElementById("bodyContent"),'a','external');
}
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1 && chemin.indexOf("wikipedia.org")==-1 && chemin.indexOf("wikimedia.org")==-1 && chemin.indexOf("stable.toolserver.org")==-1)
{
var li = external_links[i].parentNode;
if (li.className == "noarchive") continue;
var depth = 0;
while ((depth < 3) && (li.tagName != "OL") && (li.parentNode != null)) {
li = li.parentNode;
depth++;
}
if (li.tagName != "OL" || !($(li).hasClass('references')) ) continue;
var titre = $(external_links[i]).text();
var last = document.createElement("small");
last.setAttribute("class", "cachelinks");
last.style.color = "#3366BB";
last.appendChild(document.createTextNode("\u00a0["));
$(last).insertAfter(external_links[i]);
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
link.setAttribute("title", "archive de "+ titre);
link.appendChild(document.createTextNode("archive"));
link.style.color = "#3366BB";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
}
);
/**
* Aplicacion de [[Wikipèdia:Presa de decision/Ligam interprojècte]]
* Còpia los ligams interprojèctes del modèl {{Autres projèctes}}
* dins lo menut en colomna d'esquèrra.
* remove_other_projects = true; dins lo monobook personal per activar
* en mai la supression del modèl {{Autres projèctes}} en bas dels articles.
* no_other_projects = true; dins lo monobook personal per desactivar
* entièrament l'escript e l'apondon dins la colomna d'esquèrra.
*/
function autresProjets() {
if ((typeof no_other_projects != "undefined") && (no_other_projects)) return;
if(!(mw.config.get('wgNamespaceNumber')==0)) return;
if(!(mw.config.get('wgAction')=="view")) return;
var div = document.getElementById('autres_projets');
if(!div) return;
var list = div.getElementsByTagName('LI');
var newlist = document.createElement("UL");
for (var i = 0; i < list.length ; i++) {
list.link = list[i].getElementsByTagName('A')[0];
list.text = list.link.getElementsByTagName('SPAN')[0];
var newlistitem = document.createElement("LI");
var newlink = document.createElement("A");
var newlinktext = document.createTextNode($(list.text).text());
newlink.appendChild(newlinktext);
newlink.title=$(list.link).text();
newlink.href=list.link.href;
newlistitem.appendChild(newlink);
newlist.appendChild(newlistitem);
}
var interProject = document.createElement("DIV");
interProject.className = 'portlet';
interProject.innerHTML = '<h5>Autres projets<\/h5><div class="pBody"><ul>'+newlist.innerHTML+'</ul></div>';
$(interProject).insertAfter('#p-tb');
if ((typeof remove_other_projects != "undefined") && (remove_other_projects)) {
document=document.getElementById('bodyContent').removeChild(div);
}
}
$(autresProjets);
/**************************************************************/
/* Estrictament especificas a un espaci de nom o a una pagina */
/**************************************************************/
// ESPACI DE NOM 'ARTICLE'
if( mw.config.get('wgNamespaceNumber') == 0 ) {
} // Fin del còde concernent l'espaci de nom 'Article'
// PAGINA D'ACUÈLH
if( mw.config.get('wgTitle') == 'Acuèlh' ) {
/**
* ligam cap a la lista completa de las Wikipèdias dempuèi l'acuèlh
*/
if(mw.config.get('wgIsMainPage')){
mw.loader.using(['mediawiki.util']).then(function () {
$(function(){
mw.util.addPortletLink('p-lang', '//www.wikipedia.org/', 'Lista completa', 'interwiki-listacompleta', 'Lista completa de las Wikipèdias');
});
});
}
/**
* Amaga quadres de l'acuèlh
*
* Apondís un ligam sus la pagina d'acuèlh per amagar aisidament los quadres
* Memorizat per cookie.
* Copyright 2007, fr:user:Plyd e fr:User:IAlex. Licéncia GFDL e GPL.
*/
var cookieAmagaQuadresName = "amagaQuadresAcuelh";
var AmagaQuadresVal = {};
var totalQuadresAcuelh = 0;
} // Fin del còde concernent la pagina d'acuèlh
// ESPACI DE NOM 'SPECIAL'
if( mw.config.get('wgNamespaceNumber') == -1 ) {
/**
* Afichar una explicacion al nombre d'octets dins la lista de seguit
*/
function toolTipPlusMinus() {
if(mw.config.get('wgCanonicalSpecialPageName') != "Watchlist") return
var tt = "Nombre d'octèts d'escart entre las doas darrièras versions de la pagina";
var elmts = document.getElementsByTagName("span");
for(var cpt = 0; cpt < elmts.length; cpt++) {
if (/mw-plusminus-(pos|neg|null)/.test(elmts[cpt].className) || /mw-plusminus-(pos|neg|null)/.test(elmts[cpt].getAttribute("class")))
elmts[cpt].title = tt;
}
}
$(toolTipPlusMinus);
/**
* Modifica Special:Search per poder utilizar diferents motors de recèrca,
* disponibles dins una boita desenrotlanta.
* Autors : Jakob Voss, Guillaume, importat dempuèi la Wiki alemanda
* <pre><nowiki>
*/
function externalSearchEngines() {
if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return;
if (mw.config.get('wgPageName') != "Especial:Recèrca") return;
var mainNode = document.getElementById("powersearch");
if (!mainNode) mainNode = document.getElementById("search");
if (!mainNode) return;
var beforeNode = document.getElementById("mw-search-top-table");
if (!beforeNode) return;
beforeNode = beforeNode.nextSibling;
if (!beforeNode) return;
var firstEngine = "mediawiki";
var choices = document.createElement("div");
choices.setAttribute("id","searchengineChoices");
choices.style.textAlign = "center";
var lsearchbox = document.getElementById("searchText");
var initValue = lsearchbox.value;
var space = "";
for (var id in searchEngines) {
var engine = searchEngines[id];
if(engine.ShortName)
{
if (space) choices.appendChild(space);
space = document.createTextNode(" ");
var attr = {
type: "radio",
name: "searchengineselect",
value: id,
onFocus: "changeSearchEngine(this.value)",
id: "searchengineRadio-"+id
};
var html = "<input";
for (var a in attr) html += " " + a + "='" + attr[a] + "'";
html += " />";
var span = document.createElement("span");
span.innerHTML = html;
choices.appendChild( span );
var label
if (engine.Template.indexOf('http') == 0) {
label = document.createElement("a");
label.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "fr");
} else {
label = document.createElement("label");
}
label.appendChild( document.createTextNode( engine.ShortName ) );
choices.appendChild( label );
}
}
mainNode.insertBefore(choices, beforeNode);
var input = document.createElement("input");
input.id = "searchengineextraparam";
input.type = "hidden";
mainNode.insertBefore(input, beforeNode);
changeSearchEngine(firstEngine, initValue);
}
function changeSearchEngine(selectedId, searchTerms) {
var currentId = document.getElementById("searchengineChoices").currentChoice;
if (selectedId == currentId) return;
document.getElementById("searchengineChoices").currentChoice = selectedId;
var radio = document.getElementById('searchengineRadio-' + selectedId);
radio.checked = "checked";
var engine = searchEngines[selectedId];
var p = engine.Template.indexOf('?');
var params = engine.Template.substr(p+1);
var form;
if (document.forms["search"]) {
form = document.forms["search"];
} else {
form = document.getElementById("powersearch");
}
form.setAttribute("action", engine.Template.substr(0,p));
var l = ("" + params).split("&");
for (var idx = 0;idx < l.length;idx++) {
var p = l[idx].split("=");
var pValue = p[1];
if (pValue == "{language}") {
} else if (pValue == "{searchTerms}") {
var input;
input = document.getElementById("searchText");
input.name = p[0];
} else {
var input = document.getElementById("searchengineextraparam");
input.name = p[0];
input.value = pValue;
}
}
}
if (mw.config.get('wgPageName') == "Especial:Recèrca") {
var searchEngines = {
mediawiki: {
ShortName: "Recèrca intèrna",
Template: "/w/index.php?search={searchTerms}"
},
exalead: {
ShortName: "Exalead",
Template: "http://www.exalead.com/wikipedia/results?q={searchTerms}&language=oc"
},
google: {
ShortName: "Google",
Template: "http://www.google.oc/search?as_sitesearch=oc.wikipedia.org&hl={language}&q={searchTerms}"
},
wikiwix: {
ShortName: "Wikiwix",
Template: "http://fr.wikiwix.com/index.php?action={searchTerms}&lang={language}"
},
wlive: {
ShortName: "Windows Live",
Template: "http://search.live.com/results.aspx?q={searchTerms}&q1=site:http://oc.wikipedia.org"
},
yahoo: {
ShortName: "Yahoo!",
Template: "http://fr.search.yahoo.com/search?p={searchTerms}&vs=oc.wikipedia.org"
},
globalwpsearch: {
ShortName: "Global WP",
Template: "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=120&search={searchTerms}"
}
};
$(externalSearchEngines);
}
} // Fin del còde que concernisson l'espaci de nom 'Special'
// ESPACI DE NOM 'UTILIZAIRE'
if( mw.config.get('wgNamespaceNumber') == 2 ) {
/* En fasa de tèst */
/* DEBUTA DEL CODE JAVASCRIPT DE "QUADRE D'ONGLETS"
Foncionament del [[Modèl:Quadre d'onglets]]
Modèl implantat per User:Peleguer de http://ca.wikipedia.org
Actualizat per User:Joanjoc de http://ca.wikipedia.org
Traduccion e adaptacion User:Cedric31
*/
function QuadreOngletInit(){
// retorn se endacòm mai que sus l'Espaci d'utilizaire,
// sabent qu'es una orror al nivèl de l'accessibilitat
// e qu'es impossible de "recuperar" o de reciclar aqueste escript
if (mw.config.get('wgCanonicalNamespace') != 'User') return;
var i=0
for (i=0;i<=9;i++){
var vMb = document.getElementById("mb"+i);
if (!vMb) break;
var j=1
var vOgIni = 0
for (j=1;j<=9;j++){
var vBt = document.getElementById("mb"+i+"bt"+j);
if (!vBt) break;
vBt.onclick = QuadreOngletVeireOnglet;
if (vBt.className=="mbBotonSel") vOgIni=j;
}
if (vOgIni == 0) {
vOgIni = 1+Math.floor((j-1)*Math.random()) ;
document.getElementById("mb"+i+"og"+vOgIni).style.display = "block";
document.getElementById("mb"+i+"og"+vOgIni).style.visibility = "visible";
document.getElementById("mb"+i+"bt"+vOgIni).className="mbBotonSel";
}
}
}
function QuadreOngletVeireOnglet(){
var vMbNom = this.id.substr(0,3);
var vIndex = this.id.substr(5,1);
var i=1
for (i=1;i<=9;i++){
var vOgElem = document.getElementById(vMbNom+"og"+i);
if (!vOgElem) break;
if (vIndex==i){
vOgElem.style.display = "block";
vOgElem.style.visibility = "visible";
document.getElementById(vMbNom+"bt"+i).className="mbBotonSel";
} else {
vOgElem.style.display = "none";
vOgElem.style.visibility = "hidden";
document.getElementById(vMbNom+"bt"+i).className="mbBoton";
}
}
return false;
}
$(QuadreOngletInit);
/*FIN DEL CÒDE JAVASCRIPT DE "QUADRE D'ONGLETS"*/
} // Fin del còde concernent l'espaci de nom 'Utilizaire'
// ESPACI DE NOM 'REFERÉNCIA'
if( mw.config.get('wgNamespaceNumber') == 104 ) {
/*
* Causida del mòde d'afichatge de las referéncias
* @nòta L'òrdre d'aquesta lista deu correspondre a lo de Modèl:Edicion !
*/
function addBibSubsetMenu() {
var specialBib = document.getElementById('specialBib');
if (!specialBib) return;
specialBib.style.display = 'block';
menu = '<select style="display:inline;" onChange="chooseBibSubset(selectedIndex)">'
+ '<option>Lista</option>'
+ '<option>WikiNòrma</option>'
+ '<option>BibTeX</option>'
+ '<option>ISBD</option>'
+ '<option>ISO690</option>'
+ '</select>';
specialBib.innerHTML = specialBib.innerHTML + menu;
/* default subset - try to use a cookie some day */
chooseBibSubset(0);
}
// select subseccion of special characters
function chooseBibSubset(s) {
var l = document.getElementsByTagName('div');
for (var i = 0; i < l.length ; i++) {
if(l[i].className == 'BibList') l[i].style.display = s == 0 ? 'block' : 'none';
else if(l[i].className == 'WikiNòrma') l[i].style.display = s == 1 ? 'block' : 'none';
else if(l[i].className == 'BibTeX') l[i].style.display = s == 2 ? 'block' : 'none';
else if(l[i].className == 'ISBD') l[i].style.display = s == 3 ? 'block' : 'none';
else if(l[i].className == 'ISO690') l[i].style.display = s == 4 ? 'block' : 'none';
}
}
$(addBibSubsetMenu);
} // Fin del còde que concernís l'espaci de nom 'Referéncia'
/*
* Foncion
*
* Recupèra la valor d'una variabla globala en gerent lo cas quora aquesta variabla existís pas
* @param nom_variable Nom de la variabla que se ne vòl conéisser la valor
* @param val_defaut Valor per defaut se la variabla existís pas
* @return La valor de la variablq, o val_defaut se la variablq existís pas
*
* Autor : Sanao
* Darrièra revision : 22 novembre 2007
*/
function getVarValue(nom_variable, val_defaut)
{
var result = null;
try
{
result = eval(nom_variable.toString());
}
catch (e)
{
result = val_defaut;
}
return(result);
}
/*
* Foncion
*
* Retorna una cadena de caractèrs de la data correnta segon un format definit
* @param format Format de la data "j" pel jorn, "m" pel mes e "a" per l'annada. Atal s'es lo 21 de novembre de 2007 e se passa en paramètre aquesta cadena "a_m_d", la cadena retornada serà "2007_novembre_21"
* Autor : Sanao
* Darrièra revision : 21 de novembre de 2007
*/
function getStrDateToday(format)
{
var str_mes = new Array();
with (str_mes)
{
push("genièr");
push("febrièr");
push("març");
push("abril");
push("mai");
push("junh");
push("julhet");
push("agost");
push("setembre");
push("octobre");
push("novembre");
push("decembre");
}
var today = new Date();
var day = today.getDate();
var year = today.getYear();
if (year < 2000)
{
year = year + 1900;
}
var str_date = format;
//Creacion de la cadena
var regex = /j/gi;
str_date = str_date.replace(regex, day.toString());
regex = /a/gi;
str_date = str_date.replace(regex, year.toString());
regex = /m/gi;
str_date = str_date.replace(regex, str_mois[today.getMonth()]);
return (str_date);
}
/*
Esplech per permetre l'afichatge immediat d'un javascript per totes los utilizaires al meteis temps.
Quitament se tòrnan pas cargar Wikipèdia amb CTRL+R.
Util inicialament per preveire una bona reactivitat e una aviada generala duel[[Projècte:Estampatge]].
Plyd - 12 octobre 2008
tag urgentsynchronejs enclús (pas encore) dins [[MediaWiki:Copyright]]
*/
function urgentSynchroneJsLoad() {
if (document.getElementById('urgentsynchronejs')) {
jsname = "MediaWiki:Common.js/"+document.getElementById('urgentsynchronejs').title;
importScript(jsname);
}
}
$(urgentSynchroneJsLoad);
/* Permet d'afichar un compte a rebors sus una pagina amb lo modèl [[Modèl:Compte a rebors]] */
/* Plyd - 3 de febrièr de 2009 */
function Rebours() {
if(mw.config.get('wgNamespaceNumber')==0) return;
try {
if (document.getElementById("rebors")) {
destime = document.getElementById("rebors").title.split(";;");
Ara = (new Date).getTime();
Future = new Date(Date.UTC(destime[0], (destime[1]-1), destime[2], destime[3], destime[4], destime[5])).getTime();
Diff = (Future-Maintenant);
if (Diff < 0) {Diff = 0}
TempsDemorantJ = Math.floor(Diff/(24*3600*1000));
TempsDemorantH = Math.floor(Diff/(3600*1000)) % 24;
TempsDemorantM = Math.floor(Diff/(60*1000)) % 60;
TempsDemorantS = Math.floor(Diff/1000) % 60;
TempsDemorant = "" + mw.html.escape(destime[6]) + " ";
if (TempsDemorantJ == 1) {
TempsDemorant = TempsDemorant + TempsDemorantJ + " jorn ";
} else if (TempsDemorantJ > 1) {
TempsDemorant = TempsDemorant + TempsDemorantJ + " jorns ";
}
TempsDemorant = TempsDemorant + TempsDemorantH + " h " + TempsDemorantM + " min " + TempsDemorantS + " s";
document.getElementById("rebors").innerHTML = TempsDemorant;
setTimeout("Rebors()", 1000)
}
} catch (e) {}
}
$(Rebours);
/* foncionetas practicas - Darkoneko, 09/01/2008 */
//crèa un ligam e o retorna.
//lo parametre onclick es facultatiu.
function createAdressNode(href, texte, onclick) {
var a = document.createElement('a')
a.href = href
a.appendChild(document.createTextNode( texte ) )
if(arguments.length == 3) { a.setAttribute("onclick", onclick ) }
return a
}
/*
/!\ incompatible amb IE dins sa forma actuala /!\
get_editcounts() TODO :
*/
function get_editcounts(noms) {
var http_request;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest()
if (http_request.overrideMimeType)
http_request.overrideMimeType('text/xml')
} else {
alert("la partida editcount de addContribLinkNearTalkPageInContributions es pas compatibla internet explorer")
return;
/*
if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
*/
}
var address = "/w/api.php?format=xml&action=query&list=users&usprop=editcount&ususers=" + noms.join('|')
http_request.open('GET', address , false)
http_request.send(null)
var users = http_request.responseXML.documentElement.getElementsByTagName("user")
var usersEditCount =new Array() //tablèu de las valors (nom user => editcount)
for (var a=0 ; a < users.length ; a++) {
//aparentament impossible de far de claus nomenadas.
if( typeof( users[ a ].attributes['editcount'] ) != 'undefined' ) {
usersEditCount[ users[ a ].attributes['name'].value ] = users[a].attributes['editcount'].value
} else {
usersEditCount[ users[ a ].attributes['name'].value ] = 'N/A'
}
}
return usersEditCount
}
/* /foncionetas practicas */