מדיה ויקי:Gadget-IsBlock.js: הבדלים בין גרסאות בדף
אין תקציר עריכה |
מ 65 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-IsBlock.js יובאו |
||
| (10 גרסאות ביניים של 5 משתמשים אינן מוצגות) | |||
| שורה 1: | שורה 1: | ||
$( | $( function() { | ||
if ($( '.blockRequestUserName ').length === 0) return; | |||
function | |||
if ($( '.blockRequestUserName ').length | |||
var list = {}; | var list = {}; | ||
| שורה 33: | שורה 14: | ||
// filter all anons to one list, and registered to another. | // filter all anons to one list, and registered to another. | ||
var anons = Object.keys(list).filter( mw.util.isIPAddress ); | var anons = Object.keys(list).filter( mw.util.isIPAddress ); | ||
var registered = Object.keys(list).filter( u | var registered = Object.keys(list).filter( function(u) { return !mw.util.isIPAddress(u) } ); | ||
// construct an api object to be used below | // construct an api object to be used below | ||
| שורה 39: | שורה 20: | ||
// start sending api calls. for anons ("bkip" parameter), we can only ask one at a time. | // start sending api calls. for anons ("bkip" parameter), we can only ask one at a time. | ||
anons.forEach( anon | anons.forEach( function(anon) { | ||
api.get( { | api.get( { | ||
list: 'blocks', | list: 'blocks', | ||
| שורה 57: | שורה 38: | ||
.done( reportBlocks ); | .done( reportBlocks ); | ||
} | } | ||
} | |||
// when query returns, see if there are any blocks, and if there are, add the block marker. | |||
// note that list[user] is an array of all the spans in the page requesting to block this user. | |||
// typically this array will be of length 1, but it can be more. | |||
function reportBlocks( data ) { | |||
if (data && data.query && data.query.blocks ) | |||
data.query.blocks.forEach( function(block) { | |||
var user = decodeURIComponent( block.user ); // the api returns the user name encoded. | |||
addBlockedMarker( list[user] || [], block.by ); | |||
}); | |||
} | |||
function addBlockedMarker( spans, by ) { | |||
spans.forEach( function(span) { | |||
span | |||
.text(' | חסומ/ה') | |||
.attr('title', 'נחסמ/ה על ידי ' + by); | |||
}); | |||
} | |||
}); | }); | ||