User talk:Krinkle/Le Tour de Wikí/2011 Resource Walker/jsUpdater.js

From Meta, a Wikimedia project coordination wiki

Install: Copy the following code:

// [[File:User:He7d3r/Tools/jsUpdater.js]] ([[Special:GlobalUsage/User:Helder.wiki/Tools/jsUpdater.js]])
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/jsUpdater.js&action=raw&ctype=text/javascript' );

You will then see an extra "update" tab whenever you visit a script page. Clicking on it will open the edit screen and show a popup asking which changes should be performed. Note that the script isn't compatible with the new code editor, which you have to disable by clicking the /* button in the edit toolbar.

Tooltip[edit]

Hi!

You may want to restore the English tooltip (it was changed to Portuguese accidentally in this update). Helder 13:42, 13 March 2011 (UTC)

Thanks, DoneKrinkletalk 23:39, 13 March 2011 (UTC)[reply]

Fix for bug with .test()[edit]

Hi!

For some reason the script wasn't replacing "importScriptURI" with "mw.loader.load" in a page having only

importScriptURI('http://en.wikipedia.org/w/index.php?title=test.js&action=raw&ctype=text/javascript');

but it works again after this change. Helder 13:48, 14 March 2011 (UTC)

Thanks, I've performed the edit, hereKrinkletalk 18:15, 14 March 2011 (UTC)[reply]

Update[edit]

You may want to update the code to this version, which shows some checkboxes to confirm which changes should be applied to the script. There are some new regexes too. Helder 20:24, 3 July 2011 (UTC)

Hi,
I've looked at the diff/patch you linked to (haven't tested it yet though), here's a few suggestions I'd recommend you make before I merge it in:
  • Use mw.msg() instead of accessing the messages directly from the messages object.
  • The new mw.util.wikiScript( 'api' ) is now available which makes constructing the path to the api entry-point much easier and more stable and usable for other wikis (ie. also takes wgScriptExtension into account)
The rest looks pretty good from what I can see. Thanks for your improvements! –Krinkletalk 21:11, 3 July 2011 (UTC)[reply]
Done!
Thanks for these hints!
BTW: Is that loop on jsUpdater.checkForUpdates a the best way to "parse" the data from API to get the wikitext of the wanted page? Helder 01:47, 4 July 2011 (UTC)
It's not a bad way. Do note that for in-loops without checking hasProperty is dangerous, so if you wanna do a loop on the pages object directly, it should be done by checking hasProperty as well (or simply use $.each which does this automatically). But since you're interested, here's how I'd recommend you do it:
Pass the boolean parameter "indexpageids" to the API (like this). That way you can do a numeral for( var i = 0; i < someting; i++ ) on indexpageids (which is an array), then use the values of that array to look up the page object in the pages object. –Krinkletalk 12:31, 9 July 2011 (UTC)[reply]
Updated to revision 2 diff. –Krinkletalk 12:35, 9 July 2011 (UTC)[reply]
Done[1], with some improvements to the regexes.
One more question: is there any way to let the callback function used in a categorymembers query like this to know the name of the category which was passed to get the list? I needed this to create b:pt:MediaWiki:Livros/Wikilivros:Biblioteca.js (which create the checkboxes and background images for the lists on our Bookshelf), but since I didn't find a way, I had to create 8 copies of the same function, each one of them to deal with a specific category/query. Although that worked, I think it is an ugly way to do solve the problem. Besides, isn't possible to get pages from multiple categories in less queries? Helder 14:44, 10 July 2011 (UTC)
I was able to implement your suggestion, and it works! Thank you! Helder 15:15, 13 October 2011 (UTC)
DoneI've merged in more changes by you. Thanks! diffKrinkletalk 21:59, 12 October 2011 (UTC)[reply]

Tracking link[edit]

Hi!

Could you add a tracking link such as this to the script? Helder 14:42, 28 February 2012 (UTC)

DoneKrinkletalk 18:13, 28 February 2012 (UTC)[reply]
There is a "[edit]" on User:Krinkle/1-17-allwikis/jsUpdater.js which shoudn't be there (I think). Helder 03:26, 29 February 2012 (UTC)
Woops, fixed. –Krinkletalk 04:53, 29 February 2012 (UTC)[reply]

More updates[edit]

The old regex matched uses of $j, which I think should still be updated. Maybe you could backport this change? (It also includes regex for new Array()[] and new Object(){}). Helder 15:49, 17 May 2012 (UTC)

Done in r8. I also made several changes you may want to use (r6 and r7). –Krinkletalk 23:34, 17 May 2012 (UTC)[reply]
What about the conversion $j -> $?
Cool! You've added a test suite!
I wasn't able to figure out how to use the "test/index.html" file, though. Is there a link where I can access this page directly? (on github I only see its source code, which is not parsed as HTML)
Helder 21:01, 18 May 2012 (UTC)
You need to checkout the repository on your computer with "Git". Then make sure you include submodules (since it is referencing the QUnit framework). Then you can run ./test/index.html in your web browser from the local web server. –Krinkletalk 23:34, 18 May 2012 (UTC)[reply]
Converting $j. and $j(..) to use $ is fine by me. But don't change jQuery or (document).ready. Also be careful not to mess with var $jack = $('#jack');. If you feel up to it, it would be nice if you could propose the change through a GitHub pull request. –Krinkletalk 23:36, 18 May 2012 (UTC)[reply]
Done (I think). Helder 21:13, 19 May 2012 (UTC)
BTW: Could you fix (point directly to github) this double "redirect"? Helder 21:17, 19 May 2012 (UTC)

Comments[edit]

Could you make this stop making changes to commented text?-- ~ UltimateSupreme 13:53, 23 October 2013 (UTC)[reply]

dialog fades away if unselecting one of the checkboxes[edit]

I've tried to use this in some pages but when there are several issues listed and I deselect one of them, the dialog fades out and disappears. Is that intended behavior? --Waldir (talk) 16:40, 23 November 2013 (UTC)[reply]

Not really. It is just because it was created before this new message system (and I didn't have the time/motivation to update it yet). Helder 21:39, 25 November 2013 (UTC)
Waldir, actually, I "fixed" my local version some time ago. Helder 14:26, 3 December 2013 (UTC)[reply]
Hi Helder, just now saw this. I'm curioys, is there a reason you're keeping your version separate rather than contributing the fixes upstream? --Waldir (talk) 00:13, 27 February 2014 (UTC)[reply]
Waldir, probably because I was still waiting my previous pull request to be merged, and then I probably got distracted with other things... Helder.wiki 12:02, 27 February 2014 (UTC)
I guess I'll start using your version then. I'll try to prod Krinkle in the hackathon to fix this and other issues (the updater doesn't work with the new code editor, for instance) and perhaps give you commit rights on that repo :) it'd be nice if there was a single, up-to-date version around. --Waldir (talk) 23:41, 25 March 2014 (UTC)[reply]