Utilisateur:Plyd/monobook.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) ;
Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./* Lien "Obtenir un poster" - Voir [[Projet:Impression]]
<source lang='javascript'>
*/
/* , 'Test': 'http://www.amplyd.com/test.php' */
/* , 'Test': 'Affichage des infos<br/>envoyées par Wikipédia' */
var posterLang = mw.config.get('wgUserLanguage');
if ((posterLang != "fr") && (posterLang != "en")) {
posterLang = "fr";
}
var urlImprimeursParticipants = "http://fr.wikipedia.org/wiki/Projet:Impression/Imprimeurs_participants/";
var urlProjetImpressionFr = "http://fr.wikipedia.org/wiki/Projet:Impression";
var urlProjetImpressionEn = "http://fr.wikipedia.org/wiki/Projet:Impression/en";
var urlExemplePosters = "http://fr.wikipedia.org/wiki/Projet:Impression/Quality_images";
var impUrlall = {'WikiPosters': 'http://www.wikiposter.fr/commande.aspx'};
var impCommentfr = {'WikiPosters': 'Jusqu\'au 50x70cm <a href=\"http://fr.wikipedia.org/wiki/Projet:Impression/Imprimeurs_participants/WikiPosters\">(plus sur WikiPosters)</a>'};
var impCommenten = {'WikiPosters': 'From 15x21 to 50x70cm <a href=\"http://fr.wikipedia.org/wiki/Projet:Impression/Imprimeurs_participants/WikiPosters\">(more about WikiPosters)</a>'};
if (mw.config.get('wgUserName') != "") {
// Connected account
impUrlall['Yooook'] = 'https://yooook.net/external/picture/donation/wikimediafrance/';
impCommentfr['Yooook'] = 'Tirage photo (Kodak). <a href=\"http://fr.wikipedia.org/wiki/Projet:Impression/Imprimeurs_participants/Yooook\">(plus sur Yooook)</a>';
impCommenten['Yooook'] = 'Tirage photo (Kodak). <a href=\"http://fr.wikipedia.org/wiki/Projet:Impression/Imprimeurs_participants/Yooook\">(more about Yooook)</a>';
}
var impUrl = {'en': impUrlall, 'fr': impUrlall}
var impComment = {'en': impCommenten, 'fr': impCommentfr}
var messages = {'menuLink': {'fr': "Obtenir un poster de cette image",
'en': "Get a poster of this image"},
'menuHeader': {'fr': "Choisissez un imprimeur accrédité :",
'en': "Select an accredited printer :"},
'commandWith': {'fr': "Commandez avec",
'en': "Order with"},
'footerMenu': {'fr': "<a href=\""+urlExemplePosters+"\">Idées de posters</a> - <a href=\""+urlProjetImpressionFr+"\">Pourquoi ce service ?</a> - <a href=\""+urlProjetImpressionFr+"/Conseils\" title=\"Regardez l'image en haute résolution pour vous assurer de sa qualité en grand format\">Conseils</a>",
'en': "<a href=\""+urlExemplePosters+"\">Poster ideas</a> - <a href=\""+urlProjetImpressionEn+"\">Why this service ?</a> - <a href=\""+urlProjetImpressionFr+"/Conseils\" title=\"Check the image in high resolution to be sure of its quality on a big poster\">Tips</a>"}}
function getImageUrl() {
return document.getElementById("file").childNodes[0].href;
}
function tick(url) {
imgStats = document.createElement('img');
imgStats.src = url;
imgStats.width = 1;
imgStats.height = 1;
imgStats.border = 0;
imgStats.alt = " ";
document.body.appendChild(imgStats);
}
function addItemToPrinterForm(formInfos, key, content) {
newElement = document.createElement('textarea');
newElement.name = key;
newElement.value = content;
formInfos.appendChild(newElement);
}
function getLicenceInfo() {
/* retrieve page description */
imgdesc = document.getElementById("shared-image-desc");
var listOfLinks = "<p><table class=\"smalllines\" style=\"width: 100%;\"><tr><td style=\"width: 50%;\">";
/* add numbers in links and show full links in a table below */
var listOfA = imgdesc.getElementsByTagName("a");
var ref = 1;
var middle = Math.ceil(listOfA.length/2);
for(i=0;i<listOfA.length;i++){
if ((listOfA[i].href.length > 0) && /* href exists */
(listOfA[i].href.indexOf("/wiki/Template:") == -1 ) && /* no link to templates (only important links) */
(listOfA[i].href.indexOf("&action=edit") == -1 ) && /* no edit link */
(listOfA[i].href.indexOf("/wiki/Image:") == -1 )) { /* no link to other images */
listOfA[i].innerHTML += " (" + ref + ")";
listOfLinks += "("+ref+") "+listOfA[i].href+"<br/>";
ref++;
}
if (middle==i) {
listOfLinks += "</td><td style=\"width: 50%;\">";
}
}
listOfLinks += "</td></tr></table>";
startlicenceinfo = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Informations de licence pour l'image \""+mw.config.get('wgTitle')+'"</title><link rel="stylesheet" href="http://upload.wikimedia.org/skins/common/commonPrint.css?184" type="text/css" /><link rel="stylesheet" href="http://fr.wikipedia.org/w/index.php?title=MediaWiki:Common.css&usemsgcache=yes&ctype=text%2Fcss&smaxage=2678400&action=raw&maxage=2678400" type="text/css" /><link rel="stylesheet" href="http://fr.wikipedia.org/w/index.php?title=MediaWiki:Print.css&usemsgcache=yes&ctype=text%2Fcss&smaxage=2678400&action=raw&maxage=2678400" type="text/css" media="print" /><link rel="stylesheet" href="http://fr.wikipedia.org/w/index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&ctype=text%2Fcss&smaxage=2678400&action=raw&maxage=2678400" type="text/css" /><STYLE type=text/css>BODY,TABLE {FONT-SIZE: 10pt;}BODY,TABLE,TD,P {padding: 1pt; margin: 0;}.smalllines {FONT-SIZE: 6.5pt! important; LINE-HEIGHT: 135%;}h1,h2,h3,h4,h5 {FONT-SIZE: 9.5pt! important; margin:0; padding:0; LINE-HEIGHT: 14pt}</STYLE></head><body><p>'+"Ce poster provient de Wikimedia Commons (http://fr.wikipedia.org/wiki/"+mw.config.get('wgPageName')+").<br/>Voici un récapitulatif des informations le concernant, notamment sa licence d'utilisation.</p>";
endlicenceinfo = "</body></html>";
licenceinfo = startlicenceinfo + imgdesc.innerHTML + listOfLinks + endlicenceinfo;
return licenceinfo;
}
function sendDataToPrinter(thisPrinter) {
formInfos = document.createElement('form');
addItemToPrinterForm(formInfos, "imageurl", getImageUrl());
addItemToPrinterForm(formInfos, "licenceinfo", getLicenceInfo());
addItemToPrinterForm(formInfos, "imageurlmini", document.getElementById("file").childNodes[0].childNodes[0].src);
addItemToPrinterForm(formInfos, "imagetitle", mw.config.get('wgTitle'));
addItemToPrinterForm(formInfos, "imagePageName", mw.config.get('wgPageName'));
formInfos.action = impUrl[posterLang][thisPrinter];
formInfos.method = "post";
formInfos.target = "_blank";
formInfos.style.display = "none";
document.body.appendChild(formInfos);
formInfos.submit();
}
function showPrinterMenu() {
document.getElementById('listeImprimeurs').style.display='block';
}
posterMenuTO=setTimeout('null',1)
function hidePosterMenu() {
document.getElementById('listeImprimeurs').style.display='none';
}
function resetPosterMenuTO(f) {
clearTimeout(posterMenuTO);
posterMenuTO=setTimeout(f,1000);
}
function createHiddenMenuDiv(impUrlTable,impCommentTable) {
var div=document.createElement("div");
div.id = "listeImprimeurs";
div.onmouseout = function() { resetPosterMenuTO(hidePosterMenu); }
div.onmouseover = function() { resetPosterMenuTO('null'); document.getElementById('listeImprimeurs').style.display='block' }
printerLine = "<tr><td>"+messages['menuHeader'][posterLang]+"</td></tr>";
for (printer in impUrlTable) {
printerLine = printerLine + "<tr><td><a href=\"javascript:sendDataToPrinter(\'"+printer+"\');\"><b>"+messages['commandWith'][posterLang]+" "+printer+"</b></a><br/><small>"+impCommentTable[printer]+"</small></td></tr>";
}
div.innerHTML = "<table width='300px'>"+printerLine+"<tr><td><small>"+messages['footerMenu'][posterLang]+"</small></td></tr></table>";
div.style.display='none';
return div;
}
function isShowMenuImmediatly() {
var showMenuImmediatly = false;
try {
/* retrieve the anchor in url and test if it is menuImprimeurs */
var anchor = window.location.href.split("#")[1];
if (anchor == "menuImprimeurs") {
showMenuImmediatly = true;
}
} catch (err) {
/* there are no anchor after # */
}
return showMenuImmediatly;
}
/* This function is called on all pages and handles
if the menu should be displayed and constructed or not */
function checkAndMakePosterMenu() {
if (mw.config.get('wgNamespaceNumber')!=6) {
/* We are not on an image page */
return;
}
if (document.getElementById('filetoc') == null) {
/* There are no place on this page to put the link (should not happen) */
return;
}
if (!(document.getElementById("file") &&
document.getElementById("file").childNodes[0] &&
document.getElementById("file").childNodes[0].href)) {
/* We are unable to retrieve the url of the image in full resolution (may happen for non-image files) */
return;
}
/* Control validity of image in terms of free licence */
/* and object shared-image-desc only exists for commons :( */
if (document.getElementById("shared-image-desc") == null) {
/* Image does not come from commons */
return;
}
var toc = document.getElementById('filetoc');
var li = document.createElement("li");
var a = document.createElement("a");
a.href = "javascript:showPrinterMenu();";
a.appendChild(document.createTextNode(messages['menuLink'][posterLang]));
li.appendChild(a);
toc.appendChild(li);
toc.appendChild(createHiddenMenuDiv(impUrl[posterLang], impComment[posterLang]));
/* show menu at the load of the page (#menuImprimeurs) */
if (isShowMenuImmediatly()) {
showPrinterMenu();
}
}
$(checkAndMakePosterMenu);
/*</source>*/