MediaWici:Common.js
Sylwer: Ar ôl cyhoeddi, efallai y bydd rhaid i chi fynd heibio celc eich porwr er mwyn gweld y newidiadau.
- Firefox / Safari: Pwyswch Shift wrth glicio Ail-lwytho/Reload, neu pwyswch naill ai Ctrl-F5 neu Ctrl-R (⌘-R ar Mac);
- Google Chrome: Pwyswch Ctrl-Shift-R (⌘-Shift-R ar Mac)
- Internet Explorer: Pwyswch Ctrl wrth glicio Adnewyddu/Refresh, neu pwyswch Ctrl-F5.
- Opera: Pwyswch Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
/**
* Scripts imported from wikisource.org
*/
// Messages are configurable here
self.ws_messages = {
'optlist':'Display options',
'hide_page_numbers':'Hide page links',
'show_page_numbers':'Show page links',
'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':'Needs an OCR text layer',
'progress_L':'Source file is incorrect (missing pages, unordered pages, etc)',
'▲':'Return to the top of the page.',
'corr_list':"List of corrections performed on this page" ,
'corr_link':"Corrections" ,
'corr_one':"One typo </a> has been corrected." ,
'corr_many':" typos</a> have been corrected." ,
'corr_close':"Close." ,
'iwtrans':'Its text comes from',
'iwtrans2':'Its text comes from other Wikisource subdomains.'
};
// Dynamic layouts
if ( !self.ws_layouts ) {
self.ws_layouts = {};
}
self.ws_layouts['Layout 1'] = {
'#text-wrap':"",
'#text-container':"" ,
'#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;",
'.editsection':"display:none",
'#headertemplate':""
};
self.ws_layouts['Layout 2'] = {
'#text-wrap':"position:relative;margin-left:3em;margin-right:3em;",
'#text-container':"width:36em;margin:0px 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; right:37em;width:16em;text-indent:0em;text-align:right;",
'.editsection':"display:none",
'#headertemplate':""
};
self.ws_layouts['Layout 3'] = {
'#text-wrap':"margin-left:3em",
'#text-container':"position:relative; min-width:60em; float:left; width:100%; margin-right:-23em;" ,
'#text':"text-align:justify;margin-right:23em; text-indent:0em; padding-left:0px; padding-right:0px;width:auto; position:relative;",
'.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;",
'.editsection':"display:none",
'#headertemplate':"position:absolute; top:0em; right:-23em; width:21em;float:right; text-align:left;"
};
self.proofreadpage_add_container = true;
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
/*mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');*/ /*hasn't functioned in a long time */
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Corrections.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Dictionary.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');
// Mouse wheel zoom should work now for most browsers.
// If it does not work for you, set this to true in your javascript.
self.proofreadpage_disable_wheelzoom = false;
/**
* Allow descriptive labels next to sidebar language links using {{interwiki-info}}
* 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') {
// 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 Version';
}
}
else if(b.className == 'interwiki-' + a.id.substr(0, a.id.length-1)) {
count++;
if(a.id.charAt(a.id.length-1) == count) {
b.innerHTML = b.innerHTML + ' ' + a.title;
}
}
}
}
}
}
$(interwikiExtra);
/**
* 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 pr_index = document.getElementById('pr_index');
if(pr_index) return;
var q = document.getElementById('textquality');
var new_img;
if(q) {
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') {
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 link to the extension [[user:sanbeg]]
function pr_add_quality_buttons_link(){
if(typeof proofreadPageMessageStatus == 'undefined') return;
if( self.proofreadpage_no_quality_buttons ) return;
var ig = document.getElementById("wpWatchthis");
if( !ig ) return;
var f = document.createElement("span");
f.innerHTML = ' (<a href="/wiki/Help:Page Status">help</a>)';
ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling.nextSibling);
}
$(pr_add_quality_buttons_link);
/** Collapsible tables *********************************************************
*
* Description: Implements legacy classes for collapsible tables and Navigational boxes: 'collapsible', 'collapsed',
* 'innercollpase', 'outercollpase', 'autocollapse', 'Nav Frame', 'NavPic', 'NavContent', 'NavHead' and 'NavToggle'
* Maintainers:
*/
var autoCollapse = 2;
$(document).ready(function(){
mw.loader.using('jquery.makeCollapsible', function() {
// Collapsible tables
CollapsibleTables=$('table.collapsible');
var i=0;
CollapsibleTables.filter('table.autocollapse').each(function() {
i++;
if (i >= autoCollapse) {
$(this).addClass('mw-collapsed');
}
})
CollapsibleTables.filter('table.collapsed').addClass('mw-collapsed');
CollapsibleTables.filter('table.innercollapse').parent('.outercollapse').find('table.innercollapse').addClass('mw-collapsed');
CollapsibleTables.makeCollapsible();
//Collapsible Navigation boxes
NavFrames=$('div.NavFrame');
NavFrames.filter('.collapsed').addClass('mw-collapsed');
NavFrames.find('.NavPic, .NavContent').addClass('mw-collapsible-content');
NavFrames.each(function () {
if ($(this).find('.NavPic, .NavContent').length==0) {
$(this).wrapInner('<div class="mw-collapsible-content" />');
$(this).prepend($(this).find('.NavHead'));
} else {
var isCollapsed=false;
$(this).find('.NavPic, .NavContent').each(function () {
if ( this.style.display == 'none' ) {
isCollapsed = true;
}
})
if (isCollapsed) { $(this).addClass('mw-collapsed'); }
}
});
NavFrames.makeCollapsible();
NavFrames.each(function() {
$(this).children('.NavHead').append($(this).children(':first-child'));
})
})
})
/*
* port from [[:he:mediawiki:common.js]] for [[mediawiki:edittools]] -Steve
*/
/* פונקציה שמשמשת לאיפשור ניקוד ב[[מדיה ויקי:edittools]] */
function nikud(){
if (document.getElementById('edit-templates')!=null){
for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
if(a.className == "nikud") {
a.onclick=function(){insertTags('', this.title, '');return false;};
}
}
}
}
$(nikud);
/**
* withJS
*
* Allow to load custom scripts from the MediaWiki namespace without
* editing [[Special:Mypage/common.js]]
*
* Maintainer: [[User:Platonides]], [[User:Lupo]]
*/
var extraJS = mw.util.getParamValue('withJS');
// Leave here for backwards compatibility
(function (extraJS) {
if (!extraJS) {
return;
}
if (extraJS.match(/^MediaWiki:[^&<>=%#]*\.js$/)) {
// Disallow some characters in file name
importScript(extraJS);
} else {
// Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
$(function () {
mw.notify(extraJS + ' javascript not allowed to be loaded.', 'error');
});
}
})(extraJS);
/**
* Icons on the top right of the article.
* See also CSS
*
* @source: //www.mediawiki.org/wiki/Snippets/Top_icons
* @rev: 2
*/
jQuery( document ).ready( function( $ ) {
$( '.Top_icon_raw' )
.removeClass( 'Top_icon_raw' )
.addClass( 'Top_icon_dynamic' )
.prependTo( '#firstHeading' );
} );
/*Script to allow language links to Old Wikisource (http://wikisource.org) */
mw.loader.load('//en.wikisource.org/w/index.php?title=User:Doug/Multilingual-link.js&action=raw&ctype=text/javascript');