MediaWiki talk:Common.js

insertGoogleSearch
The line  in insertGoogleSearch dies in non-monobook skins. &mdash;Cryptic (talk) 12:58, 5 April 2007 (UTC)

import_script;
This function is in wikibits.js as importScript; as of 35064 - all scripts should use that instead so we can remove the old one from Commons.js – Mike.lifeguard  &#124; talk 18:18, 22 May 2008 (UTC)

Performance
I'd strongly recommend replacing this with something that doesn't have to load a large list of pages in background JavaScript; it causes unnecessary slowdowns. It may be possible to do some decent random selection via the MediaWiki API; if not already available, it would not be difficult to add a module to provide it, which can then be queried JS much more efficiently (and function when JS is not available!) --Brion VIBBER (talk) 23:37, 12 November 2008 (UTC)


 * First test version of an API/JS module: User:Splarka/randbook.js (it queries generator=random with limit=10 (max) repeatedly until it finds a page in the book categories). This works because 10.5% of the articles on en.wb are main book pages.
 * Another option would be to use generator=categorymembers&prop=categoryinfo on Category:Alphabetical, to find all 38 categories, and weight them by the number of members, and then randomly choose one, grab the full list, and randomly select a member (~500 at most currently, but not scaleable).
 * Ideally would be 2170 Random page in this category feature (marked as fixed but actually broken/reverted again), but that would require a schema change to add cl_random for efficiency purposes. Or just be broken on big categories. Splarka (talk) 09:31, 13 November 2008 (UTC)

Bug?
Hi!

When I go to MediaWiki:Perbook/X86 Disassembly.css it is shown the following links in the tabs: _|style|_ and _|script|_. There, I another tab with the link _|book|_ that points to "MediaWiki:Perbook", that doesn't exist, instead of point to the original MediaWiki:Perbook/X86 Disassembly.css. What is wrong? Helder19:14, 5 July 2009 (UTC)
 * By the way... the gadget doesn't work with the vector skin. Helder22:50, 5 July 2009 (UTC)

Addition
Could MediaWiki:Perbook/French.css and MediaWiki:Perbook/French.js be added from User:Hagindaz/per book/French.css and User:Hagindaz/per book/French.js? The files include styles that would be difficult to apply inline and optional JavaScript that some readers might find useful. --hagindaz (talk) 19:27, 27 June 2010 (UTC)
 * [[Image:Yes_check.svg|15px| ]] Done. – Adrignola talk 19:33, 27 June 2010 (UTC)
 * Thank you. I've made some minor tweaks; could you update it again? --hagindaz (talk) 00:21, 28 June 2010 (UTC)
 * [[Image:Yes_check.svg|15px| ]] Done. – Adrignola talk 02:32, 28 June 2010 (UTC)
 * Thank you. Could you update the CSS again? --hagindaz (talk) 18:20, 29 June 2010 (UTC)
 * I updated the files. – Adrignola talk 18:50, 29 June 2010 (UTC)
 * Sorry for asking yet again, but I've made a few corrections to the last update. This should be the last one. --hagindaz (talk) 19:18, 29 June 2010 (UTC)
 * Updated. "This should be the last one." Famous last words. :) No problem if you have future corrections. – Adrignola talk 19:20, 29 June 2010 (UTC)
 * One more update please :) --hagindaz 06:49, 14 July 2010 (UTC)

Done. – Adrignola talk 12:15, 14 July 2010 (UTC)
 * Once more, if you could. This update hides optional sections so each lesson is less intimidating and the core of each lesson is more obvious. --hagindaz 03:59, 18 July 2010 (UTC)
 * [[Image:Yes_check.svg|15px| ]] Done. – Adrignola talk 04:12, 18 July 2010 (UTC)
 * One more update; there of course had to be a bug that didn't show up... :) I doubt anyone's had to make a barnstar for exactly this situation before, but thanks for doing this. --hagindaz 04:34, 18 July 2010 (UTC)
 * [[Image:Yes_check.svg|15px| ]] Done. – Adrignola talk 14:23, 18 July 2010 (UTC)
 * One more update of the CSS only from User:Hagindaz/per book/French.css please. --hagindaz 23:11, 18 August 2010 (UTC)
 * [[Image:Yes_check.svg|15px| ]] Done. – Adrignola talk 23:23, 18 August 2010 (UTC)

Perbook CSS
The lines // Import per-page CSS importStylesheet('MediaWiki:Common.css/' + wgBookName); are essentially a duplicate of the CSS part of MediaWiki:Common.js/Perbook.js, which is already imported. --Yair rand (discuss • contribs) 07:37, 10 February 2011 (UTC)


 * Not entirely. Perbook.js imports pages beginning with MediaWiki:Perbook/ while the line above does MediaWiki:Common.css/.  The main instances I know it is used for are MediaWiki:Common.css/Special:RecentChanges and MediaWiki:Common.css/Special:Watchlist for revising the flagged revisions colors.  wgIsArticle may not be true for those special pages for it to take effect through the Perbook.js. – Adrignola discuss 14:00, 10 February 2011 (UTC)
 * Maybe MediaWiki:Common.css/ should only be used when wgIsArticle is not true, so only one is used at a time. --dark lama  14:04, 10 February 2011 (UTC)

MediaWiki:Common.js/Toolbox.js
Hi!

This script is causing an error when a user opens a page like this (which is not editable for non-admins): edit.wikiEditor is not a function https://secure.wikimedia.org/wikibooks/en/w/index.php?title=MediaWiki:Common.js/Toolbox.js&action=raw&ctype=text/javascript Line 170 It seems to be enought to test if  is defined and, if not, just return. This was made here. Helder 00:02, 25 February 2011 (UTC)
 * Uops... I forgot to mention that on pt.wb we had changed the variable name from "edit" to "$edit" (since it's value is get with $(...), this makes it clearer), so you'll need to do another edit to either change the "$edit" added here to "edit" or change all other 3 "edit"s to "$edit". Best regards. Helder 12:01, 25 February 2011 (UTC)
 * Yes_check.svg Done. – Adrignola discuss 14:15, 25 February 2011 (UTC)

Bug in MediaWiki:Common.js/RandomBook.js
The script is causing the following error when it executes  on nostalgia or cologneblue skins on Google Chrome 13.0.782.107: Helder 15:35, 9 August 2011 (UTC)
 * Reported as 30291 82.74.192.60 (discuss) 15:55, 9 August 2011 (UTC)
 * Closed as WONTFIX. Please change MediaWiki:Common.js/RandomBook.js to use  instead. See also JavaScript deprecation & migration overview --Krinkle (discuss • contribs) 15:58, 9 August 2011 (UTC)


 * ✅ --dark lama  17:16, 9 August 2011 (UTC)

Special:Randomrootpage
Since Reedy installed the mw:Extension:Randomrootpage on Wikibooks and Wikisources, this script may not be necessay anymore. Helder 19:49, 30 May 2012 (UTC)

Unescaped slash
Please replace FileRE = new RegExp( '^(?=MediaWiki:' + ( user ? '|User:' + user + '/' : '' ) + ').*\.(js|css)$' ); by FileRE = new RegExp( '^(?=MediaWiki:' + ( user ? '|User:' + user + '/' : '' ) + ').*\\.(js|css)$' ); . Helder 22:48, 30 May 2012 (UTC)


 * Yes_check.svg Done. Please remember that all the subpages of this page redirect to here, so noting that this is at MediaWiki:Common.js/use.js would have been helpful.  Just for reference. – Adrignola discuss 21:56, 31 May 2012 (UTC)
 * I did this yesterday, but hadn't comment yet because I was working to fix other things too. '' disappeared from the above replace request because of its special meaning in wiki syntax. I have escaped it above so it displays correctly now when reading. --dark lama  22:16, 31 May 2012 (UTC)

Possibility to hide content from beginning in CollapseElements.js
At the moment the content is shown and hides slowly, if the user wants to hide it from the beginning. I think it would be better if it is hidden from the beginning with. --David23x (discuss • contribs) 19:28, 29 July 2015 (UTC) I have put the concret changes into User:David23x/JS/CollapseElements.js and User:David23x/CSS/CollapseElements.css, please replace the ontent fron MediaWiki:Common.js/CollapseElements.js with the JS and add the content from the CSS to MediaWiki:Common.js. But i'm not sure whether my changes work. If my proposal is accepted, the templates have to been changed. Maybe in other Wikis too, I know, it will be needed by the German Wikibooks (this can I do problem-free). And sorry for my bad english. -- David23x (discuss • contribs) 17:07, 19 September 2015 (UTC)

Broken JavaScript
MediaWiki developers found that this page probably breaks JavaScript for users (example: not seeing the buttons when editing a page). You probably need to edit this .js page and/or MediaWiki:Gadgets-definition as in the examples at T122755. [/w/index.php?search=insource%3A%2F(mw.util|mw.notify)%2F+-loader.using&title=Special:Search&fulltext=1&ns8=1 List more pages to check].

If you have questions or need help, please ask at T164242. You can login with your wiki account. Best wishes, Nemo 09:49, 14 May 2017 (UTC)

deprecate jquery.async
The pages MediaWiki:Common.js/Toolbox.js and MediaWiki:Gadget-Special characters.js use eachAsync from jquery.async, which will soon be deprecated. It can easily be replaced with promises and the $.when function of jquery. ping as the last user to have made changes to this. TheDJ (discuss • contribs) 23:20, 17 November 2018 (UTC)