ميډياويکي:Gadget-BugStatusUpdate.js

د ويکيپېډيا، وړیا پوهنغونډ له خوا

د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئيادښت: د غوره توبونو د خوندي کولو وروسته، خپل د کتنمل (بروزر) ساتل شوې حافظه تازه کړی.د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئ.

  • فايرفاکس/ سفري: په دې کتنمل کې د Reload د ټکوهلو په وخت د Shift تڼۍ نيولې وساتی، او يا هم Ctrl-F5 يا Ctrl-Rتڼۍ کېښکاږۍ (په Apple Mac کمپيوټر باندې ⌘-R کېښکاږۍ)
  • گووگل کروم: په دې کتنمل کې د Ctrl-Shift-R تڼۍ کېښکاږۍ (د مک لپاره ⌘-Shift-R)
  • انټرنټ اېکسپلورر: په دې کتنمل کې د Refresh د ټکوهلو په وخت کې د Ctrl تڼۍ کېښکاږلې ونيسۍ، او يا هم د Ctrl-F5 تڼۍ کېښکاږۍ
  • اوپرا: په دې کتنمل کې د خپل براوزر ساتل شوې حافظه پدې توگه سپينولی شی Tools→Preferences
لاسوند[جوړول]
/*  * Bug Status Update Gadget * Author: Rob Moen (robm) * Description: *  Finds and updates bug status templates on a page.  *  Makes 1 JSONP request to Bugzilla JSON RPC api. * Source: [[mw:User:Robmoen/bugStatusUpdate.js]] */   (function($){ 	var		ids = [], 			target = 'https://bugzilla.wikimedia.org/jsonrpc.cgi';   	//ugly way to compose the request parameters. though, bugzilla is happy with it 	var getParams = function (ids) { 		return 'method=Bug.get&id=158&params=[{ "ids": ['+ ids.join(',') +'],"include_fields":["last_change_time","status", "id", "summary"]}]'; 	};   	//get the bug id numbers on the page 	$('.mw-trackedTemplate').each(function() { 		var title = $(this).find('a[title^="bugzilla:"]').attr('title'); 		ids.push(title.split(':')[1]); 	});          // Do not query if no ids were found        if (!ids.length) {                return;        }   	//make jsonp 	$.ajax({ 		url: target, 		dataType:'jsonp', 		data: getParams(ids), 		success: function (data) {   			var		color = { 						"RESOLVED": "green", 						"CRITICAL": "red" 					}, 					statusProps = { 						'font-weight': 'bold', 						'font-size': '1.5em', 						'text-transform': 'uppercase' 					};   			if(data.result.bugs) { 				for(var b in data.result.bugs) { 					//find the right bug to update 					$item = $('.mw-trackedTemplate') 						.find('a[title^="bugzilla:'+data.result.bugs[b].id+'"]'); 					title = $('#trakbug-'+data.result.bugs[b].id)   					if(title) { 						title.text( data.result.bugs[b].summary ); 					}     					if($item) { 						//find child, if exists 						$status = $item 							.parent() 							.next('p') 							.children('span'); 						//create the status element if it does not exist 						if($status.length === 0){ 							$item 								.parent() 								.parent() 								.append( 									$('<p />').append( 										$('<span />').css(statusProps) 											.text('Status') 									) 								); 						} 						//udpate the status element 						$item 							.parent() 							.next('p') 							.children('span') 							.css('color', color[data.result.bugs[b].status] || '#333333') 							.text(data.result.bugs[b].status);	 						$status = null;   					} 				} 			} 		} 	});   })(jQuery);