Utilisateur:Mabifixem/vector.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.mw.loader.using('mediawiki.util', function () {
/*
* Magic_words
*
* Ajoute les Magic Words Mediawiki dans la liste des caractères spéciaux
*
* Auteur : ??
* Date de dernière révision : 23 juin 2006
* {{Projet:JavaScript/Script|caracteres/magic}}
*/
//<source lang=javascript>//<pre><nowiki>
$(function() {
// Magic words
if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
addSpecialCharsetHTML("Magic words",
"<a href=\"http://meta.wikimedia.org/wiki/Help:Magic_words\">Aide</a>" +
"<br />TOC / Section :" +
"<span>" +
"__NOTOC__ __TOC__ __FORCETOC__ __NOEDITSECTION__ __NEWSECTIONLINK__ __NOGALLERY__ __HIDDENCAT__" +
"</span>" +
"<br />Date / Heure (UTC) : " +
"<span>" +
"{{CURRENTDAY}} {{CURRENTDAY2}} {{CURRENTDAYNAME}} {{CURRENTMONTH}} {{CURRENTMONTHNAME}} {{CURRENTMONTHABBREV}} {{CURRENTWEEK}} {{CURRENTYEAR}} {{CURRENTTIME}} {{CURRENTHOUR}} {{CURRENTTIMESTAMP}}" +
"</span>" +
"<br />Date / Heure (local) : " +
"<span>" +
"{{LOCALDAY}} {{LOCALDAY2}} {{LOCALDAYNAME}} {{LOCALMONTH}} {{LOCALMONTHNAME}} {{LOCALMONTHABBREV}} {{LOCALWEEK}} {{LOCALYEAR}} {{LOCALTIME}} {{LOCALHOUR}} {{LOCALTIMESTAMP}}" +
"</span>" +
"<br />Pages : " +
"<span>" +
"{{PAGENAME}} {{SUBPAGENAME}} {{BASEPAGENAME}} {{NAMESPACE}} {{FULLPAGENAME}} {{TALKSPACE}} {{SUBJECTSPACE}} {{ARTICLESPACE}} {{TALKPAGENAME}} {{SUBJECTPAGENAME}} {{ARTICLEPAGENAME}} {{REVISIONDAY}} {{REVISIONDAY2}} {{REVISIONMONTH}} {{REVISIONYEAR}} {{REVISIONTIMESTAMP}} {{SITENAME}} {{SERVER}} {{SCRIPTPATH}} {{SERVERNAME}}" +
"</span>" +
"<br />Stats : " +
"<span>" +
"{{CURRENTVERSION}} {{NUMBEROFEDITS}} {{NUMBEROFARTICLES}} {{NUMBEROFPAGES}} {{NUMBEROFFILES}} {{NUMBEROFUSERS}} {{NUMBEROFADMINS}} {{PAGESINNS:+}}" +
"</span>");
}
});
//</nowiki></pre></source>
// Permet de zoomer une image ("thumb" ou galerie) au survol de la souris ou au focus du clavier
// Documentation : [[Projet:JavaScript/Notices/ZoomOnThumb]]
// {{Catégorisation JS|ZoomOnThumb}}
//<source lang=javascript>
//<pre><nowiki>
////////////////////////////////////////////////////////////// VARIABLES PERSONNALISABLES //////////////////////////////////////////
//// Images thumb ////
// délai avant zoom en millisecondes
if(typeof(ZoomOnThumb_Delay)=="undefined") var ZoomOnThumb_Delay = 200;
// délai entre deux étapes d'agrandissement en millisecondes
if(typeof(ZoomOnThumb_TimeOut)=="undefined") var ZoomOnThumb_TimeOut = 50;
// multiplicateur de grossissement max
if(typeof(ZoomOnThumb_MaxMultiplicator)=="undefined") var ZoomOnThumb_MaxMultiplicator = 3;
//// Images galeries ////
// délai avant zoom en millisecondes
if(typeof(ZoomOnGallery_Delay)=="undefined") var ZoomOnGallery_Delay = 200;
// délai entre deux étapes d'agrandissement en millisecondes
if(typeof(ZoomOnGallery_TimeOut)=="undefined") var ZoomOnGallery_TimeOut = 50;
// pourcentage d'agrandissement entre deux étapes
if(typeof(ZoomOnGallery_ZoomFactor)=="undefined") var ZoomOnGallery_ZoomFactor = 4;
// multiplicateur de grossissement max
if(typeof(ZoomOnGallery_MaxMultiplicator)=="undefined") var ZoomOnGallery_MaxMultiplicator = 3;
//// Vidéos thumb ////
// activation
if(typeof(ZoomOnVideoThumb_Activated)=="undefined") var ZoomOnVideoThumb_Activated = false;
// délai en millisecondes
if(typeof(ZoomOnVideoThumb_TimeOut)=="undefined") var ZoomOnVideoThumb_TimeOut = 30;
// multiplicateur de grossissement max
if(typeof(ZoomOnVideoThumb_MaxMultiplicator)=="undefined") var ZoomOnVideoThumb_MaxMultiplicator = 3;
// zoom automatique au début de la lecture
if(typeof(ZoomOnVideoThumb_AutoZoom)=="undefined") var ZoomOnVideoThumb_AutoZoom = false;
//// Vidéos galeries ////
// activation
if(typeof(ZoomOnVideoGallery_Activated)=="undefined") var ZoomOnVideoGallery_Activated = false;
// délai en millisecondes
if(typeof(ZoomOnVideoGallery_TimeOut)=="undefined") var ZoomOnVideoGallery_TimeOut = 30;
// multiplicateur de grossissement max
if(typeof(ZoomOnVideoGallery_MaxMultiplicator)=="undefined") var ZoomOnVideoGallery_MaxMultiplicator = 3;
// zoom automatique au début de la lecture
if(typeof(ZoomOnVideoGallery_AutoZoom)=="undefined") var ZoomOnVideoGallery_AutoZoom = false;
////////////////////////////////////////////////////////////// FONCTIONS //////////////////////////////////////////
// --------------------------------------------------- IMAGES THUMB -----------------------------------------------------------------
/* VARIABLES */
var ZoomOnThumb_LinkOnImage = new Array(); // Liste des liens "image"
var ZoomOnThumb_LinkOnImageState = new Array(); // État de zoom : 1 = zoom avant, -1 = zoom arrière, 0 = taille normale
var ZoomOnThumb_LinkOnImageOriginalWidth = new Array(); // Largeur originale de l'image
var ZoomOnThumb_LinkOnImageOriginalHeight = new Array(); // Hauteur originale de l'image
var ZoomOnThumb_LinkOnImageOriginalTarget = new Array(); // Cible originale de l'image (basse résolution)
var ZoomOnThumb_LinkOnImageZoomedTarget = new Array(); // Cible zoomée de l'image (haute résolution)
/* LANCEMENT */
$(ZoomOnThumb_CheckLinks);
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "IMAGE" */
function ZoomOnThumb_CheckLinks(){
var Divs = document.getElementsByTagName('div');
for(var a=0;a<Divs.length;a++){
if($(Divs[a]).hasClass("thumbinner")){
var DivThumb = Divs[a];
$(DivThumb).addClass("nopopups");
var Links = DivThumb.getElementsByTagName('a');
var LinkOnImage = Links[0];
if(LinkOnImage){
while(LinkOnImage.className != "image"){
LinkOnImage = LinkOnImage.nextSibling;
if(!LinkOnImage) break;
}
}
if(LinkOnImage){
var Extension = LinkOnImage.href.replace(/.*\./,"").toLowerCase();
if((Extension!='ogg')&&(Extension!='ogv')&&(Extension!='pdf')){
ZoomOnThumb_LinkOnImage.push(LinkOnImage);
}
}
}
}
ZoomOnThumb_ModifyLinks();
}
/* TRANSFORMATION DES LIENS, MISE A JOUR VARIABLES */
function ZoomOnThumb_ModifyLinks(){
for(var b=0;b<ZoomOnThumb_LinkOnImage.length;b++){
var ThisLink = ZoomOnThumb_LinkOnImage[b];
ThisLink.id = "ZoomLink_" +b;
ThisLink.onmouseover = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnThumb_LinkOnImageState[ID] = 1;
ZoomOnThumb_ReplaceSrc(ID);
setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_Delay);
}
ThisLink.onfocus = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnThumb_LinkOnImageState[ID] = 1;
ZoomOnThumb_ReplaceSrc(ID);
setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_Delay);
}
ThisLink.onmouseout = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnThumb_LinkOnImageState[ID] = -1;
ZoomOnThumb_ZoomOut(ID);
}
ThisLink.onblur = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnThumb_LinkOnImageState[ID] = -1;
ZoomOnThumb_ZoomOut(ID);
}
var ThisDiv = ThisLink.parentNode;
ThisDiv.id = "ZoomDiv_" +b;
var ThisImage = ThisLink.getElementsByTagName('img')[0];
ThisImage.id = "ZoomImage_" +b;
ZoomOnThumb_LinkOnImageOriginalWidth[b] = ThisImage.width;
ZoomOnThumb_LinkOnImageOriginalHeight[b] = ThisImage.height;
ZoomOnThumb_LinkOnImageOriginalTarget[b] = ThisImage.src;
ZoomOnThumb_LinkOnImageState[b] = 0;
}
}
/* ZOOM AVANT */
function ZoomOnThumb_ZoomIn(ID){
if(ZoomOnThumb_LinkOnImageState[ID]!= 1) return;
var Image = document.getElementById('ZoomImage_'+ID);
var Div = document.getElementById('ZoomDiv_'+ID);
if((!Image)||(!Div)) return;
var ImageWidth = parseInt(Image.width);
var ImageHeight = parseInt(Image.height);
var Content = document.getElementById("bodyContent");
if(!Content) Content = document.getElementById("mw_contentholder");
if(!Content) Content = document.getElementById("article");
var ContentWidth = (parseInt(Content.offsetWidth) - 30);
if(ImageWidth<(ZoomOnThumb_LinkOnImageOriginalWidth[ID]*ZoomOnThumb_MaxMultiplicator)){
var NewImageWidth = parseInt(ImageWidth * 1.05);
var NewImageHeight = parseInt(ImageHeight * 1.05);
if(NewImageWidth>ContentWidth) return;
Image.width = NewImageWidth;
Image.height = NewImageHeight;
Div.style.width = (2+NewImageWidth) + 'px';
setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_TimeOut);
}
}
/* ZOOM ARRIÈRE */
function ZoomOnThumb_ZoomOut(ID){
if(ZoomOnThumb_LinkOnImageState[ID]!= -1) return;
var Image = document.getElementById('ZoomImage_'+ID);
var Div = document.getElementById('ZoomDiv_'+ID);
if((!Image)||(!Div)) return;
var ImageWidth = parseInt(Image.width);
var ImageHeight = parseInt(Image.height);
if(ImageWidth>ZoomOnThumb_LinkOnImageOriginalWidth[ID]){
var NewImageWidth = parseInt(ImageWidth * 0.8);
var NewImageHeight = parseInt(ImageHeight * 0.8);
if(NewImageWidth<ZoomOnThumb_LinkOnImageOriginalWidth[ID]){
NewImageWidth = ZoomOnThumb_LinkOnImageOriginalWidth[ID];
NewImageHeight = ZoomOnThumb_LinkOnImageOriginalHeight[ID];
Image.src = ZoomOnThumb_LinkOnImageOriginalTarget[ID];
ZoomOnThumb_LinkOnImageState[ID] = 0;
}
Image.width = NewImageWidth;
Image.height = NewImageHeight;
Div.style.width = (2+NewImageWidth) + 'px';
setTimeout("ZoomOnThumb_ZoomOut("+ID+");", ZoomOnThumb_TimeOut);
}
}
/* RECHERCHE CIBLE DE L'IMAGE EN HAUTE RÉSOLUTION */
function ZoomOnThumb_ReplaceSrc(ID){
var Image = document.getElementById('ZoomImage_'+ID);
var Link = document.getElementById('ZoomLink_'+ID);
if((!Image)||(!Link)) return;
if(ZoomOnThumb_LinkOnImageZoomedTarget[ID]){
Image.src = ZoomOnThumb_LinkOnImageZoomedTarget[ID];
return;
}
var Cible = mw.config.get('wgFormattedNamespaces')[6] + ':' + Link.href.split(mw.config.get('wgFormattedNamespaces')[6] + ':')[1];
var AdresseRequete = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&prop=imageinfo&iiprop=url&iiurlwidth='+(ZoomOnThumb_LinkOnImageOriginalWidth[ID]*ZoomOnThumb_MaxMultiplicator)+'&titles=' + Cible.replace(/&/g, "%26");
var NouvelleRequete = new XMLHttpRequest();
NouvelleRequete.open("GET", AdresseRequete, true);
NouvelleRequete.onreadystatechange = function() {
if(NouvelleRequete.readyState != 4 || NouvelleRequete.status != 200) return;
var ObjetXML = NouvelleRequete.responseXML;
if(!ObjetXML) return;
var Info = ObjetXML.getElementsByTagName('ii')[0];
if(Info){
var NewSrcImage = Info.getAttribute("thumburl");
ZoomOnThumb_LinkOnImageZoomedTarget[ID] = NewSrcImage;
if(ZoomOnThumb_LinkOnImageState[ID]!= 1) return;
Image.src = NewSrcImage;
}
}
NouvelleRequete.send(null);
}
// --------------------------------------------------- IMAGES GALERIES ---------------------------------------------------------------
/* VARIABLES */
var ZoomOnGallery_LinkOnImage = new Array(); // Liste des liens "image"
var ZoomOnGallery_LinkOnImageState = new Array(); // État de zoom : 1 = zoom avant, -1 = zoom arrière, 0 = taille normale
var ZoomOnGallery_LinkOnImageOriginalWidth = new Array(); // Largeur originale de l'image
var ZoomOnGallery_LinkOnImageOriginalHeight = new Array(); // Hauteur originale de l'image
var ZoomOnGallery_LinkOnImageOriginalTarget = new Array(); // Cible originale de l'image (basse résolution)
var ZoomOnGallery_LinkOnImageZoomedTarget = new Array(); // Cible zoomée de l'image (haute résolution)
/* LANCEMENT */
$(ZoomOnGallery_CheckLinks);
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "IMAGE" */
function ZoomOnGallery_CheckLinks(){
var Divs = document.getElementsByTagName('li');
for(var a=0;a<Divs.length;a++){
if($(Divs[a]).hasClass("gallerybox")){
var DivGallery = Divs[a];
$(DivGallery).addClass("nopopups");
var Links = DivGallery.getElementsByTagName('a');
var LinkOnImage = Links[0];
if(LinkOnImage){
while(LinkOnImage.className != "image"){
LinkOnImage = LinkOnImage.nextSibling;
if(!LinkOnImage) break;
}
}
if(LinkOnImage){
var Extension = LinkOnImage.href.replace(/.*\./,"").toLowerCase();
if((Extension!='ogg')&&(Extension!='ogv')&&(Extension!='pdf')){
ZoomOnGallery_LinkOnImage.push(LinkOnImage);
}
}
}
}
ZoomOnGallery_ModifyLinks();
}
/* TRANSFORMATION DES LIENS, MISE A JOUR VARIABLES */
function ZoomOnGallery_ModifyLinks(){
for(var b=0;b<ZoomOnGallery_LinkOnImage.length;b++){
var ThisLink = ZoomOnGallery_LinkOnImage[b];
ThisLink.id = "ZoomLink_" +(b+1000);
ThisLink.onmouseover = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnGallery_LinkOnImageState[ID] = 1;
ZoomOnGallery_ReplaceSrc(ID);
setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_Delay);
}
ThisLink.onfocus = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnGallery_LinkOnImageState[ID] = 1;
ZoomOnGallery_ReplaceSrc(ID);
setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_Delay);
}
ThisLink.onmouseout = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnGallery_LinkOnImageState[ID] = -1;
ZoomOnGallery_ZoomOut(ID);
}
ThisLink.onblur = function(){
var ID = parseInt(this.id.split('ZoomLink_').join(''));
ZoomOnGallery_LinkOnImageState[ID] = -1;
ZoomOnGallery_ZoomOut(ID);
}
var ThisDiv1 = ThisLink.parentNode;
ThisDiv1.id = "ZoomDiv1_" +(b+1000);
var ThisThumb = ThisDiv1.parentNode;
ThisThumb.id = "ZoomThumb_" +(b+1000);
var ThisDiv2 = ThisThumb.parentNode;
ThisDiv2.id = "ZoomDiv2_" +(b+1000);
var ThisGalleryBox = ThisDiv2.parentNode;
ThisGalleryBox.id = "ZoomGalleryBox_" +(b+1000);
var ThisImage = ThisLink.getElementsByTagName('img')[0];
ThisImage.id = "ZoomImage_" +(b+1000);
ZoomOnGallery_LinkOnImageOriginalWidth[(b+1000)] = ThisImage.width;
ZoomOnGallery_LinkOnImageOriginalHeight[(b+1000)] = ThisImage.height;
ZoomOnGallery_LinkOnImageOriginalTarget[(b+1000)] = ThisImage.src;
ZoomOnGallery_LinkOnImageState[(b+1000)] = 0;
}
}
/* ZOOM AVANT */
function ZoomOnGallery_ZoomIn(ID){
if(ZoomOnGallery_LinkOnImageState[ID]!= 1) return;
var Image = document.getElementById('ZoomImage_'+ID);
var Div1 = document.getElementById('ZoomDiv1_'+ID);
var Thumb = document.getElementById('ZoomThumb_'+ID);
var Div2 = document.getElementById('ZoomDiv2_'+ID);
var GalleryBox = document.getElementById('ZoomGalleryBox_'+ID);
if((!Image)||(!Div1)||(!Thumb)||(!Div2)||(!GalleryBox)) return;
var ImageWidth = parseInt(Image.width);
var ImageHeight = parseInt(Image.height);
var Content = document.getElementById("bodyContent");
if(!Content) Content = document.getElementById("mw_contentholder");
if(!Content) Content = document.getElementById("article");
var ContentWidth = (parseInt(Content.offsetWidth) - 30);
var Factor = (100+ZoomOnGallery_ZoomFactor)/100;
var MaxWidth = (parseInt(ZoomOnGallery_LinkOnImageOriginalWidth[ID])*parseInt(ZoomOnGallery_MaxMultiplicator));
if(ImageWidth<MaxWidth){
var NewImageWidth = parseInt(ImageWidth * Factor);
var NewImageHeight = parseInt(ImageHeight * Factor);
if(NewImageWidth>ContentWidth) return;
var MaxSize = NewImageWidth;
if(ImageHeight>NewImageWidth) MaxSize = NewImageHeight;
Image.width = NewImageWidth;
Image.height = NewImageHeight;
Div1.style.width = NewImageWidth + 'px';
Thumb.style.width = Math.floor( MaxSize+30 ) + 'px';
Thumb.style.height = Math.floor( MaxSize+30 ) + 'px';
Div2.style.width = Math.floor( MaxSize+35 ) + 'px';
GalleryBox.style.width = Math.floor( MaxSize+35 ) + 'px';
setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_TimeOut);
}
}
function ZoomOnGallery_GetWidth(Node){
return parseInt(Node.style.width.split("px").join(""));
}
function ZoomOnGallery_GetHeight(Node){
return parseInt(Node.style.height.split("px").join(""));
}
/* ZOOM ARRIÈRE */
function ZoomOnGallery_ZoomOut(ID){
if(ZoomOnGallery_LinkOnImageState[ID]!= -1) return;
var Image = document.getElementById('ZoomImage_'+ID);
var Div1 = document.getElementById('ZoomDiv1_'+ID);
var Thumb = document.getElementById('ZoomThumb_'+ID);
var Div2 = document.getElementById('ZoomDiv2_'+ID);
var GalleryBox = document.getElementById('ZoomGalleryBox_'+ID);
if((!Image)||(!Div1)||(!Thumb)||(!Div2)||(!GalleryBox)) return;
var ImageWidth = parseInt(Image.width);
var ImageHeight = parseInt(Image.height);
var MinWidth = ZoomOnGallery_LinkOnImageOriginalWidth[ID];
var Factor = 0.8;
if(ImageWidth>MinWidth){
var NewImageWidth = parseInt(ImageWidth * Factor);
var NewImageHeight = parseInt(ImageHeight * Factor);
if(NewImageWidth<MinWidth){
Factor = 0.9;
NewImageWidth = parseInt(ImageWidth * Factor);
NewImageHeight = parseInt(ImageHeight * Factor);
if(NewImageWidth<MinWidth){
Factor = 0.95;
NewImageWidth = parseInt(ImageWidth * Factor);
NewImageHeight = parseInt(ImageHeight * Factor);
if(NewImageWidth<MinWidth){
NewImageWidth = ZoomOnGallery_LinkOnImageOriginalWidth[ID];
NewImageHeight = ZoomOnGallery_LinkOnImageOriginalHeight[ID];
Image.src = ZoomOnGallery_LinkOnImageOriginalTarget[ID];
ZoomOnGallery_LinkOnImageState[ID] = 0;
return;
}
}
}
var MaxSize = NewImageWidth;
if(ImageHeight>NewImageWidth) MaxSize = NewImageHeight;
Image.width = NewImageWidth;
Image.height = NewImageHeight;
Image.width = NewImageWidth;
Image.height = NewImageHeight;
Div1.style.width = NewImageWidth + 'px';
Thumb.style.width = (MaxSize+30) + 'px';
Thumb.style.height = (MaxSize+30) + 'px';
Div2.style.width = (MaxSize+35) + 'px';
GalleryBox.style.width = (MaxSize+35) + 'px';
setTimeout("ZoomOnGallery_ZoomOut("+ID+");", ZoomOnGallery_TimeOut);
}
}
/* RECHERCHE CIBLE DE L'IMAGE EN HAUTE RÉSOLUTION */
function ZoomOnGallery_ReplaceSrc(ID){
var Image = document.getElementById('ZoomImage_'+ID);
var Link = document.getElementById('ZoomLink_'+ID);
if((!Image)||(!Link)) return;
if(ZoomOnGallery_LinkOnImageZoomedTarget[ID]){
Image.src = ZoomOnGallery_LinkOnImageZoomedTarget[ID];
return;
}
var Cible = mw.config.get('wgFormattedNamespaces')[6] + ':' + Link.href.split(mw.config.get('wgFormattedNamespaces')[6] + ':')[1];
var AdresseRequete = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&prop=imageinfo&iiprop=url&iiurlwidth='+(ZoomOnGallery_LinkOnImageOriginalWidth[ID]*ZoomOnGallery_MaxMultiplicator)+'&titles=' + Cible.replace(/&/g, "%26");
var NouvelleRequete = new XMLHttpRequest();
NouvelleRequete.open("GET", AdresseRequete, true);
NouvelleRequete.onreadystatechange = function() {
if(NouvelleRequete.readyState != 4 || NouvelleRequete.status != 200) return;
var ObjetXML = NouvelleRequete.responseXML;
if(!ObjetXML) return;
var Info = ObjetXML.getElementsByTagName('ii')[0];
if(Info){
var NewSrcImage = Info.getAttribute("thumburl");
ZoomOnGallery_LinkOnImageZoomedTarget[ID] = NewSrcImage;
if(ZoomOnGallery_LinkOnImageState[ID]!= 1) return;
Image.src = NewSrcImage;
}
}
NouvelleRequete.send(null);
}
// --------------------------------------------------- VIDEOS THUMB ---------------------------------------------------------------
/* VARIABLES */
var ZoomOnVideoThumb_Divs = new Array(); // Liste des vidéos
var ZoomOnVideoThumb_OriginalWidth = new Array(); // Largeur originale
var ZoomOnVideoThumb_OriginalHeight = new Array(); // Hauteur originale
/* LANCEMENT */
if(ZoomOnVideoThumb_Activated) addOnloadHook(ZoomOnVideoThumb_CheckVideos);
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "VIDEO" */
function ZoomOnVideoThumb_CheckVideos(){
var Divs = document.getElementsByTagName('div');
var Index = 0;
var ThisDiv = Divs[Index];
while(ThisDiv){
var ThisDivId = ThisDiv.id;
if(ThisDivId){
if(ThisDivId.indexOf('ogg_player_')!=-1){
if($(ThisDiv.parentNode).hasClass("thumbinner")) ZoomOnVideoThumb_Divs.push(ThisDiv);
}
}
Index++
ThisDiv = Divs[Index];
}
ZoomOnVideoThumb_ModifyInputs();
}
/* MODIFICATION DES BOUTONS */
function ZoomOnVideoThumb_ModifyInputs(){
for(var a=0;a<ZoomOnVideoThumb_Divs.length;a++){
var ID = ZoomOnVideoThumb_Divs[a].id;
var IDIndex = ID.split('ogg_player_').join('');
var Button = ZoomOnVideoThumb_Divs[a].getElementsByTagName('button')[0];
var NewButtonOnclick = Button.onclick.toString();
if(NewButtonOnclick.indexOf('false});')!=-1) continue; // pas une vidéo
NewButtonOnclick = NewButtonOnclick.replace(/"/g,"'");
NewButtonOnclick = "if(typeof(wgOggPlayer)!='undefined') { wgOggPlayer.init" + NewButtonOnclick.split('wgOggPlayer.init')[1];
NewButtonOnclick = NewButtonOnclick.split('true});')[0] + 'true});';
Button.style.display = 'none';
NewButtonOnclick += ' ZoomOnVideoThumb_AddZoomLinks(\''+IDIndex+'\');'
if(ZoomOnVideoThumb_AutoZoom) NewButtonOnclick += ' ZoomOnVideoThumb_ZoomIn(\''+IDIndex+'\');';
NewButtonOnclick += '}';
var NewHTML = '<button title="'+Button.title+'" style="width:'+Button.style.width+'" onclick="'+NewButtonOnclick+'">'+Button.innerHTML+'</button>';
Button.parentNode.innerHTML = NewHTML + Button.parentNode.innerHTML;
ZoomOnVideoThumb_Divs[a].parentNode.id = "thumbinnerVideo_"+IDIndex;
}
}
/* AJOUT DES LIENS DE ZOOM */
function ZoomOnVideoThumb_AddZoomLinks(Index){
var VideoOptions = document.getElementById('ogg_player_'+Index+'_options_box');
if(!VideoOptions) return;
var ZoomOptionsDiv = document.createElement('div');
ZoomOptionsDiv.id = 'ogg_player_ZoomOptions_' + Index;
var ZoomLinks = '<center>'
+ '<a href="javascript:ZoomOnVideoThumb_ZoomIn('+Index+');" title="Agrandir la vidéo">(+)</a>'
+ ' '
+ '<a href="javascript:ZoomOnVideoThumb_ZoomOut('+Index+');" title="Réduire la vidéo">(-)</a>'
+ '</center>';
ZoomOptionsDiv.innerHTML = ZoomLinks;
VideoOptions.parentNode.insertBefore(ZoomOptionsDiv, VideoOptions);
}
/* ZOOM AVANT */
function ZoomOnVideoThumb_ZoomIn(Index){
var VideoThumbinner = document.getElementById("thumbinnerVideo_"+Index);
var VideoPlayer = document.getElementById("ogg_player_"+Index);
var Video = document.getElementById("ogg_player_"+Index+"_obj");
if((!VideoThumbinner)||(!VideoPlayer)||(!Video)) return;
var VideoWidth = Video.width;
if(!ZoomOnVideoThumb_OriginalWidth[Index]) ZoomOnVideoThumb_OriginalWidth[Index] = VideoWidth;
var VideoHeight= Video.height;
if(!ZoomOnVideoThumb_OriginalHeight[Index]) ZoomOnVideoThumb_OriginalHeight[Index] = VideoHeight;
var Content = document.getElementById("bodyContent");
if(!Content) Content = document.getElementById("mw_contentholder");
if(!Content) Content = document.getElementById("article");
var ContentWidth = (parseInt(Content.offsetWidth) - 30);
var MaxWidth = (ZoomOnVideoThumb_OriginalWidth[Index]*ZoomOnVideoThumb_MaxMultiplicator)
if(VideoWidth<MaxWidth){
var NewWidth = parseInt(VideoWidth*1.1);
var NewHeight = parseInt(VideoHeight*1.1);
if(NewWidth>ContentWidth) return;
Video.width = NewWidth;
Video.height = NewHeight;
VideoPlayer.style.width = NewWidth + 'px';
VideoThumbinner.style.width = (NewWidth+2) + 'px';
setTimeout("ZoomOnVideoThumb_ZoomIn("+Index+");", ZoomOnVideoThumb_TimeOut);
}
}
/* ZOOM ARRIÈRE */
function ZoomOnVideoThumb_ZoomOut(Index){
var VideoThumbinner = document.getElementById("thumbinnerVideo_"+Index);
var VideoPlayer = document.getElementById("ogg_player_"+Index);
var Video = document.getElementById("ogg_player_"+Index+"_obj");
if((!VideoThumbinner)||(!VideoPlayer)||(!Video)) return;
var VideoWidth = Video.width;
var VideoHeight= Video.height;
var MinWidth = ZoomOnVideoThumb_OriginalWidth[Index];
if(VideoWidth>MinWidth){
var NewWidth = parseInt(VideoWidth*0.8);
var NewHeight = parseInt(VideoHeight*0.8);
if(NewWidth<MinWidth){
NewWidth = ZoomOnVideoThumb_OriginalWidth[Index];
NewHeight = ZoomOnVideoThumb_OriginalHeight[Index];
}
Video.width = NewWidth;
Video.height = NewHeight;
VideoPlayer.style.width = NewWidth + 'px';
VideoThumbinner.style.width = (NewWidth+2) + 'px';
setTimeout("ZoomOnVideoThumb_ZoomOut("+Index+");", ZoomOnVideoThumb_TimeOut);
}
}
// --------------------------------------------------- VIDEOS GALERIES ---------------------------------------------------------------
/* VARIABLES */
var ZoomOnVideoGallery_Divs = new Array(); // Liste des vidéos
var ZoomOnVideoGallery_OriginalWidth = new Array(); // Largeur originale
var ZoomOnVideoGallery_OriginalHeight = new Array(); // Hauteur originale
/* LANCEMENT */
if(ZoomOnVideoGallery_Activated) addOnloadHook(ZoomOnVideoGallery_CheckVideos);
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "VIDEO" */
function ZoomOnVideoGallery_CheckVideos(){
var Divs = document.getElementsByTagName('div');
var Index = 0;
var ThisDiv = Divs[Index];
while(ThisDiv){
var ThisDivId = ThisDiv.id;
if(ThisDivId){
if(ThisDivId.indexOf('ogg_player_')!=-1){
if($(ThisDiv.parentNode.parentNode.parentNode).hasClass("gallerybox")) ZoomOnVideoGallery_Divs.push(ThisDiv);
}
}
Index++
ThisDiv = Divs[Index];
}
ZoomOnVideoGallery_ModifyInputs();
}
/* MODIFICATION DES BOUTONS */
function ZoomOnVideoGallery_ModifyInputs(){
for(var a=0;a<ZoomOnVideoGallery_Divs.length;a++){
var ID = ZoomOnVideoGallery_Divs[a].id;
var IDIndex = ID.split('ogg_player_').join('');
var Button = ZoomOnVideoGallery_Divs[a].getElementsByTagName('button')[0];
var NewButtonOnclick = Button.onclick.toString();
if(NewButtonOnclick.indexOf('false});')!=-1) continue; // pas une vidéo
NewButtonOnclick = NewButtonOnclick.replace(/"/g,"'");
NewButtonOnclick = "if(typeof(wgOggPlayer)!='undefined') { wgOggPlayer.init" + NewButtonOnclick.split('wgOggPlayer.init')[1];
NewButtonOnclick = NewButtonOnclick.split('true});')[0] + 'true});';
Button.style.display = 'none';
NewButtonOnclick += ' ZoomOnVideoGallery_AddZoomLinks(\''+IDIndex+'\');'
if(ZoomOnVideoGallery_AutoZoom) NewButtonOnclick += ' ZoomOnVideoGallery_ZoomIn(\''+IDIndex+'\');';
NewButtonOnclick += '}';
var NewHTML = '<button title="'+Button.title+'" style="width:'+Button.style.width+'" onclick="'+NewButtonOnclick+'">'+Button.innerHTML+'</button>';
Button.parentNode.innerHTML = NewHTML + Button.parentNode.innerHTML;
ZoomOnVideoGallery_Divs[a].parentNode.id = "VideoDiv_"+IDIndex;
ZoomOnVideoGallery_Divs[a].parentNode.parentNode.id = "VideoThumb_"+IDIndex;
ZoomOnVideoGallery_Divs[a].parentNode.parentNode.parentNode.id = "VideoGalleryBox_"+IDIndex;
}
}
/* AJOUT DES LIENS DE ZOOM */
function ZoomOnVideoGallery_AddZoomLinks(Index){
var VideoOptions = document.getElementById('ogg_player_'+Index+'_options_box');
if(!VideoOptions) return;
var ZoomOptionsDiv = document.createElement('div');
ZoomOptionsDiv.id = 'ogg_player_ZoomOptions_' + Index;
var ZoomLinks = '<center>'
+ '<a href="javascript:ZoomOnVideoGallery_ZoomIn('+Index+');" title="Agrandir la vidéo">(+)</a>'
+ ' '
+ '<a href="javascript:ZoomOnVideoGallery_ZoomOut('+Index+');" title="Réduire la vidéo">(-)</a>'
+ '</center>';
ZoomOptionsDiv.innerHTML = ZoomLinks;
VideoOptions.parentNode.insertBefore(ZoomOptionsDiv, VideoOptions);
}
/* ZOOM AVANT */
function ZoomOnVideoGallery_ZoomIn(Index){
var VideoGalleryBox = document.getElementById("VideoGalleryBox_"+Index);
var VideoThumb = document.getElementById("VideoThumb_"+Index);
var VideoDiv = document.getElementById("VideoDiv_"+Index);
var VideoPlayer = document.getElementById("ogg_player_"+Index);
var Video = document.getElementById("ogg_player_"+Index+"_obj");
if((!VideoGalleryBox)||(!VideoThumb)||(!VideoDiv)||(!VideoPlayer)||(!Video)) return;
var VideoWidth = Video.width;
if(!ZoomOnVideoGallery_OriginalWidth[Index]) ZoomOnVideoGallery_OriginalWidth[Index] = VideoWidth;
var VideoHeight= Video.height;
if(!ZoomOnVideoGallery_OriginalHeight[Index]) ZoomOnVideoGallery_OriginalHeight[Index] = VideoHeight;
var Content = document.getElementById("bodyContent");
if(!Content) Content = document.getElementById("mw_contentholder");
if(!Content) Content = document.getElementById("article");
var ContentWidth = (parseInt(Content.offsetWidth) - 30);
var MaxWidth = (ZoomOnVideoGallery_OriginalWidth[Index]*ZoomOnVideoGallery_MaxMultiplicator)
if(VideoWidth<MaxWidth){
var NewWidth = parseInt(VideoWidth*1.1);
var NewHeight = parseInt(VideoHeight*1.1);
if(NewWidth>ContentWidth) return;
Video.width = NewWidth;
Video.height = NewHeight;
VideoPlayer.style.width = NewWidth + 'px';
VideoDiv.style.width = NewWidth + 'px';
VideoThumb.style.width = (NewWidth+30) + 'px';
VideoGalleryBox.style.width = (NewWidth+35) + 'px';
setTimeout("ZoomOnVideoGallery_ZoomIn("+Index+");", ZoomOnVideoGallery_TimeOut);
}
}
/* ZOOM ARRIÈRE */
function ZoomOnVideoGallery_ZoomOut(Index){
var VideoGalleryBox = document.getElementById("VideoGalleryBox_"+Index);
var VideoThumb = document.getElementById("VideoThumb_"+Index);
var VideoDiv = document.getElementById("VideoDiv_"+Index);
var VideoPlayer = document.getElementById("ogg_player_"+Index);
var Video = document.getElementById("ogg_player_"+Index+"_obj");
if((!VideoGalleryBox)||(!VideoThumb)||(!VideoDiv)||(!VideoPlayer)||(!Video)) return;
var VideoWidth = Video.width;
var VideoHeight= Video.height;
var MinWidth = ZoomOnVideoGallery_OriginalWidth[Index];
if(VideoWidth>MinWidth){
var NewWidth = parseInt(VideoWidth*0.8);
var NewHeight = parseInt(VideoHeight*0.8);
if(NewWidth<MinWidth){
NewWidth = ZoomOnVideoGallery_OriginalWidth[Index];
NewHeight = ZoomOnVideoGallery_OriginalHeight[Index];
}
Video.width = NewWidth;
Video.height = NewHeight;
VideoPlayer.style.width = NewWidth + 'px';
VideoDiv.style.width = NewWidth + 'px';
VideoThumb.style.width = (NewWidth+30) + 'px';
VideoGalleryBox.style.width = (NewWidth+35) + 'px';
setTimeout("ZoomOnVideoGallery_ZoomOut("+Index+");", ZoomOnVideoGallery_TimeOut);
}
}
///////////////////////////////////////////////////////////////////////////////////////////</nowiki></pre></source>
//</nowiki></pre>
//</source>
// {{Catégorisation JS|VerifHomon}}
$(function(){
mw.util.addPortletLink('p-tb', 'javascript:verifierHomonymies_init();', 'Vérif. homonymies', 't-homon', "Vérifier les liens de cette page menant vers des pages d'homonymie");
});
var verifierHomonymies_goodLinks = new Array();
var verifierHomonymies_compteurHomon = 0;
function verifierHomonymies_init(){
var Content = document.getElementById('bodyContent'); // monobook, chick, myskin, simple, vector
if(!Content) Content = document.getElementById('mw_contentholder'); //modern
if(!Content) Content = document.getElementById('article'); // cologneblue, nostalgia, standard
if(!Content) return;
var allLinks = Content.getElementsByTagName('a');
for (i=0; i<allLinks.length; i++){
if (!(!allLinks[i].href || $(allLinks[i].parentNode).hasClass('editsection') || $(allLinks[i].parentNode).hasClass('cachelinks') || $(allLinks[i]).hasClass('noprint') || $(allLinks[i]).hasClass('external') || allLinks[i].href.indexOf('javascript:') == 0 || allLinks[i].className == 'new' || allLinks[i].className == 'image' || allLinks[i].parentNode.parentNode.id == 'mw-normal-catlinks' || allLinks[i].parentNode.id == 'mw-normal-catlinks' || allLinks[i].href == mw.config.get('wgServer')+'/wiki/'+encodeURI(mw.config.get('wgPageName')) || allLinks[i].href.indexOf(mw.config.get('wgServer')+'/wiki/'+encodeURI(mw.config.get('wgPageName'))+'#') == 0 || allLinks[i].parentNode.className == 'subpages' || allLinks[i].parentNode.id == 'contentSub' )) {
verifierHomonymies_goodLinks.push(allLinks[i]);
}
}
if (!confirm(verifierHomonymies_goodLinks.length + " liens vont être analysés.")) return;
verifierHomonymies_getTemplates();
}
function verifierHomonymies_getTemplates(){
var Templates = new Array();
var Aj = new XMLHttpRequest();
Aj.open('GET', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&prop=links&pllimit=499&titles=MediaWiki:Disambiguationspage', true);
Aj.onreadystatechange = function() {
if (Aj.readyState != 4 || Aj.status != 200) return;
var AllLinks = Aj.responseXML.documentElement.getElementsByTagName('pl');
for(var a=0,l=AllLinks.length;a<l;a++){
Templates.push(AllLinks[a].getAttribute("title"));
}
verifierHomonymies(Templates, 0);
}
Aj.send(null);
}
function verifierHomonymies(Templates, position, TlContinue) {
if(!position) position=0;
if(!TlContinue) TlContinue="";
var tempLink = verifierHomonymies_goodLinks[position];
if(!tempLink){
verifierHomonymies_Msg();
return;
}
var tempTitle = tempLink.title;
var Aj = new XMLHttpRequest();
Aj.open('GET', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&prop=templates&redirects&format=xml&tllimit=499&titles=' + encodeURIComponent(tempTitle).replace(/&/g, "%26") + TlContinue, true);
Aj.onreadystatechange = function() {
if (Aj.readyState != 4 || Aj.status != 200) return;
var FoundHomon = false;
verifierHomonymies_goodLinks[position].style.backgroundColor = '#C8FFC8';
var Alltemplates = Aj.responseXML.documentElement.getElementsByTagName('tl');
for (j=0; j<Alltemplates.length; j++){
var ThisTemplate = Alltemplates[j].getAttribute("title");
if (Templates.indexOf(ThisTemplate)!=-1){
FoundHomon = true;
verifierHomonymies_goodLinks[position].style.backgroundColor = '#FFCCCC';
verifierHomonymies_compteurHomon++;
break;
}
}
var QueryContinue = Aj.responseXML.documentElement.getElementsByTagName('query-continue')[0];
if(!FoundHomon && QueryContinue){
var NewTlContinue = "&tlcontinue=" + QueryContinue.firstChild.getAttribute("tlcontinue").replace(/&/g, "%26");
verifierHomonymies(Templates, position, NewTlContinue);
}else{
verifierHomonymies(Templates, (position+1));
}
}
Aj.send(null);
}
function verifierHomonymies_Msg(){
// Message de fin.
var msg = "";
if (verifierHomonymies_compteurHomon == 0)
msg = "Aucun lien vers une page d’homonymie n’a été trouvé.";
else if (verifierHomonymies_compteurHomon == 1)
msg = "Un lien vers une page d’homonymie a été trouvé.";
else
msg = verifierHomonymies_compteurHomon + " liens vers des pages d’homonymie ont été trouvés.";
alert(msg);
}
});