MediaWiki talk:Common.js

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from MediaWiki talk:Monobook.js)

Removing magic editintros[edit]

The last discussion on remove the "magic editintros" (for BLP/disambig pages) was at MediaWiki talk:Common.js/Archive 22#Replacing magic editintros with editnotices and Lua. That fixated on solving the problem by detecting page categories using lua - which is not really possible until phab:T50175 is resolved. I have a patch for that in the pipeline which is stuck. But never mind, this doesn't actually need T50175:

I propose to drop the code from Common.js and include the editintros via Template:Editnotices/Namespace/Main like other editnotices. I've created Module:Mainspace editnotice which implements the existing editnotices added by the template and by Common.js. – SD0001 (talk) 06:38, 4 February 2024 (UTC)[reply]

Pinging people from the earlier discussion: @Galobtter @TheDJ @Tacsipacsi. – SD0001 (talk) 06:42, 4 February 2024 (UTC)[reply]
I'd support this, per what I said in the last discussion. I assumed it'd be too annoying to figure out disambiguation pages without the category, but since it is possible, that was the only blocker to doing what I was trying to do. The only thing is that this needs to be fast since the editnotice is parsed everytime it needs to be displayed. Galobtter (talk) 15:52, 5 February 2024 (UTC)[reply]
Performance should be no more of an issue that the already existing check for {{refideas}} on the talk page is (which I wrote without even thinking about performance and AFAIK hasn't caused any problems of that nature). * Pppery * it has begun... 17:19, 5 February 2024 (UTC)[reply]
As part of the {{draft at}} inclusion conditionals, the current editnotice is already checking whether the page is a disambiguation page. In the new module, I'm reusing the same check result for both use-cases. I also tested by not reusing the result and letting it get computed twice - even then no discernible change in lua execution time was seen at a millisecond precision. – SD0001 (talk) 17:52, 5 February 2024 (UTC)[reply]
Looks good then. Galobtter (talk) 19:02, 5 February 2024 (UTC)[reply]
I have requested the edits at Template talk:Editnotices/Namespace/Main#Interface-protected edit request on 6 February 2024. – SD0001 (talk) 10:48, 9 February 2024 (UTC)[reply]
 Done * Pppery * it has begun... 18:58, 9 February 2024 (UTC)[reply]

Unarchiving this discussion as there is a problem, as indicated at Template_talk:BLP_editnotice#Suppresses_link_to_Page_notice, which has been traced to the above edit. Is there something that can be done to resolve the issue? SilkTork (talk) 23:24, 25 May 2024 (UTC)[reply]

Removing hasClass shim[edit]

The hasClass shim looks like low-hanging fruit to be removed since almost nothing still using it is likely to have survived other javascript deprecations in mediawiki. I checked the uses - the search returned 33 results:

All results: (exported here via CD's convert to wikitext feature, and then annotated)

  • User:GregU/randomlink.js continue; if ((mw.config.get('wgAction') == "history") != hasClass(link, "mw-userlink")) continue; if (link.hostname... 8 KB (847 words) - 12:46, 29 November 2021
    • 94 users, 6 active, but the script is already broken due to undeclared use of getElementsByClassName, see last section of talk page
  • MediaWiki:LAPI.js error: ' + root.getInnerText ()); } } return doc; }, hasClass : function (node, className) { if (!node) return false; return... 73 KB (8,718 words) - 03:31, 20 November 2023
    • ☒N false positive
  • User:The Editor's Apprentice/randomlink.js continue; if ((mw.config.get('wgAction') == "history") != hasClass(link, "mw-userlink")) continue; if (link.hostname... 9 KB (1,012 words) - 13:45, 27 August 2022
  • User:Kimdime/monobook.js getElementsByTagName('div'); for(var a=0;a<Divs.length;a++){ if(hasClass(Divs[a],"thumbinner")){ var DivThumb = Divs[a]; ... 15 KB (1,368 words) - 16:40, 7 February 2021
    • 1 user
  • User:Pmartin/cache.js } var element_parent = current_link.parentNode; if (hasClass(element_parent, "noarchive")) { continue; } ... 2 KB (265 words) - 03:15, 23 March 2011
    • 2 users
  • User:Ucucha/hiderefs.js getElementsByTagName("sup"); for(var i = 0; i < refs.length; i++) { if(hasClass(refs[i], "reference")) refs[i].style.display = refs_hidden... 1,019 bytes (116 words) - 13:35, 29 November 2021
    • 1 user
  • User:Saintrain/S3/colcol.js //====================================== hasClass ========================================================> var hasClass = (function () { var reCache = {};... 4 KB (460 words) - 20:05, 6 February 2021
    • ☒N false positive
  • User:Cacycle/MooTools.js each(arguments, this.removeProperty, this); return this; }, hasClass: function(className){ return this.className.contains(className... 117 KB (12,449 words) - 04:48, 22 November 2009
    • ☒N false positive
  • User:Ucucha/collapse.js getElementsByTagName( "tr" ); for ( var i = 0; i < Rows.length; i++ ) { if ( hasClass( Rows[i], "row-collapsebutton" ) ) { /* only add button and... 3 KB (246 words) - 04:41, 4 January 2011
    • 0 users
  • User:Verdy p/common.js getElementsByTagName("table"); for (var i = 0; i < Tables.length; i++) { if (hasClass(Tables[i], "collapsible")) { /* only add button and increment... 3 KB (326 words) - 20:24, 30 December 2021
    • 1 user
  • User:Gary/script installer source.js (haystack[i] == needle) return true; } } return false; }; function hasClass(element, classToCheck) { if (typeof(element) == 'undefined' || !element... 52 KB (5,679 words) - 02:36, 29 November 2021
    • ☒N false positive
  • User:PrimeHunter/Diaporama.js DiapoState = Diaporama.Params.Paused[index]; if( (hasClass("Play", Span) && DiapoState == false) || ( (hasClass("Pause", Span)||hasClass("Stop", Span))&&DiapoState==true)... 10 KB (981 words) - 17:46, 18 May 2013
  • User:Cpiral/monobook.js if( !document.getElementById('mw-dismissible-notice') && !(cnote && hasClass(cnote, 'expanded'))) return; appendCSS('#bodyContent { position:relative;... 6 KB (751 words) - 07:03, 5 February 2021
    • 1 user
  • User:Ilmari Karonen/test.js if ( hasClass( xNavChild, 'xNavPic' ) ) { xNavChild.style.display = 'none'; } if ( hasClass( xNavChild... 4 KB (379 words) - 20:14, 23 September 2008
    • 0 users
  • User:Icqa/Collapsing.js collapseColsOptout ) { if ( !hasClass( Rows[i], 'nocollapse' ) && !( hasClass( Rows[i], 'sortbottom' ) && !hasClass( Rows[i], 'collapsible' )... 5 KB (542 words) - 21:49, 3 February 2014
    • 0 users
  • User:Equazcion/DiaporamaFrench.js DiapoState = Diaporama.Params.Paused[index]; if( (hasClass("Play", Span) && DiapoState == false) || ( (hasClass("Pause", Span)||hasClass("Stop", Span))&&DiapoState==true)... 10 KB (981 words) - 18:50, 22 October 2013
    • 0 users
  • User:AvicPublic/HotCatMod.js (href.substring (prefix.length)); } return null; } function hasClass (elem, name) { return (' ' + elem.className + ' ').indexOf (' ' +... 109 KB (11,957 words) - 13:39, 21 February 2021
    • 0 users
  • User:Flatscan/showCCI.js getElementsByTagName("span"); for (var i = 0; i < spans.length; i++) { if (!hasClass(spans[i], CCI_item_hide_class)) { continue; } var itm = spans[i];... 2 KB (156 words) - 23:33, 6 February 2021
    • 1 user
  • User:Gary/functions.js vars['revisions'] = vars['page']['revisions']; } return vars; } function hasClass(element, className) { if (!element || !element.className) return false;... 2 KB (269 words) - 03:55, 21 February 2014
    • ☒N false positive
  • User:Fred Bradstadt/show all collapsed tables.js getElementsByTagName( "table" ); for ( var i = 0; i < Ta.length; i++ ) { if ( hasClass( Ta[i], "collapsible" ) && document.getElementById( "collapseButton" +... 381 bytes (44 words) - 16:41, 27 May 2008
    • 2 users
  • User:TjBison/Collapsing.js collapseColsOptout ) { if ( !hasClass( Rows[i], 'nocollapse' ) && !( hasClass( Rows[i], 'sortbottom' ) && !hasClass( Rows[i], 'collapsible' )... 5 KB (542 words) - 08:09, 23 July 2017
    • 0 users
  • User:EdoDodo/hotcat.js (href.substring (prefix.length)); } return null; } function hasClass (elem, name) { return (' ' + elem.className + ' ').indexOf (' ' +... 99 KB (10,801 words) - 13:40, 21 February 2021
    • 0 users
  • User:Gary Queen/layout.js previousSibling; if ((two && hasClass(two, leftAlignedThumb)) || (three && hasClass(three, leftAlignedThumb)) || (four && hasClass(four, leftAlignedThumb)))... 20 KB (2,241 words) - 23:49, 6 March 2021
    • 0 users
  • User:Samuel Wiki/navonce.js ONCE_NavChild = ONCE_NavChild.nextSibling) { if (hasClass(ONCE_NavChild, 'NavPic') || hasClass(ONCE_NavChild, 'NavContent')) { ONCE_NavChild... 7 KB (716 words) - 13:52, 26 January 2016
    • 0 users
  • User:Dr Brains/RightClicMenu.js for(i=0;i<Navig.length;i++){ if ((hasClass(Navig[i], "portlet" )) || (hasClass(Navig[i], "mw_portlet" )) || (hasClass(Navig[i], "portal" )) ){ ... 132 KB (11,496 words) - 23:34, 6 March 2021
    • 0 users
  • User:Kornatice/vector.js continue; if ((mw.config.get('wgAction') == "history") != hasClass(link, "mw-userlink")) continue; if (link.hostname... 8 KB (845 words) - 23:24, 15 March 2021
    • 1 user
  • User:Giudark/vector.js collapseColsOptout ) { if ( !hasClass( Rows[i], 'nocollapse' ) && !( hasClass( Rows[i], 'sortbottom' ) && !hasClass( Rows[i], 'collapsible' )... 5 KB (542 words) - 22:27, 22 January 2016
    • 1 user
  • User:Kawawish/common.js search(nspat) >= 0) continue; if ((wgAction == "history") != hasClass(link, "mw-userlink")) continue; if (link.hostname... 7 KB (802 words) - 02:11, 7 February 2021
    • 1 user
  • User:Dr Brains/Utilities.js insertBefore(node, referenceNode.nextSibling); } } if(typeof(hasClass)=="undefined"){ function hasClass(node, className) { if (node.className ==... 4 KB (353 words) - 20:22, 21 August 2010
    • ☒N will be unaffected
  • User:Evad37/qunit-2.8.0.js while (i--) { addEvent(elems[i], type, fn); } } function hasClass(elem, name) { return (" " + elem.className + " ").indexOf(" " + name... 183 KB (20,148 words) - 15:50, 1 January 2019
    • ☒N false positive
  • User:Nemoi/common.js getElementById('mw-hidden-catlinks')) ) return; if( hasClass(hc, 'mw-hidden-cats-user-shown') ) return; if( hasClass(hc, 'mw-hidden-cats-ns-shown') ) addClass(hc... 2 KB (191 words) - 02:21, 7 February 2021
    • 1 user
  • User:V.narsikar/common.js i < tableIndex; i++ ) { if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse'... 15 KB (1,736 words) - 21:25, 27 February 2022
    • 1 user
  • User:Kimdime/vector.js getElementsByTagName('div'); for(var a=0;a<Divs.length;a++){ if(hasClass(Divs[a],"thumbinner")){ var DivThumb = Divs[a]; ... 15 KB (1,368 words) - 21:36, 6 February 2021
    • 1 user

If anyone's interested, the simple way to migrate uses is to replace hasClass(A, B) to $(A).hasClass(B). – SD0001 (talk) 11:49, 2 June 2024 (UTC)[reply]

SD0001, did you mean to ping me or PrimeHunter? Primefac (talk) 12:22, 2 June 2024 (UTC)[reply]
oops! – SD0001 (talk) 12:32, 2 June 2024 (UTC)[reply]
I have deleted User:PrimeHunter/Diaporama.js which used hasClass but was just an old unused test. PrimeHunter (talk) 12:48, 2 June 2024 (UTC)[reply]