User:Technical 13/SandBox/Gadget-BugStatusUpdate.js/sandbox.js: Difference between revisions
Content deleted Content added
Technical 13 (talk | contribs) Testing ground... Recreate this process as a function so I can use it recursively if there is a failure. |
Technical 13 (talk | contribs) Add some information about the error message seen when this fails and only wrap the ajax call in its own function... |
||
Line 10:
*/
(function
var ids = [], target = 'https://bugzilla.wikimedia.org/jsonrpc.cgi';
Line 28:
}
// Make jsonp request
function bugStatus(){
dataType: 'jsonp',
success:
var color = {
"
},
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
var $item = $( '.mw-trackedTemplate' ).find( 'a[title^="bugzilla:' + data.result.bugs[b].id + '"]' );
var title = $( '.trakbug-' + data.result.bugs[b].id );
if( title ) {
title.text( data.result.bugs[b].summary );
}
if( $item ) {
// // Find child, if it exists.
$status = $item
.parent()
.next( 'p' )
.children( 'span' );
// //create the status element if it does not exist
if( $status.length === 0 ){
$item▼
.parent()▼
$( '<p />' ).append(
$( '<span />' ).css( statusProps )
}▼
// // Udpate the status element.▼
$item
.parent()
.
.
.css( 'color', color[data.result.bugs[b].status] || '#333333' )▼
▲ $( '<p />' ).append(
▲ }
▲// // Udpate the status element.
▲ $item
▲ .parent()
▲ .next( 'p' )
▲ .children( 'span' )
▲ .css( 'color', color[data.result.bugs[b].status] || '#333333' )
▲ }
}
}/* End of success:▼
▲ }
error: function(){▼
▲ }/* End of success:
/* Using this string with 49741 being a ticket I can't see:
▲ error: function(){
https://bugzilla.wikimedia.org/jsonrpc.cgi?method=Bug.get&id=158¶ms=[{%20%22ids%22:%20[35810,35909,300,48745,49741,54598],%22include_fields%22:[%22last_change_time%22,%22status%22,%20%22id%22,%20%22summary%22]}]
returns:
}*/▼
{"error":{"message":"You are not authorized to access bug #49741. To see this bug, you must first log in to an account with the appropriate permissions.","code":102},"id":"158","result":null}
*//*
▲ }*/
}
});
})(jQuery);
|