MediaWiki talk:Gadget-purgetab.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


See also[edit]

New code[edit]

{{editprotected}} Please update the code. The current code has $j('#ca-history a') in it, which is ultra-slow. Edokter (talk) — 12:59, 4 July 2011 (UTC)[reply]

/**
 * Action link: Purge (Action menu)
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Purge_action
 * @rev: 5
 */
$( function () {
    if ( !$( '#ca-purge' ).length && mw.config.get( 'wgIsArticle' ) ) {
        mw.util.addPortletLink(
            'p-cactions',
            mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ) + '?action=purge',
            mw.config.get( 'skin' ) == 'vector' ? 'Purge' : '*',
            'ca-purge',
            'Purge the server cache of this page',
            '*'
        );
    }
});
Do you want your code to entirely replace the existing code? That's fine, I just didn't know (and didn't want to screw it up). Killiondude (talk) 18:40, 1 August 2011 (UTC)[reply]
✓ Done --Mormegil (talk) 15:39, 2 August 2011 (UTC)[reply]

Translated label[edit]

{{Edit request}} Is there a reason why the English label "Purge" is used and not a translated label as if {{int:purge}} was used? --bdijkstra (overleg) 09:43, 23 September 2020 (UTC)[reply]

@Bdijkstra: Probably because the purge interface message isn’t available in JS (at least as far as I can tell). I’m disabling the {{Edit request}} because I don’t think it’s actionable at the moment – no specific edit has been proposed/requested and I don’t see a straightforward way to implement the requested functionality. --Lucas Werkmeister (talk) 21:22, 23 November 2020 (UTC)[reply]
Here's an example of how interface messages can be loaded and used:
var api = new mw.Api();
api.loadMessagesIfMissing(["purge"]).then(function () {
	var linktext = mw.msg("purge");
    ...
});
- Nikki (talk) 14:49, 30 March 2024 (UTC)[reply]
Add the first three lines before line 10. Add the last line after line 17. Replace 'Purge' on line 17 with linktext. - Nikki (talk) 07:33, 5 May 2024 (UTC)[reply]
✓ Done; I added maxage: 24 * 60 * 60 to the API request getting the message so that it gets cached (client-side, per user) for a day, to reduce overhead and make the gadget load faster (most of the time). --Lucas Werkmeister (talk) 07:43, 5 May 2024 (UTC)[reply]

Vector-2022 label[edit]

Can someone update this gadget with the version from https://en.wikipedia.org/wiki/MediaWiki:Gadget-purgetab.js ? This should fix the label in the new Vector. It's the only change to the code. —TheDJ (talkcontribs) 11:07, 15 March 2023 (UTC)[reply]

@TheDJ: I've synced the code (this issue has been bugging me for a while), but it doesn't seem to work as far as I can see - any thoughts? Thanks. Mike Peel (talk) 11:49, 1 April 2023 (UTC)[reply]
Ah, now it seems to be working, must have taken a bit of time to get through the cache. Thanks. Mike Peel (talk) 11:50, 1 April 2023 (UTC)[reply]

Timeless label[edit]

It is requested that an edit or modification be made to this protected page.
Administrators: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Nikki

Please add "timeless" to the list of skins on line 13. In Timeless, the link is shown as a sidebar entry on wider screens and as a dropdown menu entry on narrower screens, there's no reason it would need a single character label.

A better solution might be to only use "*" if the skin is "monobook", which I assume is what the "*" label is really intended for.

- Nikki (talk) 14:56, 30 March 2024 (UTC)[reply]

A better solution might be to only use "*" if the skin is "monobook", which I assume is what the "*" label is really intended for. I’m not sure about that, to be honest – MediaWiki:Gadget-purgetab says that it’s “an asterisk * in skins other than the default Vector”. Lucas Werkmeister (talk) 07:34, 5 May 2024 (UTC)[reply]
What I mean is that MonoBook puts these links as tabs across the top, so long link names are a problem, and MonoBook was the default skin when this was created, so I'm assuming that's the reason why someone chose to use "*" instead of something meaningful. - Nikki (talk) 08:15, 5 May 2024 (UTC)[reply]

Minerva support[edit]

It is requested that an edit or modification be made to this protected page.
Administrators: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Nikki

Please use "p-tb" instead of "p-cactions" (line 11) when the skin is "minerva". This gadget currently doesn't work in Minerva because Minerva does not have an element with the ID "p-cactions". Adding it to "p-tb" will add it to Minerva's dropdown "More" menu.

An icon could also be added for it. Adding this somewhere after line 17 if the skin is "minerva" would use the OOUI reload icon (it does reload the page after purging, so it wouldn't be wrong :)):

node.querySelector(".minerva-icon").classList.add("oo-ui-icon-reload");

And adding this CSS (I would create MediaWiki:Gadget-purgetab.css and then update MediaWiki:Gadgets-definition, but adding it from within the script would be an option too) would make the icon closer in colour to the other Minerva icons:

.minerva-icon-portletlink-t-purge { opacity: 0.65 }

- Nikki (talk) 15:24, 30 March 2024 (UTC)[reply]

And "minerva" should also be added to the list on line 13, if it's not changed to only use "*" on Monobook. - Nikki (talk) 15:39, 30 March 2024 (UTC)[reply]