MediaWiki:Common.js: Revizyonlar arasındaki fark

İçerik silindi İçerik eklendi
E THP (konuşmaa | yardımnar)
Değişiklik özeti yok
E THP (konuşmaa | yardımnar)
Değişiklik özeti yok
926. liniya:
addOnloadHook(MetaCaixaInit);
redirect redlinks for not autoconfirmed users
 
/**
* redirect redlinks for not autoconfirmed users
* 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 ($(".noarticletext").length !== 0) {
myQuery = "#ca-edit a"; // if we are on new page, do that function to fix create button instead redlinks
}
$(myQuery).each(function() {
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");
}
else { // if was autoconfirmed
$(".isautoconfirmed").show();
$(".notautoconfirmed").hide();
}
if (extpar("iamsure")!=="")
iamsure = true;
if (extpar("redlink") === "1" && wgAction == "edit" && wgNamespaceNumber === 0
/*&& (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>