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 bugStatus($){
var ids = [], target = 'https://bugzilla.wikimedia.org/jsonrpc.cgi';
Line 28:
}
// Make jsonp request
function bugStatus(){
$.ajax({
url: target,
dataType url: 'jsonp'target,
dataType: 'jsonp',
data: getParams( ids ),
success data: function getParams( dataids ) {,
success: varfunction color( =data ) {
var color = {
"RESOLVED": "green",
"CRITICALRESOLVED": "redgreen",
}, "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
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()
.nextparent( 'p' )
$( '<p />' ).append(
$( '<p />' ).append(
$( '<span />' ).css( statusProps )
.childrentext( 'spanStatus' )
} )
} );
}
// // Udpate the status element.
$item
.parent()
.parentnext( 'p' )
.appendchildren( 'span' )
.css( 'color', color[data.result.bugs[b].status] || '#333333' )
$( '<p />' ).append(
$.text( '<span />' )data.css( statusPropsresult.bugs[b].status );
.text($status 'Status'= )null;
) }
);}
}
// // 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;
}
}
}/* 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&params=[{%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);