MediaWiki talk:Gadget-rightsfilter.js: Difference between revisions

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Content deleted Content added
→‎Update: * The <br> tag was in the Portuguese translation intentionally (see #Localization), but I think it is better to move it to a place such as $fieldSet, where it would be added to all translations.
(One intermediate revision by the same user not shown)
Line 87: Line 87:


== Update ==
== Update ==
{{tlc|editprotected}}
{{editprotected}}


Hello! Could someone apply [https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-rightsfilter.js&oldid=57959850&diff=57977420 these changes] to the script? The new version includes fixes to the problems mentioned in the sections above (i18n, bug fixes, backward compatibility, button to get links to filtered lists ). Feel free to add other translations as well. [[b:pt:User:Helder.wiki|Helder]] 04:15, 13 August 2011 (UTC)
Hello! Could someone apply [https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-rightsfilter.js&oldid=57959850&diff=57977420 these changes] to the script? The new version includes fixes to the problems mentioned in the sections above (i18n, bug fixes, backward compatibility, button to get links to filtered lists ). Feel free to add other translations as well. [[b:pt:User:Helder.wiki|Helder]] 04:15, 13 August 2011 (UTC)
Line 105: Line 105:
* Some other minor performance improvements and good practices catched by JSHint.
* Some other minor performance improvements and good practices catched by JSHint.
: –''[[User:Krinkle|Krinkle]]''<sup>[[User talk:Krinkle|talk]]</sup> 12:02, 13 August 2011 (UTC)
: –''[[User:Krinkle|Krinkle]]''<sup>[[User talk:Krinkle|talk]]</sup> 12:02, 13 August 2011 (UTC)
::Followup:
::* There is a small typo in the code: <code>'filter-othe-list-instructions'</code> should be <code>'filter-othe<span style="color:red;">r</span>-list-instructions'</code>.
::* It seems necessary to change the parameters in the [https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadgets-definition&curid=3185782&diff=57991000&oldid=55914657 gadgets-definition] from [ResourceLoader] to [ResourceLoader<span style="color:red;">|dependencies=mediawiki.util</span>], to avoid problems when <code>mw.util.getParamValue</code> and <code>mw.util.addPortletLink</code> are used.
::* The <code><nowiki><br></nowiki></code> tag was in the Portuguese translation intentionally (see [[MediaWiki_talk:Gadget-rightsfilter.js#Localization|#Localization]]), but I think it is better to move it to a place such as <code>$fieldSet</code>, where it would be added to all translations.
::Thanks for improving the script.
::PS: what about adding translations for 'nl' and 'de'? ;-) [[b:pt:User:Helder.wiki|Helder]] 12:37, 13 August 2011 (UTC)

Revision as of 12:52, 13 August 2011

lifilter

FYI, I've updated this to work on any page that has any <li> (and renamed it accordingly), and to work on demand via querystring as well. w:User:Splarka/lifilter.js. Splarka 06:10, 11 February 2008 (UTC)[reply]

Updated it again, to play nice on almost any page (via &lifilter=true url) and in any skin (in theory). Same link. Splarka 10:51, 24 February 2008 (UTC)[reply]

Typo and suggestion

Hello!

I've noticed there is a typo at this line:

if(wgAction == 'history' || wgCanonicalSpecialPageName == 'Search' || wgCanonicalSpecialPageName == 'Log'
|| wgCanonicalSpecialPageName == 'CheckUser' || wgCanonicalSpecialPageName == 'LinkSearch'
|| wgCanonicalSpecialPageName == 'Contributions' || wgCanonicalSpecialPageName == 'IPBlockList' || queryString('lifilter'))
addOnloadHook(filterLiButton)

When we go to Special:IPBlockList, the variable wgCanonicalSpecialPageName has the value "Ipblocklist", with 'pb' instead of 'PB'.

Could you correct this? Helder 17:48, 29 October 2009 (UTC)

By the way, is it possible to "submit" the filter when the user press ENTER? Currently it is needed to click at the "Filter" button... I think this could be useful. Helder 17:48, 29 October 2009 (UTC)
By the way (2), I've made a translation of the messages to Portuguese, if you want to add it here... ;) Helder 17:56, 29 October 2009 (UTC)
✓ Done, first request done, for the other ones someone with more JavaScript knowledge is necessary. --The Evil IP address (talk) 22:17, 30 October 2009 (UTC)[reply]
Would it be possible to have the script filtering after the user press ENTER? Helder 21:06, 19 May 2010 (UTC)
✓ Done. Don't forget to reload your browser's cache. Lupo 07:12, 20 May 2010 (UTC)[reply]

Localization

Hi!

Could anyone please make the script localizable?

We already have the Portuguese translation ('pt' and 'pt-br') which could be incorpored in commons version too. Helder 20:22, 27 December 2010 (UTC)

By the way, in the translated version, the line became too long horizontally:

Could someone add a linebreak in the text of variable "instructions"?
Another option would be to move the text of that variable to the caption:
$legend.text('Filter <li> list: ' + instructions );
Helder 20:42, 27 December 2010 (UTC)

Missing parenthesis

{{editprotected}}

Hi!

It seems to be missing some parenthesis around this code:

	if (wgAction == 'history' || wgCanonicalSpecialPageName && wgCanonicalSpecialPageName.match(/^(Activeusers|CheckUser|Contributions|Ipblocklist|LinkSearch|Log|Search|(Uncategoriz|Unus|Want)ed(categori|templat)es|Wantedfiles|(Short|Long|Ancient|Uncategorized|Unwatched|Wanted|Protected|Deadend|Lonely|New)pages|Fewestrevisions|Withoutinterwiki|(Double|Broken)Redirects|Protectedtitles|CrossNamespaceLinks|Recentchanges|Categories|Disambiguations|Listredirects|GlobalUsers|GlobalBlockList|Listusers|Watchlist|Most(linked|revisions|categories)|Nuke|Whatlinkshere)$/i) || getParamValue('lifilter')) {

It should be

	if (wgAction == 'history' || (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName.match(/^(Activeusers|CheckUser|Contributions|Ipblocklist|LinkSearch|Log|Search|(Uncategoriz|Unus|Want)ed(categori|templat)es|Wantedfiles|(Short|Long|Ancient|Uncategorized|Unwatched|Wanted|Protected|Deadend|Lonely|New)pages|Fewestrevisions|Withoutinterwiki|(Double|Broken)Redirects|Protectedtitles|CrossNamespaceLinks|Recentchanges|Categories|Disambiguations|Listredirects|GlobalUsers|GlobalBlockList|Listusers|Watchlist|Most(linked|revisions|categories)|Nuke|Whatlinkshere)$/i)) || getParamValue('lifilter')) {

Could someone add them, please? Helder 14:00, 9 January 2011 (UTC)

✓ Done http://commons.wikimedia.org/wiki/?diff=53522120Krinkletalk 20:10, 23 April 2011 (UTC)[reply]

JS Errors

{{editprotected|technical=yes}} The script is generating the error

trailing \ in regular expression
http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-rightsfilter.js&action=raw&ctype=text/javascript&283-19
Line 85

when I start to fill in the form with the regex "\d", because it try to use "\" as a regex.

I think if the code of filterLi() or

$('#rightsFilter input').bind('keyup change', function () {
	filterLists.filterLi();
});

validated the input to see if it is a valid regular expression this error wouldn't happen.

Could someone fix it? Helder 14:35, 9 January 2011 (UTC)

Backward compatibilities

{{editprotected|technical=yes}} Hi!

I would like to know if it is really wanted that this edit breaks old links in which there was no 'lifilter' parameter needed to activate the form when clicking in the links. For example:

Could it check for the presence of any of the accepted parameters to decide if the form should be shown (instead of checking by &lifilter=1)? Helder 15:04, 9 January 2011 (UTC)

 Not done This has been open for 6 months - let's admit it isn't going to be fulfilled. I suggest following it up by posting at COM:VP or approaching a user directly who might be able to help. Rd232 (talk) 10:55, 20 July 2011 (UTC)[reply]

Links to filtered lists

Hi!

Could some admin replicate this update to the original script? It adds a link which the user can use to get a url to the filtered list, making it easier to share specific sublists of logs and other pages. Helder 21:07, 16 May 2011 (UTC)

Update

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.

He7d3r

Hello! Could someone apply these changes to the script? The new version includes fixes to the problems mentioned in the sections above (i18n, bug fixes, backward compatibility, button to get links to filtered lists ). Feel free to add other translations as well. Helder 04:15, 13 August 2011 (UTC)

✓ Done. Also made an additional edit:
  • Whitespace consistency
    • separate conditions and the condition-wrapper with a space from the "if" keyword
    • no space between the function and the callee (whether or not with arguments). This makes it easy to see if something is a function or a block.
  • Double quotes/single quotes
  • HTML escaping!
    • jQuery.fn.append is appending HTML, not text. Input has to be escaped before hand (or use .text() if possible) with mw.html.escape().
    • When creating a new element, insert text with .text() instead of .append().
    • Including cases like $( foo ).append( '<option>' + mw.msg( 'bar' ) + '</option>' );,
      those should be $( foo ).append( '<option>' + mw.html.escape( mw.msg( 'bar' ) ) + '</option>' );
      or perhaps: $( foo ).append( $('<option>').text( mw.msg( 'bar' ) ) );.
      From MediaWiki 1.18 onwards, the following has become possible as well: $( foo ).append( '<option>' + mw.message( 'bar' ).escaped() + '</option>' );.
      But some kind of escaping is required.
  • Removing unneeded parenthesis.
  • Using strict comparison (tripple equals)
  • Combining HTML fragments into a string before dom-manipulation (eg. combining a bunch of ‎<option> tags in 1 string and calling .append() only once, instead of parsing HTML many times and appending the element to another element many times)
  • Some other minor performance improvements and good practices catched by JSHint.
Krinkletalk 12:02, 13 August 2011 (UTC)[reply]
Followup:
  • There is a small typo in the code: 'filter-othe-list-instructions' should be 'filter-other-list-instructions'.
  • It seems necessary to change the parameters in the gadgets-definition from [ResourceLoader] to [ResourceLoader|dependencies=mediawiki.util], to avoid problems when mw.util.getParamValue and mw.util.addPortletLink are used.
  • The <br> tag was in the Portuguese translation intentionally (see #Localization), but I think it is better to move it to a place such as $fieldSet, where it would be added to all translations.
Thanks for improving the script.
PS: what about adding translations for 'nl' and 'de'? ;-) Helder 12:37, 13 August 2011 (UTC)