Difference between revisions of "User:Fbstj/gadget/history-test.js"

m
Fbstj moved page User:Fbstj/common.js to User:Fbstj/gadget/history-test.js without leaving a redirect
m (smaller links)
m (Fbstj moved page User:Fbstj/common.js to User:Fbstj/gadget/history-test.js without leaving a redirect)
 
(151 intermediate revisions by the same user not shown)
mw.hook('wikipage.content').add(function revs_gadget() {
/* Add edit buttons to templates */
$(function () {
 
const pageid = mw.config.get('wgArticleId')
function edit_button(i, v) {
const query = {
if (!v) return v;
// request the history of this page
v = v.replace(/\.(\d+)/, "%$1");
pageids: [pageid],
var a = "<a href='/edit/Template:" + v +"'>edit</a>";
prop: 'revisions',
$('.title', this).append("<span class='mw-editsection' style='float: right;' >[" + a + "]</span>");
// request the oldest edits first
rvdir: 'newer',
// request as many as you can at once
rvlimit: 'max',
// properties to fetch:
rvprop: [ 'ids', 'user', 'timestamp', 'size', 'tags', ],
}
const api = new mw.Api({ parameters: query, })
 
api.get().then(function old_hist(resp) {
$('.navbar').attr('id', edit_button);
 
const page = resp.query.pages[pageid]
$('.infobox').attr('id', edit_button);
page.revisions.forEach(console.log)
 
});
 
})