MediaWiki:Common.js: Revizyonlar arasındaki fark

İçerik silindi İçerik eklendi
Ruslik0 (konuşmaa | yardımnar)
rm test code
E THP (konuşmaa | yardımnar)
Değişiklik özeti yok
17. liniya:
else if (norm == test + 'css') ext = 'css';
if (ext != null) window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.' + ext);
}
/** extract a URL parameter from the current URL **********
* From [[en:User:Lupin/autoedit.js]]
*
* paramName : the name of the parameter to extract
*/
function getURLParamValue( paramName, url)
{
if (typeof (url) == 'undefined' || url === null) url = document.location.href;
var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
var m=cmdRe.exec(url);
if (m && m.length > 1) return decodeURIComponent(m[1]);
return null;
}
Satır 23 ⟶ 37:
* without editing [[Special:Mypage/monobook.js]]
*/
var extraJS = mw.util.getParamValuegetURLParamValue("withJS");
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
importScript(extraJS);
Satır 73 ⟶ 87:
*/
if (wgServer == "https://secure.wikimedia.org") {
mw.loader.load("//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400")
var metaBase = "https://secure.wikimedia.org/wikipedia/meta";
} else {
var metaBase = "https://meta.wikimedia.org";
}
importScriptURI(metaBase+"/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400")
/* Scripts specific to Internet Explorer */
Satır 125 ⟶ 144:
importStylesheet( 'MediaWiki:Common.css/WinFixes.css' );
}
/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
/** Interwiki links to featured articles ***************************************
Satır 196 ⟶ 229:
for ( var i = 0; i < Tables.length; i++ ) {
if ( $hasClass( Tables[i]).hasClass(, "collapsible" ) ) {
/* only add button and increment count if there is a header row to work with */
Satır 229 ⟶ 262:
for ( var i = 0; i < tableIndex; i++ ) {
if ( $hasClass( NavigationBoxes[i]).hasClass(, "collapsed" ) || ( tableIndex >= autoCollapse && $hasClass( NavigationBoxes[i]).hasClass(, "autocollapse" ) ) ) {
collapseTable( i );
}
else if ( $hasClass( NavigationBoxes[i]).hasClass(, "innercollapse" ) ) {
var element = NavigationBoxes[i];
while (element = element.parentNode) {
if ( $hasClass( element).hasClass(, "outercollapse" ) ) {
collapseTable ( i );
break;
Satır 272 ⟶ 305:
if (NavToggle.firstChild.data == NavigationBarHide) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if ($hasClass(NavChild).hasClass(, 'NavContent') || $hasClass(NavChild).hasClass(, 'NavPic')) {
NavChild.style.display = 'none';
}
Satır 281 ⟶ 314:
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if ($hasClass(NavChild).hasClass(, 'NavContent') || $hasClass(NavChild).hasClass(, 'NavPic')) {
NavChild.style.display = 'block';
}
Satır 297 ⟶ 330:
for (var i = 0; NavFrame = divs[i]; i++) {
// if found a navigation bar
if ($hasClass(NavFrame).hasClass(, "NavFrame")) {
indexNavigationBar++;
Satır 305 ⟶ 338:
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var isCollapsed = $hasClass( NavFrame).hasClass(, "collapsed" );
/*
* Check if any children are already hidden. This loop is here for backwards compatibility:
Satır 314 ⟶ 347:
*/
for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
if ( $(NavChild).hasClass( NavChild, 'NavPic' ) || $(NavChild).hasClass( NavChild, 'NavContent' ) ) {
if ( NavChild.style.display == 'none' ) {
isCollapsed = true;
Satır 322 ⟶ 355:
if (isCollapsed) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if ( $(NavChild).hasClass( NavChild, 'NavPic' ) || $(NavChild).hasClass( NavChild, 'NavContent' ) ) {
NavChild.style.display = 'none';
}
Satır 332 ⟶ 365:
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for(var j=0; j < NavFrame.childNodes.length; j++) {
if ($hasClass(NavFrame.childNodes[j]).hasClass(, "NavHead")) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild(NavToggle);
Satır 351 ⟶ 384:
*/
if (wgPageName == 'Baş yaprakAna_Sayfa' || wgPageName == 'DartışmaTartışma:Baş_yaprakAna_Sayfa')
addOnloadHook(function () {
addPortletLink('p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
'Tam liste', 'interwiki-completelist', 'Vikipedilerin tam listesi')
var nstab = document.getElementById('ca-nstab-main')
if (nstab && wgUserLanguage=='gagtr') {
while (nstab.firstChild) nstab = nstab.firstChild
nstab.nodeValue = 'BaşAna yaprakSayfa'
}
}
Satır 399 ⟶ 432:
}
addOnloadHook(uploadwizard_newusers);
/** IPv6 AAAA connectivity testing **/
var __ipv6wwwtest_factor = 100;
var __ipv6wwwtest_done = 0;
if ((wgServer != "https://secure.wikimedia.org") && (Math.floor(Math.random()*__ipv6wwwtest_factor)==42)) {
importScript("MediaWiki:Common.js/IPv6.js");
}
/** Magic editintros ****************************************************
Satır 415 ⟶ 457:
el.href += '&editintro=' + name;
}
if (wgNamespaceNumber == 0) {
addOnloadHook(function(){
if (document.getElementById('villagebox'))
addEditIntro('Template:Village_editintro');
});
addOnloadHook(function(){
if (document.getElementById('disambigbox'))
Satır 429 ⟶ 475:
cats = cats.getElementsByTagName('a');
for (var i = 0; i < cats.length; i++) {
if (cats[i].title == 'CategoryKategori:LivingYaşayan peopleinsanlar' || cats[i].title == 'CategoryKategori:Possibly living people') {
addEditIntro('Template:BLP_editintro');
break;
Satır 458 ⟶ 504:
// var permittedGroups = [ "sysop", "bureaucrat"]; // permit sysop, bureaucrat
// -------------------------------------------------------------------------------
var permittedGroups = [ "autoconfirmed*"];
Array.prototype.intersects = function() {
Satır 567 ⟶ 613:
function CustomizeModificationsOfSidebar() {
//removes [[Özel:Yükle]] from toolbox
ModifySidebar("remove", "araçlar", "DDosya yükle", "//gagtr.wikipedia.org/wiki/Özel:Yükle");
//adds [[Vikipedi:Yükle]] to toolbox
ModifySidebar("add", "araçlar", "Dosya yükle", "//gagtr.wikipedia.org/wiki/Vikipedi:Yükle");
}
Satır 819 ⟶ 865:
//******************************************************************
// Baş_yaprakdakiAna Sayfadaki Metabox için gereken kod. İlk fırsatta muadili bulunacak
//******************************************************************
Satır 884 ⟶ 930:
addOnloadHook(MetaCaixaInit);
//redirect redlinks for not autoconfirmed users
//</syntaxhighlight>
 
/**
/* Helper script for .hlist class in common.css
* redirect redlinks for not autoconfirmed users
* Maintainer: [[User:Edokter]]
* and hides "new article wizard" edit buttons for them
* +
* two CSS class for show and hide something
* from autoconfirmed users and not autoconfirmed users
* +
* don't allow page creation for with nonstandard characters (for persian)
*/
if(typeof iamsure === "undefined")
iamsure = false; // is a global variable and users can modify it on their vector.js or monobook.js
// to prevent from redirect from not correct title
function importantFunction() {
if( !/(secure\.wikimedia\.org|fa\.wikipedia\.org)/.test(window.location.href)){
return; // prevent to executed on other wikis
}
function extpar(par) {
var href = window.location.href;
return href.replace(RegExp(".*?[&?]" + par + "=([^&]*).*"), "$1").replace(href,"");
}
var isautoconfirmed = false, issysop = false, passednewarticlewizard = false;
if (typeof(wgUserGroups) == "object" && wgUserGroups) {
for (i = 0; i < wgUserGroups.length; i++) {
if (wgUserGroups[i] == "autoconfirmed") {
isautoconfirmed = true;
}
if (wgUserGroups[i] == "sysop") {
issysop = true;
}
}
}
if (!isautoconfirmed) {
var myQuery = ".new";
if ( $.client.profile(".noarticletext").lengthname !== 0'msie' ) {
/* Add pseudo-selector class to last child list items in IE 8 */
myQuery = "#ca-edit a"; // if we are on new page, do that function to fix create button instead redlinks
if ( $.client.profile().versionBase == '8' ) {
}
$( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
$(myQuery).each(function() {
.addClass( 'hlist-last-child' );
if(!(/\/wiki\//.test(this.href) || /title=.*\:/.test(this.href)))
this.href = this.href + encodeURI("&preload=الگو:ایجاد+مقاله/استخوان‌بندی&editintro=الگو:ایجاد+مقاله/ادیت‌نوتیس&summary=ایجاد+یک+مقاله+نو+از+طریق+ایجادگر&nosummary=&prefix=&minor=&create=درست+کردن+مقاله+جدید");
});
$(".isautoconfirmed").hide();
$(".notautoconfirmed").show();
importScript("MediaWiki:Gadget-signit.js");
}
/* Generate interpuncts and parens for IE < 8 */
else { // if was autoconfirmed
if ( $.client.profile().versionBase < '8' ) {
$(".isautoconfirmed").show();
$( '.hlist' ).find( 'dt + dd, dt + dt' ).prev()
$(".notautoconfirmed").hide();
.append( '<b>:</b> ' );
}
$( '.hlist' ).find( 'dd + dd, dd + dt, li + li' ).prev()
if (extpar("iamsure")!=="")
.append( '<b>·</b> ' );
iamsure = true;
$( '.hlist' ).find( 'dl dl, ol ol, ul ul' )
if (extpar("redlink") === "1" && wgAction == "edit" && wgNamespaceNumber === 0
.prepend( '( ' ).append( ') ' );
/*&& (isautoconfirmed || passednewarticlewizard) && (!iamsure)
&& extpar("redirected") === ""*/) {
function fixarticletitle(instr){ // a simple text cleaner, can improved by gadget-extraeditbutton codes later
for (i=0;i<10;i++) {
instr = instr.replace(RegExp("(" + "٠١٢٣٤٥٦٧٨٩"[i] + "|" + i + ")", "g"), "۰۱۲۳۴۵۶۷۸۹"[i]); // arabic and latin numbers
}
return instr.replace(/[ىي]/g, "ی")
.replace(/ك/g, "ک")
.replace(/:(?=[^\s])/g, ": ")
.replace(/([^\s])\(/, "$1 (") // look behind is not supported by javascript
.replace(/([\.،«»\:؛\sزرذدواژؤإأآءةa-zA-Z])\u200c/g, "$1")
.replace(/\u200c /g, " ")
.replace(/(\u200c*$|^\u200c*)/g, "")
.replace(/[\u200dـ]/g, "")
.replace(/\(\s(.*?)\s\)/g, "($1)")
.replace(/(ۀ|هٓ)/g, "هٔ")
.replace(/ابهام ؟زدایی/,/*n*/ "ابهام‌زدایی");
}
fixedtitle = fixarticletitle(wgTitle);
if (fixedtitle !== wgTitle) {
window.location.href = window.location.href.replace(
encodeURI(wgTitle.replace(/\s/g,"_")),
encodeURI(fixedtitle.replace(/\s/g,"_"))
)+"&redirected=1";
}
}
if(!issysop && wgTitle == "تابلوی اعلانات مدیران"){
$("#ca-edit a").attr("href", $("#thismonthlink > a").attr("href").replace("&section=new", ""));
}
}
 
//Fix Persian sorting
 
/** Bug fixed for persian sorting, see: [[m:Help:Sorting#Text]]
* and [[bugzilla:31137]]
*/
mw.config.set('tableSorterCollation', {'پ':'بي', 'چ' : 'جي', 'ژ': 'زي', 'ک':'قي', 'گ':'کي', 'ی':'وي'});
//</syntaxhighlight>
 
$( importantFunction );
 
//</syntaxhighlight>