MediaWiki:Gadget-BugStatusUpdate.js
This page is loaded as a part of the BugStatusUpdate gadget, used by 7,738 users. |
/* * Bug Status Update Gadget * * Authors: * Written by Rob Moen (robm). * Ported to Phabricator by Matthew Flaschen (Mattflaschen (WMF)) * * Description: * Finds and updates bug status templates on a page. * Makes 1 JSONP request to phabricator-bug-status API (maintained by Matthew Flaschen) * (which passes the request to Phabricator's Conduit API) * Source: [[mw:User:Robmoen/bugStatusUpdate.js]] */( function( $ ){varids = [],target = 'https://tools.wmflabs.org/phabricator-bug-status/queryTasks';var getParams = function( ids ) {return $.param( { ids: JSON.stringify( ids ) } );};// Get the Phabricator task id numbers on the page// The template should provide a data attribute, for simplicity and probably better performance. There// should also be a class, so it could quickly be found. E.g.// data-phabricator-task="123" class="trakfab ..." ...// This could then be selected easily, and the number could be accessed with .data( 'phabricatorTask' )$( '.mw-trackedTemplate' ).find( 'a[title^="phabricator:T"]' ).each( function() {var titleMatch = $( this ).attr( 'title' ).match( /phabricator:T(\d*)/ );if ( titleMatch !== null ) {ids.push( parseInt( titleMatch[1], 10 ) );}});// Do not query if no ids were foundif ( !ids.length ) {return;}// Make jsonp$.ajax( {url: target,dataType: 'jsonp',timeout: 5000, // Give up if Tool Labs is being slow todaystatusCode: { 500: function () { /* Tool Labs has failed, nothing to do here */ } },data: getParams( ids ),success: function ( data ) {varcolor = {"resolved": "green"},phid, taskInfo, taskNumber, selector,trackedTemplate, $taskLink, $title, $item,$status;for( phid in data ) {taskInfo = data[phid];taskNumber = taskInfo.id;// Find the right task to updateselector = '.mw-trackedTemplate a[title^="phabricator:T' + taskNumber + '"]';$taskLink = $( selector );$title = $taskLink.find( '.trakfab-T' + taskNumber );if ( $title ) {$title.text( taskInfo.title );}$item = $taskLink.closest( '.mw-trackedTemplate' );if( $item ) {// Find child, if exists// This is very fragile; this needs a class.$status = $( '.tracked-closure' );// Create the status element if it does not existif( $status.length === 0 ) {$status = $( '<span></span>' ).addClass('tracked-closure');$item.append( '<br>', $status );}// Update the status element// This matches Template:Tracked itself, where only resolved has a color// defined for Phabricator (everything else is black).$status.text( taskInfo.statusName ).css( 'color', color[taskInfo.status] || 'black' );}}}} );})( jQuery );
🔥 Top keywords: Akademia e Shkencave e RPS te ShqiperiseAlexandria Ocasio-CortezBilderberg GroupCristiano RonaldoDong XiaowanMinecraftOperation GladioPrimal cutRiot FestStrictly Come Dancing (series 7)Main PageSpecial:SearchDonald TrumpWikipedia:Featured picturesLuka DončićCleopatraProsecution of Donald Trump in New YorkDeaths in 2024Kyrie IrvingStormy DanielsDrew Gordon2024 South African general electionYouTube2024 Indian general electionJuan MerchanFuriosa: A Mad Max SagaProject 2025EminemInughuit2024 ICC Men's T20 World CupKepler's Supernova.xxxMichael FinleyStormy Daniels–Donald Trump scandalJason KiddDallas MavericksEric (miniseries)Neatsville, KentuckyThe First OmenCivil War (film)Todd BlancheAlesha DixonPortal:Current eventsXXX (2002 film)Michael Cohen (lawyer)List of digital camera brandsBiggest ball of twine2024 United States presidential electionList of NBA champions