MediaWiki:Common.js
Napomena: Nakon objave možda ćete trebati očistiti međuspremnik svog preglednika kako biste vidjeli promjene.
- Firefox / Safari: držite Shift i pritisnite Reload, ili pritisnite bilo Ctrl-F5 ili Ctrl-R (⌘-R na Macu)
- Google Chrome: pritisnite Ctrl-Shift-R (⌘-Shift-R na Macu)
- Internet Explorer / Edge: držite Ctrl i kliknite Refresh, ili pritisnite Ctrl-F5
- Opera: pritisnite Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
//<nowiki>
mw.loader.using( ['mediawiki.util', 'jquery.client'], function () {
/* Begin of mw.loader.using callback
*
* Scripts imported from wikisource.org
* see [[oldwikisource:Wikisource:Shared Scripts]] for details
*/
jQuery.getScript('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript', function() {
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:InterWikiTransclusion.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:DoubleWiki.js&action=raw&ctype=text/javascript');
} );
/**
* Poruke - config. messages
*/
self.ws_messages = {
'do':'Display options',
'optlist':'Display options',
'hide_page_numbers':'Hide page links',
'show_page_numbers':'Show page links',
'page_numbers_inline':'Page links within text',
'page_numbers_beside':'Page links beside text',
'layout':'Layout',
'author':'Author',
'translator':'Translator',
'editor':'Editor',
'publisher':'Publisher',
'place':'Place',
'volume':'Volume',
'school':'School',
'book':'Book',
'collection':'Collection',
'journal':'Journal or magazine',
'phdthesis':'Thesis, report',
'dictionary':'Dictionary',
'progress':'Progress',
'progress_T':'Done',
'progress_V':'To be validated',
'progress_C':'To be proofread',
'progress_MS':'Ready for Match & Split',
'progress_OCR':'Source file needs an OCR text layer',
'progress_L':'Source file is incorrect (missing pages, unordered pages, etc)',
'progress_X':'Pagelist needed (to verify file is complete and correct before commencing proofreading)',
'▲':'Return to the top of the page.',
'corr_list':'List of typos identified on this page',
'corr_link':'Typos Marked',
'corr_one':'One typo</a> has been marked.',
'corr_many':' typos</a> have been marked.',
'corr_close':'Close.',
'iwtrans':'Its text comes from',
'iwtrans2':'Its text comes from other Wikisource subdomains.',
'page_namespace_name': 'Page',
'page_trascluded_in': 'Page trascluded in:',
'text_number': 'Text',
'compare_with': 'Comparison with:',
'compare_texts': 'Compare texts'
};
// Dynamic layouts
if ( !self.ws_layouts ) {
self.ws_layouts = {};
}
self.ws_layouts['Layout 1'] = {
'#text-wrap':"position:relative; margin-left:3.0em;",
'#text-container':"position:relative;",
'#text':"",
'.sidenote-right':"float:right; margin:0.5em; padding:3px; border:solid 1px gray; max-width:9em; text-indent:0em; text-align:left;",
'.sidenote-left':"float:left; margin:0.5em; padding:3px; border:solid 1px gray; max-width:9em; text-indent:0em; text-align:left;",
'.mw-editsection':"display:none;",
'#headertemplate':""
};
self.ws_layouts['Layout 2'] = {
'#text-wrap':"position:relative; margin-left:3.0em; margin-right:3.0em;",
'#text-container':"position:relative;width:36em; margin:0 auto 0 auto; font-family:Georgia,serif;",
'#text':"text-align:justify;",
'.sidenote-right':"position:absolute; left:37em; width:16em; text-indent:0em; text-align:left;",
'.sidenote-left':"position:absolute; left:37em; width:16em; text-indent:0em; text-align:left;",
'.mw-editsection':"display:none;",
'#headertemplate':"font-family:sans-serif;"
};
self.ws_layouts['Layout 3'] = {
'#text-wrap':"position:relative; margin-left:3.0em;",
'#text-container':"position:relative; min-width:60em; float:left; width:100%; margin-right:-23em;",
'#text':"position:relative; text-align:justify; margin-right:23em; text-indent:0em; padding-left:0px; padding-right:0px; width:auto;",
'.sidenote-right':"position:absolute; right:-10em; width:9em; background-color:#eeeeee; text-indent:0em; text-align:left;",
'.sidenote-left':"position:absolute; right:-10em; width:9em; background-color:#eeeeee; text-indent:0em; text-align:left;",
'.mw-editsection':"display:none;",
'#headertemplate':"position:absolute; top:0em; right:-23em; width:21em; float:right; text-align:left;"
};
self.ws_layouts['Proposed Layout'] = {
'#text-wrap':"position:relative; margin-left:3.00em;",
'#text-container':"position:relative; margin-right:-20em; min-width:60em; width:100%;",
'#text':"position:relative; width:auto; margin-right:20em; padding-right:0px; padding-left:0px; text-indent:0.00em; text-align:justify;",
'.sidenote-right':"position:absolute; right:-10em; width:9.00em; background-color:#eeeeee; text-indent:0.00em; text-align:left;",
'.sidenote-left':"position:absolute; right:-10em; width:9.00em; background-color:#eeeeee; text-indent:0.00em; text-align:left;",
'.mw-editsection':"display:none;",
'#headertemplate':"position:relative; font-family:sans-serif; margin-bottom:1.33em;"
};
/* End of mw.loader.using callback */
} );
/** JSconfig (old version, to be replaced soon) ************
* Global configuration options to enable and disable specific
* script features from [[MediaWiki:Common.js]]
* Override these default settings in your [[Special:Mypage/monobook.js]]
* for Example: JSconfig.loadAutoInformationTemplate = false;
*
* Maintainer: [[User:Dschwen]]
*/
var JSconfig_old =
{
loadAutoInformationTemplate : true,
specialSearchEnhanced : true,
subPagesLink : true,
attributeSelf : true,
userUploadsLink : true
}
// Scripts for Special:Upload have been moved to [[MediaWiki:Upload.js]]
if ( (mw.config.get('wgPageName') == 'Special:Upload') || (mw.config.get('wgPageName') == 'Posebno:Upload') )
{
importScript( 'MediaWiki:Upload.js' );
}
/*HERE STARTS THE WORKING-CODE OF "METABOXES"*/
/* Funcionament de la Plantilla:Metacaixa
Implementat per: Usuari:Peleguer.
Actualitzat per Joanjoc seguint les indicacions d'en Martorell
*/
function MetaCaixaInit(){
//S'executa al carregar-se la pàgina, si hi ha metacaixes,
// s'assignen els esdeveniments als botons
//alert("MetaCaixaInit");
var i=0 //Inicialitzem comptador de caixes
for (i=0;i<=9;i++){
var vMc = document.getElementById("mc"+i);
if (!vMc) break;
//alert("MetaCaixaInit, trobada Metacaixa mc"+i);
var j=1 //Inicialitzem comptador de botons dins de la caixa
var vPsIni = 0 //Pestanya visible inicial
for (j=1;j<=9;j++){
var vBt = document.getElementById("mc"+i+"bt"+j);
if (!vBt) break;
//alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'esdeveniment onclick
//alert (vBt.className);
if (vBt.className=="mcBotoSel") vPsIni=j; //Si tenim un botó seleccionat, en guardem l'index
}
//alert ("mc="+i+", ps="+j+", psini="+vPsIni );
if (vPsIni == 0) { //Si no tenim cap botó seleccionat, n'agafem un aleatòriament
vPsIni = 1+Math.floor((j-1)*Math.random()) ;
//alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_");
document.getElementById("mc"+i+"ps"+vPsIni).style.display = "block";
document.getElementById("mc"+i+"ps"+vPsIni).style.visibility = "visible";
document.getElementById("mc"+i+"bt"+vPsIni).className="mcBotoSel";
}
}
}
function MetaCaixaMostraPestanya(){
//S'executa al clicar una pestanya,
//aquella es fa visible i les altres s'oculten
var vMcNom = this.id.substr(0,3); //A partir del nom del botó, deduïm el nom de la caixa
var vIndex = this.id.substr(5,1); //I l'index
var i=1
for (i=1;i<=9;i++){ //busquem totes les pestanyes d'aquella caixa
//alert(vMcNom+"ps"+i);
var vPsElem = document.getElementById(vMcNom+"ps"+i);
if (!vPsElem) break;
if (vIndex==i){ //Si és la pestanya bona la mostrem i canviem la classe de botó
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById(vMcNom+"bt"+i).className="mcBotoSel";
} else { //Sinó, l'ocultem i canviem la classe de botó
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById(vMcNom+"bt"+i).className="mcBoto";
}
}
return false; //evitem la recàrrega de la pàgina
}
$(MetaCaixaInit);
/*HERE FINISHES THE WORKING-CODE OF "METABOXES"*/
function proofreadpage_add_ocr(){
if(self.proofreadpage_disable_ocr) return;
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');
}
$(proofreadpage_add_ocr);
// -------------------------------------------------------------------------------
// Force Preview JavaScript code - Start
//
// To allow any group to bypass being forced to preview,
// enter the group name in the permittedGroups array.
// E.g.
// var permittedGroups = []; // force everyone
// var permittedGroups = [ "user"]; // permit logged-in users
// var permittedGroups = [ "sysop", "bureaucrat"]; // permit sysop, bureaucrat
// -------------------------------------------------------------------------------
var permittedGroups = [ "user"];
function forcePreview()
{
if( mw.config.get('wgAction') != "edit") return;
if( mw.config.get('wgUserGroups') === null) {
mw.config.set('wgUserGroups', []);
}
if ( mw.config.get( "wgUserGroups" ).filter(function(group) {
return permittedGroups.indexOf(group) > -1;
}).length ) return;
var saveButton = document.getElementById("wpSave");
if( !saveButton )
return;
saveButton.disabled = true;
saveButton.value = "Sačuvaj stranicu (pritisnite Prikaži)";
saveButton.style.fontWeight = "normal";
document.getElementById("wpPreview").style.fontWeight = "bold";
}
$(forcePreview);
/**********************
*** Quality indicators on "article" tab
*** by [[user:ThomasV]]
**********************/
// return src for icon given percentage
function icon_src(t){
var src='//upload.wikimedia.org/wikipedia/commons/';
switch(t){
case '0%': src+='8/8f/00'; break;
case '25%': src+='5/5b/25'; break;
case '50%': src+='3/3a/50'; break;
case '75%': src+='c/cd/75'; break;
case '100%': src+='6/64/100'; break;
}
return src + '%25.png';
}
// add indicator
function pageQuality() {
var a = document.getElementById('ca-nstab-main');
if(!a) 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(mw.config.get('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);
}
}
}
}
$(pageQuality);
/**********************
*** Add quality buttons on edit view
*** by [[user:ThomasV]]
**********************/
// set edit summary, add {{Kakvoća teksta}} to editbox
function addQuality(form, value) {
var text = '';
switch(value) {
// these should be the same as in {{Kakvoća teksta}}, etc.
case '25%': text = 'Tekst se uređuje'; break;
case '50%': text = 'Tekst je upotpunjen'; break;
case '75%': text = 'Tekst je provjeren i ispravljen'; break;
case '100%': text = 'Tekst je provjeren od strane više suradnika'; break;
}
form.elements['wpSummary'].value = '/* ' + text + ' */';
if(mw.config.get('wgCanonicalNamespace') == 'Page') {
s = form.elements['headerTextbox'].value;
s = s.replace(/\{\{PageQuality\|.*?\}\}/gi, '');
form.elements['headerTextbox'].value = '{{PageQuality|' + value + '}}' + s;
}
else {
s = form.elements['wpTextbox1'].value;
s = s.replace(/\{\{Kakvoća teksta\|.*?\}\}/gi, '');
form.elements['wpTextbox1'].value = '{{Kakvoća teksta|' + value + '}}' + s;
}
}
// add buttons below edit box
function addQualityButtons() {
if(mw.config.get('wgNamespaceNumber') != 0) {
return;
}
var ig = document.getElementById('wpWatchthis');
if(ig) {
var f = document.createElement('span');
f.innerHTML =
' <input type="radio" name="quality" value="25%" onclick="addQuality(this.form, this.value);"><img src="'+icon_src('25%')+'">'
+'<input type="radio" name="quality" value="50%" onclick="addQuality(this.form, this.value);"><img src="'+icon_src('50%')+'">'
+'<input type="radio" name="quality" value="75%" onclick="addQuality(this.form, this.value);"><img src="'+icon_src('75%')+'">'
+'<input type="radio" name="quality" value="100%" onclick="addQuality(this.form, this.value);"><img src="'+icon_src('100%')+'">';
ig.parentNode.insertBefore(f, ig.nextSibling.nextSibling.nextSibling)
}
}
$(addQualityButtons);
// </nowiki>