MediaWiki talk:Gadget-morebits.js: Difference between revisions
Content deleted Content added
→IndexOf x $.inArray: why it broke |
→IndexOf x $.inArray: my bad |
||
Line 6:
== IndexOf x $.inArray==
{{editprotected|answered=
Wouldn't be better to change
mw.config.get( 'wgUserGroups' ).indexOf( group ) !== -1
to
<s>[http://api.jquery.com/jQuery.inArray/ $.inArray](group, mw.config.get( 'wgUserGroups' ))</s>
to ensure cross-browser support? [[User talk:Helder.wiki|Helder]] 13:55, 18 May 2011 (UTC)
:I have no idea. But as there is no opposition I have made the change for you. — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 10:14, 19 May 2011 (UTC)
::Fair enough. Personally, I think it's a performance decrease, and doesn't really improve legibility. But, that aside, any changes to this page are likely to get unintentionally overwritten, unless Twinkle maintainers get a heads-up at [[WT:TW]]. — <span style="border:dashed #666;border-width:1px 0 0 1px">[[User:This, that and the other|This, that]]</span>, and <span style="border:dashed #666;border-width:0 1px 1px 0">[[User talk:This, that and the other|the other<small> (talk)</small>]]</span> 10:40, 19 May 2011 (UTC)
::: Helder's point was mainly browser compatibility, I think: IE8 doesn't support JS 1.6 and thus doesn't know <tt>Array.indexOf</tt>.<br>Don't know how many other problems morebits has in IE8 (and older), of course. [[User talk:Amalthea|<span style="font-variant:small-caps;color:#832">Amalthea</span>]] 11:03, 19 May 2011 (UTC)
::::Indeed. IE8 shows "undefined" if I put "javascript:alert(['foo'].indexOf)" in the adress bar while Firefox displays "function indexOf() {[native code]}". [[User talk:Helder.wiki|Helder]] 18:06, 25 May 2011 (UTC)
{{editprotected|answered=yes}} Actually, that change broke stuff. Could an admin please revert it? Thanks, — <span style="border:dashed #666;border-width:1px 0 0 1px">[[User:This, that and the other|This, that]]</span>, and <span style="border:dashed #666;border-width:0 1px 1px 0">[[User talk:This, that and the other|the other<small> (talk)</small>]]</span> 10:57, 19 May 2011 (UTC)
: Done. [[User talk:Amalthea|<span style="font-variant:small-caps;color:#832">Amalthea</span>]] 11:03, 19 May 2011 (UTC)
:: inArray also returns the index, comparing the return value with -1 should have worked. [[User talk:Amalthea|<span style="font-variant:small-caps;color:#832">Amalthea</span>]] 11:06, 19 May 2011 (UTC)
:::My bad. I forgot to add the "!== -1" part to the code above. This should work:
$.inArray(group, mw.config.get( 'wgUserGroups' )) !== -1;
:::[[User talk:Helder.wiki|Helder]] 18:06, 25 May 2011 (UTC)
|