User:Monster Domosed/common.js: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 36: | Line 36: | ||
function renderWidget($root, items) { | function renderWidget($root, items) { | ||
$root. | // Remove all existing list items, including skeleton rows | ||
$root.children().remove(); | |||
items.forEach(function (item, index) { | items.forEach(function (item, index) { | ||
| Line 87: | Line 88: | ||
function loadRecentEdits($root) { | function loadRecentEdits($root) { | ||
var limit = parseInt($root.data('limit'), 10) || 5; | |||
return new mw.Api().get({ | |||
action: 'query', | |||
list: 'recentchanges', | |||
rcprop: 'title|timestamp|user|ids|flags', | |||
rctype: 'edit|new', | |||
rcnamespace: 0, | |||
rclimit: limit | |||
}).then(function (data) { | |||
var items = []; | |||
if (data && data.query && data.query.recentchanges) { | |||
items = data.query.recentchanges; | |||
} | |||
renderWidget($root, items); | |||
// Data loaded successfully, so this portlet is no longer empty | |||
$root.closest('.mw-portlet').removeClass('emptyPortlet'); | |||
}); | |||
} | |||
function initWidget($root) { | function initWidget($root) { | ||