לדלג לתוכן

מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
נקודה ופסיק
סידור הזחה
שורה 4: שורה 4:
function importUserScript() {
function importUserScript() {
     var args = arguments;
     var args = arguments;
mw.loader.using('mediawiki.util', function() {
mw.loader.using('mediawiki.util', function() {
for (var arg = 0; arg < args.length; arg++) {
for (var arg = 0; arg < args.length; arg++) {
try {
try {
importScript( "MediaWiki:סקריפטים/" + args[arg]);
importScript( "MediaWiki:סקריפטים/" + args[arg] );
}
}
catch(e) {}
catch(e) {}
שורה 28: שורה 29:


if ( wgPageName == "עמוד_ראשי" || wgPageName == "שיחה:עמוד_ראשי" ) {
if ( wgPageName == "עמוד_ראשי" || wgPageName == "שיחה:עמוד_ראשי" ) {
importScript("MediaWiki:Mainpage.js");                              // שיפורים שונים בעמוד הראשי
importScript("MediaWiki:Mainpage.js");                              // שיפורים שונים בעמוד הראשי
if ( wgNamespaceNumber === 0 ) importScript("MediaWiki:Portals.js");  // פורטלים מתחלפים בעמוד הראשי
if ( wgNamespaceNumber === 0 ) importScript("MediaWiki:Portals.js");  // פורטלים מתחלפים בעמוד הראשי
}
}


שורה 46: שורה 47:
importScript('Mediawiki:Common.js/pgn.js'); // להצגת שחמט
importScript('Mediawiki:Common.js/pgn.js'); // להצגת שחמט
//importScript("MediaWiki:HelpLinks.js"); // הוספת מסגרת הפניית תשומת לב לדף השיחה של הערך + הסבר בדפי שיחה כיצד להוסיף פסקה חדשה לערך.
//importScript("MediaWiki:HelpLinks.js"); // הוספת מסגרת הפניית תשומת לב לדף השיחה של הערך + הסבר בדפי שיחה כיצד להוסיף פסקה חדשה לערך.
if (wgNamespaceNumber == 6)
 
try{mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js');}catch(e){} // surround with try/catch in case other server behaves badly.
if (wgNamespaceNumber == 6) {
try {
mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js');
}
catch(e) {} // surround with try/catch in case other server behaves badly.
}
// סקריפטים עבור אנונימיים ו/או חדשים
// סקריפטים עבור אנונימיים ו/או חדשים
if ( $.inArray("autoconfirmed",wgUserGroups)==-1 ) {
if ( $.inArray("autoconfirmed",wgUserGroups)==-1 ) {
importScript("MediaWiki:anonTalkLink.js"); // הצגת קישור לדף השיחה עבור אנונימיים, בעת קבלת הודעה
importScript("MediaWiki:anonTalkLink.js"); // הצגת קישור לדף השיחה עבור אנונימיים, בעת קבלת הודעה
importScript("MediaWiki:Autopurge.js"); // הוספת אפשרות לרענון אוטומטי על ידי אנונימיים, ללא מעבר בטופס
importScript("MediaWiki:Autopurge.js"); // הוספת אפשרות לרענון אוטומטי על ידי אנונימיים, ללא מעבר בטופס
importScript("MediaWiki:Navtip.js"); // הוספת התיבה "רוצה טיפ?" בצד למשתמשים אנונימיים
importScript("MediaWiki:Navtip.js"); // הוספת התיבה "רוצה טיפ?" בצד למשתמשים אנונימיים
}
}


// סקריפטים לדפי עריכה
// סקריפטים לדפי עריכה
if ( (wgAction == "edit" || wgAction == "submit") && !($('#wpTextbox1').prop( 'readonly' )) )
if ( (wgAction == "edit" || wgAction == "submit") && !($('#wpTextbox1').prop( 'readonly' )) ) {
{
importScript("MediaWiki:Edittoolbar.js"); // תוספות לסרגל העריכה
importScript("MediaWiki:Edittoolbar.js"); // תוספות לסרגל העריכה
importScript("MediaWiki:Templateslist.js"); // הצגת רשימת תבניות
importScript("MediaWiki:Templateslist.js"); // הצגת רשימת תבניות
importScript("MediaWiki:Nosaving.js"); // חיוב תצוגה מקדימה למשתמשים אנונימיים
importScript("MediaWiki:Nosaving.js"); // חיוב תצוגה מקדימה למשתמשים אנונימיים
importScript("MediaWiki:Edittools.js"); // שיפור התווים המיוחדים שמתחת לדף העריכה
importScript("MediaWiki:Edittools.js"); // שיפור התווים המיוחדים שמתחת לדף העריכה
importScript("MediaWiki:Ref2template.js"); //ref סקריפט שמשנה את התנהגות כפתור "הערה": הוספת תבנית הערה. במקום להוסיף תג
importScript("MediaWiki:Ref2template.js"); //ref סקריפט שמשנה את התנהגות כפתור "הערה": הוספת תבנית הערה. במקום להוסיף תג
}
}


// סקריפטים לעמודים ספציפיים
// סקריפטים לעמודים ספציפיים
if(wgCanonicalSpecialPageName == "Upload" )
if(wgCanonicalSpecialPageName == "Upload" ) {
importScript("MediaWiki:Licenses.js"); // שיפורים ברשיונות ושינויים בדף ההעלאה
importScript("MediaWiki:Licenses.js"); // שיפורים ברשיונות ושינויים בדף ההעלאה
}
// הופעת [[תבנית:דיון חדש במזנון]] לפני יצירת פסקה חדשה במזנון
// הופעת [[תבנית:דיון חדש במזנון]] לפני יצירת פסקה חדשה במזנון
if(mw.config.get('wgPageName')=='ויקיפדיה:מזנון')
if(mw.config.get('wgPageName')=='ויקיפדיה:מזנון') {
$(document).ready(function(){
$(document).ready(function(){
$('#ca-addsection a').attr('href',$('#ca-addsection a').attr('href')+'&editintro=תבנית:דיון_חדש_במזנון');
$('#ca-addsection a').attr('href',$('#ca-addsection a').attr('href')+'&editintro=תבנית:דיון_חדש_במזנון');
});
});
}


/** WikiMiniAtlas *******************************************************
/** WikiMiniAtlas *******************************************************
*
*
*  Description: WikiMiniAtlas is a popup click and drag world map.
*  Description: WikiMiniAtlas is a popup click and drag world map.
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
*              The script itself is located on meta because it is used by many projects.
*              The script itself is located on meta because it is used by many projects.
*              See [[Meta:WikiMiniAtlas]] for more information.
*              See [[Meta:WikiMiniAtlas]] for more information.
*  Maintainers: [[User:Dschwen]]
*  Maintainers: [[User:Dschwen]]
*/
*/
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
/*
/*
* Description: Redirects from /User:UserName/skin.js or .css to the user's actual skin page. Used (also) in {{תב|דף אישי}}.
* Description: Redirects from /User:UserName/skin.js or .css to the user's actual skin page. Used (also) in {{תב|דף אישי}}.
* Originally created by [[:en:User:Cacycle]]
* Originally created by [[:en:User:Cacycle]]
*/
*/
$(function ()
$(function () {
{
if (wgArticleId === 0 && wgUserName) {
if (wgArticleId === 0 && wgUserName) {
var slash = wgPageName.indexOf('/');
var slash = wgPageName.indexOf('/');
var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase();
var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase();
var test = 'משתמש:' + wgUserName.replace(/ /g, '_') + '/skin.';
var test = 'משתמש:' + wgUserName.replace(/ /g, '_') + '/skin.';
var ext = null;
var ext = null;
if (norm == test + 'js') ext = 'js';
if (norm == test + 'js') {
else if (norm == test + 'css') ext = 'css';
ext = 'js';
if (ext !== null) window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.' + ext);
} else if (norm == test + 'css') {
ext = 'css';
}
if (ext !== null) {
window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.' + ext);
}
}
}
$('#firstHeading span').attr('dir', null);
$('#firstHeading span').attr('dir', null);
שורה 102: שורה 114:
// create an event when "addportellink" is called, so scripts that manipulate menus ca readjust.
// create an event when "addportellink" is called, so scripts that manipulate menus ca readjust.
var oldFunc = mw.util.addPortletLink;
var oldFunc = mw.util.addPortletLink;
if (typeof oldFunc === 'function')
if (typeof oldFunc === 'function') {
mw.util.addPortletLink = function() {
mw.util.addPortletLink = function() {
var res = oldFunc.apply( this, arguments );
var res = oldFunc.apply( this, arguments );
שורה 108: שורה 120:
return res;
return res;
};
};
 
}
});
});




if ( wgPageName == "ויקיפדיה:בוקמרקלטים" || wgPageName == "שיחת_ויקיפדיה:בוקמרקלטים" ) {
if ( wgPageName == "ויקיפדיה:בוקמרקלטים" || wgPageName == "שיחת_ויקיפדיה:בוקמרקלטים" ) {
importScript("MediaWiki:/common.js/bookmarkletsInit.js");                              // דף הבוקמרקלטים
importScript("MediaWiki:/common.js/bookmarkletsInit.js");                              // דף הבוקמרקלטים
}
}


if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName === 'Search'){
if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName === 'Search') {
importScript("MediaWiki:SearchEngines.js"); // בחירה במנועי חיפוש שונים
importScript("MediaWiki:SearchEngines.js"); // בחירה במנועי חיפוש שונים
importScript('Mediawiki:Gadget-advanceSearch.js');
importScript('Mediawiki:Gadget-advanceSearch.js');
שורה 134: שורה 146:
*
*
*/
*/
var restrictionEdit=mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit');
var restrictionEdit = mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit');
if(restrictionEdit && restrictionEdit.length>0 && (restrictionEdit[0]=='sysop' || restrictionEdit[0]=='autoconfirmed' || restrictionEdit[0]=='autopatrol') && $('#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected').length===0 &&
if(restrictionEdit && restrictionEdit.length>0 && (restrictionEdit[0]=='sysop' || restrictionEdit[0]=='autoconfirmed' || restrictionEdit[0]=='autopatrol') && $('#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected').length===0 &&
($.inArray(mw.config.get('wgAction'),['view','submit'])+1))
($.inArray(mw.config.get('wgAction'),['view','submit'])+1)) {
{
var restrictionEditMapping = {
var restrictionEditMapping = {
'sysop': 'מוגן',
'sysop': 'מוגן',
שורה 145: שורה 156:
$.get(wgServer+mw.util.wikiScript('api'),{
$.get(wgServer+mw.util.wikiScript('api'),{
action: 'parse',format:'json',text: '{{'+restrictionEditMapping[restrictionEdit[0]]+'}}',prop: 'text',title: mw.config.get('wgPageName')
action: 'parse',format:'json',text: '{{'+restrictionEditMapping[restrictionEdit[0]]+'}}',prop: 'text',title: mw.config.get('wgPageName')
},function(data){
}, function(data) {
$(function(){
$(function() {
$('.printfooter').before($('<div>',{'class': 'plprotected',html:data.parse.text['*']}));
$('.printfooter').before($('<div>',{'class': 'plprotected',html:data.parse.text['*']}));
});
});

גרסה מ־11:45, 13 בספטמבר 2014

/* ייבוא סקריפטים */

/* פונקציה לייבוא סקריפט מ[[ויקיפדיה:סקריפטים]] */
function importUserScript() {
    var args = arguments;

	mw.loader.using('mediawiki.util', function() {
		for (var arg = 0; arg < args.length; arg++) {
			try {
				importScript( "MediaWiki:סקריפטים/" + args[arg] );
			}
			catch(e) {}
		}
	});
}

/* פונקציה הטוענת פונקציות בעת עליית הדף */
function addLoadEvent(e) {
	hookEvent( "load", e );
}

/* פונקציה לקבלת ערך של פרמטר משורת הכתובת */
function getParamValue( paramName ) {
	return mw.util.getParamValue(paramName);
}

mw.loader.using( 'mediawiki.util', function() {
	importScript("MediaWiki:Functions.js"); // פונקציות המצויות בשימוש בסקריפטים שונים

	if ( wgPageName == "עמוד_ראשי" || wgPageName == "שיחה:עמוד_ראשי" ) {
		importScript("MediaWiki:Mainpage.js");                               // שיפורים שונים בעמוד הראשי
		if ( wgNamespaceNumber === 0 ) importScript("MediaWiki:Portals.js");  // פורטלים מתחלפים בעמוד הראשי
	}

	// סקריפטים כלליים
	importScript("MediaWiki:UploadLink.js"); // שינוי קישורי ההעלאה
	importScript("MediaWiki:SubPagesLink.js"); // הוספת קישור לדפי המשנה של הדף הנוכחי
	importScript("MediaWiki:FeaturedInterwiki.js"); // תמיכה באינטרוויקי מומלץ ואיכותי
	importScript("MediaWiki:Navigationbar.js"); // תמיכה בקופסאות מוסתרות
	importScript("MediaWiki:Collapsetables.js"); // טבלאות מוסתרות
	importScript("MediaWiki:Tabs.js"); // תמיכה בלשוניות
	importScript("MediaWiki:SlideShow.js"); // מצגת תמונות
	importScript("MediaWiki:ImgToggle.js"); // החלפת תמונות, עבור [[תבנית:מפת מיקום]]
	importScript("MediaWiki:LoadingContent.js"); // הצגת טקסטים הנטענים באופן דינמי
	importScript("Mediawiki:Imagemap-Highlight.js"); // עבור [[תבנית:מפת תמונה]] עם סימון=כן
	importScript('Mediawiki:Common.js/interwiki-lang.js'); // הצגת שם השפה בעברית
	importScript('Mediawiki:Common.js/pgn.js'); // להצגת שחמט
	//importScript("MediaWiki:HelpLinks.js"); // הוספת מסגרת הפניית תשומת לב לדף השיחה של הערך + הסבר בדפי שיחה כיצד להוסיף פסקה חדשה לערך.

	if (wgNamespaceNumber == 6) {
		try {
			mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js');
		}
		catch(e) {} // surround with try/catch in case other server behaves badly.
	}
	// סקריפטים עבור אנונימיים ו/או חדשים
	if ( $.inArray("autoconfirmed",wgUserGroups)==-1 ) {
		importScript("MediaWiki:anonTalkLink.js"); // הצגת קישור לדף השיחה עבור אנונימיים, בעת קבלת הודעה
		importScript("MediaWiki:Autopurge.js"); // הוספת אפשרות לרענון אוטומטי על ידי אנונימיים, ללא מעבר בטופס
		importScript("MediaWiki:Navtip.js"); // הוספת התיבה "רוצה טיפ?" בצד למשתמשים אנונימיים
	}

	// סקריפטים לדפי עריכה
	if ( (wgAction == "edit" || wgAction == "submit") && !($('#wpTextbox1').prop( 'readonly' )) ) {
		importScript("MediaWiki:Edittoolbar.js"); // תוספות לסרגל העריכה
		importScript("MediaWiki:Templateslist.js"); // הצגת רשימת תבניות
		importScript("MediaWiki:Nosaving.js"); // חיוב תצוגה מקדימה למשתמשים אנונימיים
		importScript("MediaWiki:Edittools.js"); // שיפור התווים המיוחדים שמתחת לדף העריכה
		importScript("MediaWiki:Ref2template.js"); //ref סקריפט שמשנה את התנהגות כפתור "הערה": הוספת תבנית הערה. במקום להוסיף תג
	}

	// סקריפטים לעמודים ספציפיים
	if(wgCanonicalSpecialPageName == "Upload" ) {
		importScript("MediaWiki:Licenses.js"); // שיפורים ברשיונות ושינויים בדף ההעלאה
	}

	// הופעת [[תבנית:דיון חדש במזנון]] לפני יצירת פסקה חדשה במזנון
	if(mw.config.get('wgPageName')=='ויקיפדיה:מזנון') {
		$(document).ready(function(){
			$('#ca-addsection a').attr('href',$('#ca-addsection a').attr('href')+'&editintro=תבנית:דיון_חדש_במזנון');
		});
	}

	/** WikiMiniAtlas *******************************************************
	 *
	 *  Description: WikiMiniAtlas is a popup click and drag world map.
	 *               This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
	 *               The script itself is located on meta because it is used by many projects.
	 *               See [[Meta:WikiMiniAtlas]] for more information.
	 *  Maintainers: [[User:Dschwen]]
	 */
	mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
	/*
	 * Description: Redirects from /User:UserName/skin.js or .css to the user's actual skin page. Used (also) in {{תב|דף אישי}}.
	 * Originally created by [[:en:User:Cacycle]]
	 */
	$(function () {
		if (wgArticleId === 0 && wgUserName) {
			var slash = wgPageName.indexOf('/');
			var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase();
			var test = 'משתמש:' + wgUserName.replace(/ /g, '_') + '/skin.';
			var ext = null;
			if (norm == test + 'js') {
				ext = 'js';
			} else if (norm == test + 'css') {
				ext = 'css';
			}
			if (ext !== null) {
				window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.' + ext);
			}
		}
		$('#firstHeading span').attr('dir', null);

		// create an event when "addportellink" is called, so scripts that manipulate menus ca readjust.
		var oldFunc = mw.util.addPortletLink;
		if (typeof oldFunc === 'function') {
			mw.util.addPortletLink = function() {
				var res = oldFunc.apply( this, arguments );
				$( document ).trigger( 'new-portlet-link' );
				return res;
			};
		}
	});


	if ( wgPageName == "ויקיפדיה:בוקמרקלטים" || wgPageName == "שיחת_ויקיפדיה:בוקמרקלטים" ) {
		importScript("MediaWiki:/common.js/bookmarkletsInit.js");                               // דף הבוקמרקלטים
	}

	if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName === 'Search') {
		importScript("MediaWiki:SearchEngines.js"); // בחירה במנועי חיפוש שונים
		importScript('Mediawiki:Gadget-advanceSearch.js');
	}

	// Adding results from Wikidata to search, when a page doesn't exist:

	if (mw.config.get('wgCanonicalSpecialPageName') === 'Search' ||  (mw.config.get('wgArticleId') === 0 && mw.config.get('wgCanonicalSpecialPageName') === false)) {
		importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
	}

	/*
	 * Adds an automatic "{{תב|מוגן}}" or "{{תב|מוגן חלקית}}" template when the page is protected.
	 * You can use the {{תב|ללא הודעת הגנה אוטומטית}} to prevent the protection notice from being inserted.
	 *
	 * written by [[User:ערן]], [[User:Yonidebest]]
	 *
	 */
	var restrictionEdit = mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit');
	if(restrictionEdit && restrictionEdit.length>0 && (restrictionEdit[0]=='sysop' || restrictionEdit[0]=='autoconfirmed' || restrictionEdit[0]=='autopatrol') && $('#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected').length===0 &&
	($.inArray(mw.config.get('wgAction'),['view','submit'])+1)) {
		var restrictionEditMapping = {
			'sysop': 'מוגן',
			'autopatrol': 'הגנה מוגברת',
			'autoconfirmed': 'מוגן חלקית'
		};
		$.get(wgServer+mw.util.wikiScript('api'),{
			action: 'parse',format:'json',text: '{{'+restrictionEditMapping[restrictionEdit[0]]+'}}',prop: 'text',title: mw.config.get('wgPageName')
		}, function(data) {
			$(function() {
				$('.printfooter').before($('<div>',{'class': 'plprotected',html:data.parse.text['*']}));
			});

		});
	}
});

/* Use http redirect for Haaretz links until there's a less ad-hoc solution */
if (document.location.protocol==='https:') {
	$('a.external[href^="http://www.haaretz.co.il"]').each(function() {
		$(this).attr('href', 'http://tools.wmflabs.org/hewiki-tools/redirect.php?q=' + $(this).attr('href'));
	});
}