Fandom Developers Wiki
Line 221: Line 221:
   
 
:::Confirmed that superfluous code is superfluous and can safely be removed. Discovered that the throbber doesn't work in the Monobook skin :P {{User:Mathmagician/sig|07:04 UTC|Wednesday|19 September 2012}}
 
:::Confirmed that superfluous code is superfluous and can safely be removed. Discovered that the throbber doesn't work in the Monobook skin :P {{User:Mathmagician/sig|07:04 UTC|Wednesday|19 September 2012}}
  +
  +
::::It seems the className should have been "oasisThrobber" instead of "wikiaThrobber" :) -- [[w:Message_Wall:Pecoes|peco<span style="vertical-align:-0.2em">e</span>s]] 07:29, September 19, 2012 (UTC)

Revision as of 07:29, 19 September 2012

Redundant buttons

A bug for you to chew on: Use this, then go on a blog page. Redundant buttons. --Zapwire (invisible leather tardis) 14:14, December 16, 2009 (UTC) Old, as well as any wiki with SMW. Just need to have it check the current ns and not appear if it's in X. Joey (talk) 15:07, December 18, 2009 (UTC)

New profile masthead

With this edit, Monchoman45 fixed the code for the Purge button so that it would work with the new profile masthead. It worked brilliantly for a bit. But, now it seems to have stopped working in the user and usertalk namespaces again. Just wanted to alert you guys. Thanks! — SpikeToronto 05:37, August 26, 2011 (UTC)

Should be fixed. grunny:~$ 16:40, August 26, 2011 (UTC)
It works! Only, now the pulldown has a certain level of tranparency to it pulls down behind other elements. Although that may only be on pages with the new RTE activated. Thanks! — SpikeToronto 21:17, August 26, 2011 (UTC)
Update: Well, it is working great on userpages and user talkpages, and in other namespaces. However, it does not show up in subpages in the user namespace. (See here for an example.) Thanks! — SpikeToronto 07:36, August 29, 2011 (UTC)
Should be fixed. grunny:~$ 08:10, August 30, 2011 (UTC)

Localizations

Can the translations be added in a similar way to ShowHide code? leviathan_89 21:50, March 11, 2012 (UTC)

Other Languages — Chinese

"Purge" in Chinese is "刷新" -- Sam Wang (talk) 04:57, May 13, 2012 (UTC)

Small improvement

There are two things that I feel could be improved upon:

  1. The dangling "action=purge" in the URL is really annoying.
  2. This function does not purge the browser's cache.

So how about this:

function purge () {
    $.get('/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', function () {
        location.reload(true);
    });
}

Or in full:

if( wgNamespaceNumber >= 0 && !window.PurgeButtonsLoaded && document.getElementById('control_purge') == null && wgNamespaceNumber != 500 && wgNamespaceNumber != 502 ) {
    addOnloadHook( addPurgeButton );
}
var PurgeButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)

function addPurgeButton () {
    var theText = 'Refresh'; //default text, ala SMW
    
    if( typeof PurgeButtonText == "string" ) {
        theText = PurgeButtonText;
    }

    function purge () {
        $.get('/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', function () {
            location.reload(true);
        });
    }
    
    switch( skin ) {
        case 'answers': /* forked from monaco, close enough, pass to monaco */
        case 'awesome': /* you really shouldnt even have this value... */
        case 'monaco_old': /* really, where are you getting these skin settings from... */
        case 'monaco':
            $('#page_controls').append('<li id="control_purgebutton"><img src="/skins/common/blank.gif" class="sprite refresh" /><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;


        case 'uncyclopedia': /* monobook clone, pass to monobook */
        case 'wowwiki': /* monobook clone, pass to monobook */
        case 'lostbook': /* monobook clone, pass to monobook */
        case 'monobook':
            $('#p-cactions > .pBody > ul').append('<li id="ca-purge"><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;

        case 'oasis':
        case 'wikia':
            $(((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && $( '.UserProfileActionButton' ).length ? '.UserProfileActionButton' : '#WikiaPageHeader') + ' > .wikia-menu-button > ul').append('<li><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;

    }
    
    $('#purge').click(purge);
}

-- pecoes 18:39, June 11, 2012 (UTC)

*bump* pecoes 05:54, June 13, 2012 (UTC) -- pecoes 09:57, June 13, 2012 (UTC)
Done. Cheers, grunny@:~$ 16:47, June 16, 2012 (UTC)
Thanks! I like how this clears the ?action=purge from the URL. That way, if I want, I can just Ctrl-F5 after. Thanks guys! — SpikeToronto 21:50, June 16, 2012 (UTC)
Actually, you don't have to Ctrl+F5 anymore. That's already included. -- pecoes 21:57, June 16, 2012 (UTC)
Perfect! Double thanks!! — SpikeToronto 22:28, June 16, 2012 (UTC)
By the way, at least in Internet Explorer, this new function is closer to Reload than Refresh. Thanks! — SpikeToronto 05:22, June 17, 2012 (UTC)

Only add to main menu button

Can the code be changed to only append Purge to the main menu button? I have created a second menu button with extra admin functions and I'm annoyed that Purge gets appended there as well since it's of class "wikia-menu-button" too. Land Raider 13:49, July 3, 2012 (UTC)

Do you have an example page? Or can you post your button's HTML and/or where it's located in the DOM? -- pecoes 14:24, July 03, 2012 (UTC)
You can probably fix this in your personal CSS. — SpikeToronto 19:32, July 4, 2012 (UTC)
Basically, I modified FastDelete tool to create a menu with FastDelete buttons instead of separate buttons (which is done by default). The menu is created with:
$( 'header.WikiaPageHeader' ).append('<nav class="wikia-menu-button"><a title="FastDelete" data-summary="Cleanup. See [[MediaWiki:Policy|Policy]] for details" data-id="fastdelete"><img class="sprite edit-pencil" width="30" height="16" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" alt="">FastDelete</a><span class="drop"><img class="chevron" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D"></span><ul id="fastdelete-list" class="WikiaMenuElement"></ul></nav>');

which is the only way I found to create another menu in addition to the main (Edit/Rephrase/Delete and Purge, if installed) one. In order for the menu to actually be a

menu, it needs this 'wikia-menu-button class but PurgeButton gets appended to that menu too, then. You're saying I can fix that in my personal CSS - how can this be done? I have tried to created a new menu button class but realized that CSS apparently can't "inherit" properties of other classes, and I don't know where to steal the CSS for the standard wikia-menu-button so that I could create another class based on it. If you suggest some other fix, I'd be glad to know about it. Land Raider 15:00, July 5, 2012 (UTC)


If you use Wikia's CSS to create complex interface elements, you have to plan for side-effects. Your drop-down button is basically a hack at this point. The only real fix is to write the CSS for the nav-button yourself. You can take Wikia's CSS as a blueprint, if you like. -- pecoes 15:51, July 05, 2012 (UTC)
Where do I find Wikia's CSS which defines wikia-menu-button? Land Raider 15:05, July 6, 2012 (UTC)
What you’ve done, LandRaider, sounds very interesting. If I understand it correctly, it adds the FastDelete buttons to the edit button pulldown? Could it be made to branch out from the "delete" entry on the button? The reason I ask is that the pulldown is already long with all the options already there. Thanks! — SpikeToronto 00:24, July 6, 2012 (UTC)
No, it creates a second menu because as you said, the Edit one is already quite crowded and those buttons delete a page instantly, so caution is needed when using them and it's better to separate them from standard tools. Take a look. Land Raider 15:05, July 6, 2012 (UTC)
As a quick hack: How about adding a height property to the dropdown and setting the overflow to "hidden"?
And out of curiosity: What do those sub-buttons mean? -- pecoes 15:51, July 06, 2012 (UTC)
EDIT: Sorry I didn't see your follow-up question above: You can find the CSS for menu button by "inspecting" the element either with Firefox/Firebug or Chrome. -- pecoes 15:53, July 06, 2012 (UTC)
Sub-buttons? "Wiki" for questions that can be answered by reading the "main" wiki (game answers wikias are not contributor-powered search engines for easily accessible documented knowledge, after all!), "Opinion" for breaking the Wikia answers policy (questions which can only have answers based on personal opinion are considered out of place) and "Spec" for baseless speculation requests (inquiries about information that cannot be deduced from the topic's media - games, movies, books, etc. - and is therefore baseless speculation). Regarding inspecting, I did that already (that's how I got the code for the button on the first place), but I was too confused with the CSS, I know very little about it and JavaScript. I'll try it out soon though, thanks for your suggestion! As for the quick hack, it's a good idea but a complete abomination from my point of view, an extra level of complexity... better try creating my own button with CSS :) Land Raider 20:14, July 6, 2012 (UTC)

"better try creating my own button with CSS :)"

Absolutely :) -- pecoes 20:39, July 06, 2012 (UTC)

What about adding .eq(0) to the PurgeButton selector? CSS classes are ther to be reused. No need to reinvent the wheel, specially when he wants to have the exact same functionality of the already existing menu button. I'm too lazy at that moment to switch to the Oasis skin, but if the existing button has an ID, PurgeButton should select the menu button by the ID rather than the CSS class, to prevent this from occurring. Otherwise, better put .eq(0) to the selector --Ciencia Al Poder en WikiDex 12:15, July 7, 2012 (UTC)
Only Grunny has edit-rights for the code and he hasn't chimed in yet. -- pecoes 12:48, July 07, 2012 (UTC)
What does .eq(0) do? Also, I tried selecting by ID in my customized PurgeButton code which I imported to DAA and it didn't work, but ought to be just my lame JS skills. If this can be done, I'd be delighted. Land Raider
Cienca's suggestion was that it would be easier to modify the PurgeButton script with .eq(0) then for you to recreate the CSS from scratch. .eq(0) selects the first matching node, so attaching it to the jQuery selector would cause only the first nav of class wikia-menu-button to be retrofitted with the purge-option.
In other words: .eq(0) would only be of indirect use to you. In your own code it's probably useless. But if you're interested anyway, take a look at this and this -- pecoes 15:27, July 08, 2012 (UTC)

For blog posts

I need to purge blog posts to see properly their replies. I do it by entering ?action=purge manually, but what if PurgeButton could also purge the blog posts? Cafeinlove, 22:06, July 10, 2012 (UTC)

You cannot see it in the URL but requesting ?action=purge is exactly what PurgeButton does. -- pecoes 00:39, July 11, 2012 (UTC)
Right, though buttons can be sometimes helpful. I actually edit on an old laptop with a not so good disposition of keyboard and I made typo 2 times while typing just ?action=purge, arrr(!) The best solution would be to make blog comments auto-refresh, but as now they are not. Cafeinlove, 03:01, July 11, 2012 (UTC)
Ah. I understand now. You mean the comments section under blogs and articles. Yes, those don't update while you're looking at the page. And you're right: That's really annoying.
The PurgeButton is not the right tool for this, I'm afraid. But MathMagician and I happen to be working on a little suite of tools for article comments and message walls. We really should put polling for new comments on the feature list! What do you think Math? -- pecoes 03:14, July 11, 2012 (UTC)
Hmmmm, auto-refreshing (I assume you mean *just* the comments, probably some sort of ajax thing, not the entire page) would be pretty neat. Also outside of my experience. But definitely neat. — Mathmagician (message wall) 00:16, July 12, 2012 (UTC)
That's outside of my experience too. We'd have to do a bit of reverse engineering on the wikia code to find out how they poll notifications and how they fetch messages...
Here's the code for article comments:
http://trac.wikia-code.com/browser/wikia/trunk/extensions/wikia/ArticleComments
And here the code for the message wall:
http://trac.wikia-code.com/browser/wikia/trunk/extensions/wikia/Wall
As awesome as this would be to have, it would be a little difficult to pull off. -- pecoes 05:58, July 12, 2012 (UTC)

(reset indent) I just stopped to thank you for considering this suggestion. I hope your work will go well and I'll look forward to eventual news. Cafeinlove, 08:02, July 17, 2012 (UTC)

Where do you add this to make it work

Global.js or global.css?User talk:Not the person you're thinking of|NTPYTO22:10, August 7, 2012 (UTC)

w:Special:MyPage/global.js -- pecoes 22:28, August 07, 2012 (UTC)

Thanks!User talk:Not the person you're thinking of|NTPYTO15:48, August 8, 2012 (UTC)

PurgeButton not working in User_blog: namespace

It appears that the refresh option does not appear in the Oasis 'edit' button dropdown when editing blog posts in the User blog namespace. My guess would be this is a small bug that might have something to do with the button being in a different place. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 22:36 UTC, Sunday, 16 September 2012

The current code simply aborts when the page is in the Blog or User Blog namespace.
This would fix it:
// if user blog, test if the current user owns the blog; if yes proceed, if not abort    
if ( [ 500, 502 ].indexOf( mw.config.get( 'wgNamespaceNumber' ) ) !== -1 ) {
    var user = mw.config.get( 'wgUserName' );
    if ( mw.config.get( 'wgTitle' ).slice( 0, user.length ) !== user) {
        return;
    }
}


-- pecoes 05:58, September 17, 2012 (UTC)
Grunny was so kind to give me edit rights. The button should work on blogs now. -- pecoes 13:51, September 18, 2012 (UTC)
Cool. A couple notes though: First: I'm not sure exactly why you need to test whether or not the user owns the blog? (Oasis: button doesn't appear if you don't own the blog, Monobook: Just add the PurgeButton where it would normally go?)
Secondly, where are you getting this magical "startThrobbing" function from? 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 22:22 UTC, Tuesday, 18 September 2012
  1. You may have a point there. It works though. So forgive me for leaving it like this for now :)
  2. I accidentally found $.fn.startThrobbing and $.fn.stopThrobbing in oasis_shared_user_js. Those two functions are not all that fancy though:
$.fn.startThrobbing = function () {
    this.append('<div class="wikiaThrobber"></div>');
};
$.fn.stopThrobbing = function () {
    this.find('.wikiaThrobber').remove();
};
-- pecoes 02:42, September 19, 2012 (UTC)


Thanks. I was sure it wasn't in the jQuery API, but I still had no clue what else would be adding it in. Also, (at the time I first posted) I couldn't get the function to work when calling it from the console. I did something like $(document.body).startThrobbing() and it didn't do anything. I realized just now that you actually have to be looking at the top of the page (which of course is fine with PurgeButton because the edit button is at the top of the article). If you scroll down to the bottom of the page, the throbber can't be seen anymore. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 03:09 UTC, Wednesday, 19 September 2012
Fixed the throbber and commented out the test whether the user owns the blog or not. -- pecoes 04:45, September 19, 2012 (UTC)
Confirmed that superfluous code is superfluous and can safely be removed. Discovered that the throbber doesn't work in the Monobook skin :P 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 07:04 UTC, Wednesday, 19 September 2012
It seems the className should have been "oasisThrobber" instead of "wikiaThrobber" :) -- pecoes 07:29, September 19, 2012 (UTC)