Functions and global variables defined by Common.js should be documented in the
CSS and JavaScript catalog, especially if they are of interest to script authors.
To help centralise discussions and keep related topics together, the following talk pages redirect here:
This page has archives. Sections older than 40 days may be automatically archived by Lowercase sigmabot III.
Removing magic editintros
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:
Module:Disambiguation has seen significant improvements over the last year which make it very accurate in detecting disambiguation pages, without any performance impact. It can be used to check whether to include {{disambig editintro}}.
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
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
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
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