משתמש:Yonidebest/vector.js

מתוך ויקיפדיה, האנציקלופדיה החופשית

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
// All pages
//importScript('משתמש:yonidebest/scripts/mysubpages.js');   /* Adds link to my subpages after the to exit account button. */
//importScript('משתמש:yonidebest/monobook.js/dashfixer.js');    /* A Hebrew dash converter. */
//importScript('משתמש:yonidebest/monobook.js/templateSC.js');   /* Adds link to warn users on their talkpage in the diff page */
//importScript('משתמש:yonidebest/monobook.js/search.js');          /* Allows the use of shortcuts in the wiki search. */
//importScript('משתמש:yonidebest/monobook.js/customnav.js');       /* Adds custom links in a navbox above community navbox. */
//importScript('משתמש:yonidebest/monobook.js/archive.js');         /* Archives my talk page. */
//importScript('משתמש:yonidebest/monobook.js/newMsg.js');          /* Changes the border of the page when I recieve a new msg. */
//importScript('משתמש:yonidebest/monobook.js/move.js');            /* Adds a link for moving sections from one page to another. */
//disableReferencesCheck = true;    /* Disables MediaWiki:References.js. */
//var templatesList = "toolbar";   /* position of templates list */
//importScript('משתמש:yonidebest/monobook.js/colorProtected.js');  /* Colors the "edit" tab according to protection lvl. */
//importScript('משתמש:yonidebest/monobook.js/createDiffLink.js'); /* Add link to create diff link to current diff page. */
//importScript('משתמש:yonidebest/monobook.js/createSectionLink.js'); /* Add link to create sections links */
//importScript('משתמש:Yonidebest/monobook.js/showNonLast.js'); /* Filter contribution list */
//importScript('משתמש:Yonidebest/scripts/subpageLinks.js') /* add link for creating subapge */

// Wikipedia pages
if (wgNamespaceNumber == 4) {
 //importScript('משתמש:yonidebest/monobook.js/clearSandBox.js'); /* Adds a link to clear sand box. */
 //importScript('משתמש:yonidebest/monobook.js/checkpercentage.js'); /* Allow to check who's winning in vote pages. */
}

// upload page
if ( wgCanonicalSpecialPageName == "Upload" ) {
 //importScript('משתמש:Yonidebest/scripts/bypassCheckUploadInformationTemplate.js') /* bypass function in [[mediawiki:Licenses.js]]*/
}

// RC page
if (wgPageName == 'מיוחד:שינויים_אחרונים' || wgPageName == 'מיוחד:רשימת_המעקב') {
 //importScript('משתמש:yonidebest/monobook.js/highlightAnon.js');   /* Adds a colored background to anonymous edits in RC page. */
 //importScript('משתמש:yonidebest/scripts/anonRecentEditors.js');   /* Filters RC list, shows unaudited anon edits. */
}

// History pages
if (wgAction == 'history') {
 //importScript('משתמש:yonidebest/monobook.js/addSizes.js');        /* Adds added/removed byte in history page. */
 //importScript('משתמש:yonidebest/monobook.js/createDiffLink.js');  /* Adds link to create diff link to said page. */
 //importScript('משתמש:yonidebest/monobook.js/fixHistoryLinksIE.js');  /* Removes checked boxed in history page - IE fix. */
}

// user or user talk pages
if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
 //importScript('משתמש:yonidebest/monobook.js/editCounterTab.js'); /* add a tab with edit counter on user pages */
}

//mw.loader.load('http://127.0.0.1/wikipediatest.js'); // סקריפט לאח"מים בלבד

/* Allows to mark pages as patrolled from the Recentchanges or Watchlist page.
 *
 * Written by [[User:Yonidebest]], [[User:קיפודנחש]] and others
 */

if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'), ["Recentchanges", "Watchlist", "Recentchangeslinked", "Newpages"]) + 1) {
mw.loader.load('mediawiki.api');
mw.hook( 'wikipage.content' ).add(function() {
	function singlePatrol(revid, checkbox) {
		var api = new mw.Api();
		api.postWithToken('patrol', {action: 'patrol', revid: revid }).done( function(data, textStatus, jqXHR) {
			if (data && data.patrol) {
				mw.notify('העריכה בדף ' + data.patrol.title + ' סומנה כבדוקה');
				$(checkbox).remove();
			}
			else {
				var desc = (data && data.error && data.error.info) || '';
				mw.notify('<span style="color:red">אירעה שגיאה ' + desc + '</span>');
			}
		})
		.fail( function(jqXHR, textStatus, errorThrown) {
			mw.notify(jqXHR + '<br/>' + textStatus + '<br/>' + errorThrown);
		});
	}

	function multiplePatrol(articleName) {
		$('li.mw-line-odd, li.mw-line-even').each(function() {
			var a = $(this).find('a:Contains(קודמת), a:Contains(הבדל)').filter(function() { return /diff=\d+/.test($(this).attr('href')); } );
			if (!a.length)
				return;
			if (articleName == a[0].title) {
				var m = a.attr('href').match(/diff=(\d+)/);
				if ( ! m )
					return;
				var revid = m[1];
				var checkbox = $(this).find('input[type=checkbox]');
				if (!checkbox.length)
					return;
				var api = new mw.Api();
				api.postWithToken('patrol', {action: 'patrol', revid: revid }).done( function(data, textStatus, jqXHR) {
					if (data && data.patrol) {
						mw.notify( 'העריכה בדף ' + data.patrol.title + ' סומנה כבדוקה');
						$(checkbox[0]).remove();
						$(checkbox[1]).remove();
					}
					else {
						var desc = (data && data.error && data.error.info) || '';
						mw.notify('<span style="color:red">אירעה שגיאה ' + desc + '</span>');
					}
				})
				.fail( function(jqXHR, textStatus, errorThrown) {
					mw.notify(jqXHR + '<br/>' + textStatus + '<br/>' + errorThrown);
				});
			}
		});
	}

	function userPatrol(userName) {
		$('li.mw-line-odd, li.mw-line-even').each(function() {
			var a = $(this).find('a:Contains(קודמת), a:Contains(הבדל)').filter(function() { return /diff=\d+/.test($(this).attr('href')); } );
			if (!a.length)
				return;
			var bdi = $(this).find('bdi');
			if (!bdi.length)
				return;
			var currentUser = bdi.text();
			if (userName == currentUser) {
				var m = a.attr('href').match(/diff=(\d+)/);
				if ( ! m )
					return;
				var revid = m[1];
				var checkbox = $(this).find('input[type=checkbox]');
				if (!checkbox.length)
					return;
				var api = new mw.Api();
				api.postWithToken('patrol', {action: 'patrol', revid: revid }).done( function(data, textStatus, jqXHR) {
					if (data && data.patrol) {
						mw.notify( 'העריכה בדף ' + data.patrol.title + ' סומנה כבדוקה');
						$(checkbox[0]).remove();
						$(checkbox[1]).remove();
						$(checkbox[2]).remove();
					}
					else {
						var desc = (data && data.error && data.error.info) || '';
						mw.notify('<span style="color:red">אירעה שגיאה ' + desc + '</span>');
					}
				})
				.fail( function(jqXHR, textStatus, errorThrown) {
					mw.notify(jqXHR + '<br/>' + textStatus + '<br/>' + errorThrown);
				});
			}
		});
	}
    
	function addCheckbox(elem, abbr) {
		//alert(JSON.stringify(abbr, null, 4));
		if (!abbr.length)
			return;
		var a = elem.find('a:Contains(קודמת), a:Contains(הבדל)').filter(function() { return /diff=\d+/.test($(this).attr('href')); } );
		if (!a.length)
			return;
		var m = a.attr('href').match(/diff=(\d+)/);
		if ( ! m )
			return;
		var revid = m[1];
		abbr.before($('<input>', {'type': 'checkbox', 'title': 'סימון שינוי זה כבדוק'}).change(function() {singlePatrol(revid, this);}));
		var articleName = a[0].title;
		abbr.before($('<input>', {'type': 'checkbox', 'title': 'סימון כל השינויים בערך זה כבדוקים'}).change(function() {multiplePatrol(articleName);}));
		abbr.remove();
		var bdi = elem.find('bdi');
		if (!bdi.length)
			return;
		var userName = bdi.text();
		bdi.parent().before($('<input>', {'type': 'checkbox', 'title': 'סימון כל השינויים של משתמש זה כבדוקים'}).change(function() {userPatrol(userName);}));
	}

	$('li.mw-line-odd, li.mw-line-even').each(function() {
		addCheckbox($(this), $(this).find('abbr.unpatrolled'));
	});
	
	$('li.not-patrolled').each(function(){
		var a =  $(this).find('a[href*="oldid"]')
		if (!a.length)
			return;
		var m = a.attr('href').match(/oldid=(\d+)/);
		if ( ! m )
			return;
		var revid = m[1];
		a.before($('<input>', {'type': 'checkbox'}).change(function() {singlePatrol(revid, this);}));
	});
}); // document.ready
} // in recentchanges page..