User:T12/scripts/pageCollector.js: Difference between revisions
< User:T12
Jump to navigation
Jump to search
m (Tito Dutta moved page User:Tito Dutta/script/pageCollector.js to User:Tito Dutta/scripts/pageCollector.js without leaving a redirect: s) |
m (Abhidevananda moved page User:Tito Dutta/scripts/pageCollector.js to User:T12/scripts/pageCollector.js: Automatically moved page while renaming the user "Tito Dutta" to "T12") |
(No difference)
|
Latest revision as of 11:37, 6 November 2022
(function() {
function save(title, content, next)
{
var param = {action: 'edit', title: title, summary: 'adding ' + content, token: mw.user.tokens.get('editToken'), appendtext: content, format: 'json'};
$.post(mw.util.wikiScript('api'), param, function() {
mw.util.jsMessage(content + ' added to page ' + title);
}); //flying blind
}
function add_button(page, caption)
{
var addColon = $.inArray(mw.config.get('wgNamespaceNumber'), [6,14]) + 1; //file:, category:
var pageName = (addColon ? ":" : "") + wgPageName.replace( /_/g, " " );
var text = '[[' + pageName + ']]';
var a = mw.util.addPortletLink(window.pageCollectorMenu || 'p-cactions','#',caption,'','add this page to: "' + page + '"');
$(a).click(function() {save(page, '\n* ' + text);});
}
$(window.pagesToCollect).each(function() {add_button(this.page, this.caption);});
})();