מעדיעוויקי:Gadget-wikibugs-patrol.js

פון המכלול
קפיצה לניווט קפיצה לחיפוש

אַכטונג: נאכן היטן, ברויכט איר אפשר נאך אויסקרויזן דעם בראוזער'ס זאַפאַס צו זען די ענדערונגען.

  • פייערפוקס/סאפארי: האלט אראפ שיפט בשעת'ן דרוקן Reload, אדער דרוקט Ctrl-F5 אדער Ctrl-R (אויף א מאקינטאש ⌘-R)
  • גוגל כראם: דרוקט Ctrl-Shift-R (אויף א מאקינטאש ⌘-Shift-R)
  • אינטערנעט עקספלארער: האלט אראפ Ctrl בשעת'ן קליקן Refresh, אדער דרוקט Ctrl-F5
  • אפערע: גייט צו מעניו → שטעלונגען ( אפערע → פרעפערנצן אויף א מעק) און דערנאך צו פריוואטקייט & און זיכערהייט → רוימען בראוזער דאטא → בילדער און טעקעס אין זאפאס
if ( mw.config.get('wgPageName') === 'המכלול:באריכט_א_טעות' ) {
	$(function(){
	function reloadNotify(msg) {
		mw.notify(msg).done(function(){ window.location.reload(); });
	}
	function removeSection(section, basetimestamp, starttimestamp, summ) {
		var api = new mw.Api(), pagename = this.curPage;
		api.postWithToken('csrf', {
			action: 'edit',
			title: 'המכלול:באריכט א טעות',
			summary: summ,
			minor: 1,
			basetimestamp: basetimestamp,
			starttimestamp: starttimestamp,
			text: '',
			section: section
		}).done(function(d) {
			if (d && d.edit && d.edit.result == 'Success') {
				reloadNotify('אורכב בהצלחה');
			}
		});
	}

	function archiveToTalk(articleName, sectionTitle, content) {
		var talkPage = new mw.Title(articleName).getTalkPage(),
		newContent =  content.replace(/== .+? ==\n+/, '').replace(/\{\{\/מצב\|.+?\}\}/, '');
		return new mw.Api().post({action: 'edit', minor: 1, title: talkPage.getPrefixedText(), summary: 'העברת דיווח מהדף [[המכלול:באריכט א טעות]]', token: mw.user.tokens.get('csrfToken'), section: 'new', sectiontitle: sectionTitle, text: ':דיווח מהדף [[המכלול:באריכט א טעות]]\n' + newContent }).then(function(d){ mw.notify($('<a>', {href: talkPage.getUrl(), target: '_blank'}).text('אורכב בהצלחה')); });	
	}

	function archiveReport(e) {
			var summ = prompt('כותרת הדיווח:', 'דיווח שאורכב ב-{{ס:'+'#זמןמ:d xg Y}}');
			if(summ === null) return;
			var articleName = $(this).parents('h2').find('a:first').prop('title').replace(' (הדף אינו קיים)', ''),
			sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1],
			api = new mw.Api();
			
			api.get( {action:'query',prop:'revisions',titles:mw.config.get('wgPageName'), rvprop:'content|timestamp',rvsection:sectionNum, curtimestamp: 1}).done(function(data){
				for(var rv in data.query.pages)
				{
					var sectionText = data.query.pages[rv].revisions[0]['*'],
					basetimestamp = data.query.pages[rv].revisions[0].timestamp;
					if ((sectionText.indexOf('== [['+articleName+']] ==') !== 0) && (sectionText.indexOf('== [[:'+articleName+']] ==') !== 0)) {
						reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
					} else {
						if (sectionText.indexOf('{{#lst:')!=-1) {
							removeSection(sectionNum, basetimestamp ,data.curtimestamp, '/* '+ articleName +' */ ארכוב');
						} else {
							archiveToTalk(articleName, summ, sectionText).done(function(){removeSection(sectionNum, basetimestamp ,data.curtimestamp, '/* '+ articleName +' */ ארכוב'); });
						}
					}

				}
			});
			e.preventDefault();
	}

	function removeReport(e) {
			var summ = prompt('תקציר עריכה למחיקת הדיווח:');
			if(summ === null) return;
			var articleName = $(this).parents('h2').find('a:first').prop('title').replace(' (הדף אינו קיים)', ''),
			sectionNum = $(this).parent().find('a').attr('href').match(/section=(.*)/)[1],
			api = new mw.Api();
			api.get( {action:'query',prop:'revisions',titles:mw.config.get('wgPageName'), rvprop:'content|timestamp',rvsection:sectionNum, curtimestamp: 1}).done(function(data){
				for(var rv in data.query.pages)
				{
					var sectionText = data.query.pages[rv].revisions[0]['*'],
					basetimestamp = data.query.pages[rv].revisions[0].timestamp;
					if ((sectionText.indexOf('== [['+articleName+']] ==') !== 0) && (sectionText.indexOf('== [[:'+articleName+']] ==') !== 0)) {
						reloadNotify('הפסקה אינה קיימת עוד במקומה. מרענן את הדף');
					} else {
						removeSection(sectionNum, basetimestamp ,data.curtimestamp, summ);
					}
				}
			});
			e.preventDefault();
	}

		$('h2').each(function()
		{
			var archive = $('<a>ארכוב</a>').attr({href:'#'}).css({'font-size':'small', 'margin-right':'20px'}).click(archiveReport),
			    removeReportBtn = $('<a>הסרה</a>').attr({href:'#'}).css({'font-size':'small', 'margin-right':'20px'}).click(removeReport);
			$(this).find('.mw-editsection').append([archive, removeReportBtn]);
		});
	});
}