(Criou a página com "//<nowiki> →* * Adds a recent changes widget to the sidebar * * @author JaydenKieran: 'use strict'; ; (function($, mw) { var $prependTo var $rcContainer var recentChanges var $recentChangesDOM function init() { $prependTo = $('#p-Navigation') var api = new mw.Api() // Build our container $rcContainer = $('<nav>') .addClass('vector-menu vector-menu-portal portal') .attr('id', 'p-Recent...") |
Sem resumo de edição Etiqueta: Revertido |
||
Linha 13: | Linha 13: | ||
var recentChanges | var recentChanges | ||
var $recentChangesDOM | var $recentChangesDOM | ||
var $showMore | |||
function init() { | function init() { | ||
Linha 23: | Linha 24: | ||
.attr('id', 'p-RecentChanges') | .attr('id', 'p-RecentChanges') | ||
.append( | .append( | ||
$('<h3>').text(' | $('<h3>').text('Mudanças recentes') | ||
) | ) | ||
Linha 34: | Linha 35: | ||
rcprop: "title|timestamp|sizes|user", | rcprop: "title|timestamp|sizes|user", | ||
rcnamespace: 0, | rcnamespace: 0, | ||
rclimit: " | rclimit: "5", | ||
rctype: "edit|new", | rctype: "edit|new", | ||
rcshow: "!bot", | rcshow: "!bot", | ||
Linha 67: | Linha 68: | ||
}) | }) | ||
} else { | } else { | ||
$recentChangesDOM = $('<p>').text(' | $recentChangesDOM = $('<p>').text('Sem mudanças recentes.') | ||
} | } | ||
Edição das 19h54min de 1 de julho de 2022
//<nowiki>
/**
* Adds a recent changes widget to the sidebar
*
* @author JaydenKieran
*/
'use strict';
;
(function($, mw) {
var $prependTo
var $rcContainer
var recentChanges
var $recentChangesDOM
var $showMore
function init() {
$prependTo = $('#p-Navigation')
var api = new mw.Api()
// Build our container
$rcContainer = $('<nav>')
.addClass('vector-menu vector-menu-portal portal')
.attr('id', 'p-RecentChanges')
.append(
$('<h3>').text('Mudanças recentes')
)
// Add the container to the sidebar
$prependTo.after($rcContainer)
api.get({
action: "query",
list: "recentchanges",
rcprop: "title|timestamp|sizes|user",
rcnamespace: 0,
rclimit: "5",
rctype: "edit|new",
rcshow: "!bot",
rctoponly: 1,
format: "json"
})
.done(function(data) {
if (data.query && data.query.recentchanges) {
recentChanges = data.query.recentchanges
}
if (recentChanges.length > 0) {
var placeholderTime = 1;
$recentChangesDOM = recentChanges.map(function(rc) {
placeholderTime += Math.floor(Math.random() * 10);
return $('<div>').addClass('rc-sidebar-item').append(
$('<a>')
.addClass('rc-sidebar-page')
.text(' ' + rc.title)
.attr('href', new mw.Title(rc.title).getUrl()),
$('<p>')
.addClass('rc-sidebar-user')
.text(placeholderTime + 'm ago – ')
.append(
$('<a>')
.text(rc.user)
.attr('href', new mw.Title(rc.user, 2).getUrl())
)
)
})
} else {
$recentChangesDOM = $('<p>').text('Sem mudanças recentes.')
}
$rcContainer.append($recentChangesDOM)
})
.fail(function(_, data) {
alert(data.error.info)
});
}
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
$(init)
})
}(jQuery, mediaWiki));
//</nowiki>