• Welcome to NIWA Community Forums.
 

Recent changes namespace toggler

Started by Greenpickle, November 12, 2010, 09:34:45 PM

Previous topic - Next topic

Greenpickle

I actually initially wrote this a long time ago (page histories give 10th October 2009 as the date of the initial version...), but I didn't know any JavaScript and was just making stuff up as I went along, looking up what I needed.  Unsurprisingly, the result was pretty terrible code - but it worked, for me, and I was happy with that.

A few weeks ago, I borrowed a JavaScript book from the library and took a weekend to actually learn it; now, I've got around to rewriting this, and it should be ready to use.

This is a script to, as the name suggests, toggle namespaces in the recent changes.  A checkbox for every namespace (and things like deletion log, new accounts, page moves) gets added to the top, and ticking/unticking it shows/hides changes for that namespace (once you've put the right CSS in place as well).  You can set initial values so that certain namespaces start hidden; and there are buttons to toggle all/invert the selection/restore the initial selection.  Here's a live version.

To use it, follow the instructions here.

Known issues

- When using enhanced recent changes, hiding/expanding the edits for a page removes the class applied by my script to hide it.  Therefore, this is only a problem when the CSS you set up doesn't hide the 'hidden' changes (but does something else - makes them small and grey like the example, say).  This'll be fixed when I get the time, and I'll see if they'll accept a patch in MediaWiki to make the enhanced recent changes more flexible with regard to manipulating classes.

- If this is employed site-wide, the user can't have their own settings for the initial namespaces hidden because user JS loads after site JS.  I'll try to think of a way this could be done; I have an idea that would work, but be messy and increase page load time - anyone have any suggestions?

- I haven't been able to test this in IE as VirtualBox has suddenly decided it doesn't want guests to have internet access and I can't be bothered to set up a local page.  If anyone finds this doesn't work in IE (not unlikely), there'll probably be an error-type icon somewhere that you can double-click or something to get the details I'd like to know about; and I'd like to know the version you're using as well.  Update: reported to work fine in IE7.

Bug reports and feature requests are welcome.

Peanut64


tacopill








Greenpickle

First, I hope you're not planning on using that version; here's the one without Wikia-specific parts.  Second, just checking, you know that depends on JQuery, right?  It's just that it's not mentioned on any information page for it that I can find.  Third, wow, there's some terrible code in there.

The answer is no, but it would just be a few lines to make it compatible (I'm thinking just if (window.$ !== undefined) $.bind('ajaxComplete', function () {
    $('#' + RCNSTControlsId).remove();
    RCNST.init();
});
).  What you'd get is any new changes loaded through JavaScript requests wouldn't be affected by the checkboxes/buttons.  Edits now not fitting in the set number of changes you allow would disappear, which shouldn't cause an exception or anything, I don't think, but it would keep references to those changes so garbage collection wouldn't get at them - in other words, a memory leak.

tacopill