This is an archive copy of wikilivres.ca as of 18 February 2017 (from the WikiTeam dump). The original site is closed.
MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <pre> */
/**********************
*** Quality indicators on "article" tab
*** by [[user:ThomasV]]
**********************/
// return src for icon given percentage
function icon_src(t){
var src='https://ca.wikilivres.ru/images/';
switch(t){
case '0%': src+='8/8f/00%25.png'; break;
case '25%': src+='5/5b/25%25.png'; break;
case '50%': src+='3/3a/50%25.png'; break;
case '75%': src+='c/cd/75%25.png'; break;
case '100%': src+='6/64/100%25.png'; break;
case 'Validated': src+='b/b7/Etoile.png'; break;
}
return src;
}
// add indicator
function pageQuality() {
var a = document.getElementById('ca-nstab-main');
if(!a) return;
var pr_index = document.getElementById('pr_index');
if(pr_index) return;
var q = document.getElementById('textquality');
if(q) {
var new_img = document.createElement('img');
new_img.setAttribute('src', icon_src(q.className));
a.firstChild.appendChild(new_img);
}
for(var i=0; spanElem = document.getElementsByTagName('span')[i]; i++) {
if (spanElem.className == 'pagequality') {
var new_img = document.createElement('img');
new_img.setAttribute('src', icon_src(spanElem.title));
if(wgCanonicalNamespace == 'Page') {
a.firstChild.appendChild(new_img);
}
else {
s1 = spanElem.parentNode.previousSibling;
opttext = s1.firstChild.firstChild;
img = opttext.firstChild.nextSibling.nextSibling.nextSibling;
next = img.nextSibling;
opttext.removeChild(img);
opttext.insertBefore(new_img,next);
}
}
}
}
addOnloadHook(pageQuality);
/* configure */
self.proofreadpage_add_container = true;
self.proofreadpage_disable_wheelzoom = false;
importScriptURI('https://ca.wikilivres.ru/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
/* importScriptURI('https://wikisource.org/w/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript'); */
importScriptURI('https://ca.wikilivres.ru/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript');
importScriptURI('https://ca.wikilivres.ru/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');
/* Version ''correcte du script mais qui ne fonctionne pas, la version de jquery est trop ancienne */
/*importScriptURI('https://wikisource.org/w/index.php?title=MediaWiki:MatchSplit.js&action=raw&ctype=text/javascript');*/
/* Version de remplacement */
importScriptURI('https://ca.wikilivres.ru/index.php?title=MediaWiki:MatchSplit.js&action=raw&ctype=text/javascript');
/********************************************
*** New buttons on toolbar box
*** by [[user:ThomasV]]
********************************************/
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
mwCustomEditButtons[mwCustomEditButtons.length] =
{"imageFile": imageFile,
"speedTip": speedTip,
"tagOpen": tagOpen,
"tagClose": tagClose,
"sampleText": sampleText};
}
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png','Rayer','<s>','</s>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/8/88/Btn_toolbar_enum.png','Énumération','\\n# élément 1\\n# élément 2\\n# élément 3','','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_liste.png','Liste','\\n* élément A\\n* élément B\\n* élément C','','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/8/8f/Button_poeme.png','Poésie','<poem>','</poem>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/9/9e/Btn_toolbar_gallery.png','Galerie Photo','<gallery>\\n','\\n</gallery>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png','Commentaire','<!--','-->','Insérer votre commentaire');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/c/c8/Button_redirect.png','Redirection','#REDIRECT \[\[','\]\]','nom de la destination');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png','Catégorie','\[\[Category:','\]\]','nom de la catégorie');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png','Texte centré','<center>','</center>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png','paragraphe niveau 3','===','===','');
addCustomButton('https://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png', 'Insérer un retrait',':','',':' );
addCustomButton('https://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png','Texte plus petit','<small>','</small>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/2/28/Bouton_noir.png','Texte plus grand','<big>','</big>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png','Exposant','<sup>','</sup>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/4/4b/Button_nbsp.png','Espace insécable',' \;','','');
addCustomButton('https://upload.wikimedia.org/wikipedia/en/9/93/Button_sub_link.png','Lien vers sous-titre','\[\[Page\#','\]\]','Sub_page' );
addCustomButton('https://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png','Block quote','<blockquote style="border: 1px solid blue; padding: 2em;">\\n','\\n</blockquote>','Block quote');
addCustomButton('https://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png','Aller à la ligne','<br />','','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png', 'Paragraphe texte','<div class=\'text\'>','</div>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/7/78/Button_titre.png','Titre de page','\{\{Titre\|','\|\|\}\}','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/0/03/Button_chapitre.png','Titre de Chapitre','\{\{chapitre\|livre=','\|auteur=\|nrpartie=\|nrchapitre=\|TitreChapitre=\|commentaires=\}\}','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/c/c4/Button_ref.png','Ajoute une référence','<ref>','</ref>','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/6/64/Buttonrefvs8.png','Liste des références','<references />','','');
addCustomButton('https://upload.wikimedia.org/wikipedia/commons/c/c3/Button_travaux.png','Relecture','\{\{subst:Infoédit\|1=','\|2= \|3= \|4= \|5= \|6= \}\}','');
/********************************************
*** Copyright tab
*** by [[user:ThomasV]]
********************************************/
function ongletCopyright() { // id created by Template:Licence. It should match Template:Licence parameters
var a = document.getElementById("p-cactions");
if (a)
{
b = a.getElementsByTagName("ul");
if(b.length > 0)
{
if(document.getElementById("Creative Commons by-nc-sa"))
{ b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user">'
+ '<a href="https://fr.wikisource.org/wiki/Wikisource:Creative_Commons_by-nc-sa">' // /wiki/Wikilivres:Creative Commons by-nc-sa
+ 'Copyright</a></li>';
}
else if(document.getElementById("Copyright-ONU"))
{ b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user">'
+ '<a href="https://fr.wikisource.org/wiki/Wikisource:Copyright-ONU">' // /wiki/Wikilivres:Copyright-ONU
+ 'Copyright</a></li>';
}
else if(document.getElementById("Copyright-UNESCO"))
{ b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user">'
+ '<a href="https://fr.wikisource.org/wiki/Wikisource:Copyright-UNESCO">' // /wiki/Wikilivres:Copyright-UNESCO
+ 'Copyright</a></li>';
}
else if(document.getElementById("GFDL"))
{ b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user">'
+ '<a href="https://fr.wikisource.org/wiki/Wikisource:Licence_GFDL">' // /wiki/Wikilivres:Licence GFDL
+ 'Copyright</a></li>';
}
}
}
}
addOnloadHook(ongletCopyright);
/*****************************************************************
*** Edittools: Menu for selecting subsets of special characters
***
******************************************************************/
function addCharSubsetMenu() { // the options should match MediaWiki:Edittools
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
menu += "<option>Wiki</option>";
menu += "<option>Latin</option>";
menu += "<option>Grec</option>";
menu += "<option>Cyrillique</option>";
menu += "<option>AHD</option>";
menu += "<option>Allemand</option>";
menu += "<option>Catalan</option>";
menu += "<option>Croate</option>";
menu += "<option>Espagnol</option>";
menu += "<option>Espéranto</option>";
menu += "<option>Estonien</option>";
menu += "<option>Gallois</option>";
menu += "<option>Hawaien</option>";
menu += "<option>Hiéroglyphe</option>";
menu += "<option>Islandais</option>";
menu += "<option>Italien</option>";
menu += "<option>Maltais</option>";
menu += "<option>Pinyin</option>";
menu += "<option>Polonais</option>";
menu += "<option>Portugais</option>";
menu += "<option>Rōmaji</option>";
menu += "<option>Roumain</option>";
menu += "<option>Scandinave</option>";
menu += "<option>Serbe</option>";
menu += "<option>Tchèque</option>";
menu += "<option>Vieil anglais</option>";
menu += "<option>Vietnamien</option>";
menu += "<option>API</option>";
menu += "</select>";
specialchars.innerHTML = menu + specialchars.innerHTML;
/* default subset - try to use a cookie some day */
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
addOnloadHook(addCharSubsetMenu);
/*****************************************************************
*** interwikiExtra
*** by [[user:ThomasV]]
******************************************************************/
function interwikiExtra()
{
// iterate over all <span>-elements
for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
// if found a linkInfo span
if(a.className == "interwiki-info") { // class created by Template:Interwiki-info
// iterate over all <li>-elements
var count=0;
for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
if(b.className == "interwiki-" + a.id) {
b.innerHTML = b.innerHTML + " "+a.title;
if(a.title == "(vo)") { b.title = "Original Text"; }
}
else if(b.className == "interwiki-" + a.id.substr(0,a.id.length-1)) {
count = count+1;
if(a.id.charAt(a.id.length-1) == count) {
b.innerHTML = b.innerHTML + " "+a.title;
}
}
}
}
if(a.className == "OtherVersion") { // class created by Template:OtherVersion (Modèle:AutreVersion in fr.ws)
p = a.title.indexOf("|");
pvers = document.getElementById("p-version");
if (pvers == null) {
c = document.getElementById("column-one");
c.innerHTML = c.innerHTML
+ "<div class=\"portlet\" id=\"p-version\">"
+ "<h5>Other versions</h5>"
+ "<div class=\"pBody\">"
+ "<ul>"
+ "</ul>"
+ "</div>";
pvers = document.getElementById("p-version");
}
e = pvers.getElementsByTagName("ul")[0];
e.innerHTML = e.innerHTML
+ "<li class=\"\"><a href='"
+ a.title.substr(0,p)
+ "'>" + a.title.substr(p+1,a.title.length-1)+ "</a> " +"</li>";
}
}
}
addOnloadHook(interwikiExtra);
/*****************************************************************
*** footnotes as tooltip
*** from it.wikipedia.org
*** inserted by [[user:-jkb-]]
******************************************************************/
addOnloadHook ( function ()
{
sups = document.getElementsByTagName("sup");
for (i=0; i<sups.length; i++)
{
note_id = sups[i].childNodes[0].href;
if (note_id && (note_id.indexOf("#") != -1))
{
note_id = document.getElementById(note_id.substr(note_id.indexOf("#")+1));
if (note_id)
if (document.all)
{
sups[i].title = note_id.innerText;
sups[i].childNodes[0].title = note_id.innerText;
}
else
{
sups[i].title = note_id.textContent;
}
}
}
})
/* </pre> */