MediaWiki talk:Common.js: Difference between revisions

From Wikibooks, open books for an open world
Latest comment: 12 years ago by Helder.wiki in topic Bug in MediaWiki:Common.js/RandomBook.js
Jump to navigation Jump to search
Content deleted Content added
Line 65: Line 65:
: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" [http://en.wikibooks.org/?diff=prev&oldid=2055750 added here] to "edit" or change all other 3 "edit"s to "$edit". Best regards. [[:pt:User:Helder.wiki|Helder]] 12:01, 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" [http://en.wikibooks.org/?diff=prev&oldid=2055750 added here] to "edit" or change all other 3 "edit"s to "$edit". Best regards. [[:pt:User:Helder.wiki|Helder]] 12:01, 25 February 2011 (UTC)
::[[File:Yes_check.svg|15px|link=|alt=]] '''Done'''. &ndash;&nbsp;[[User:Adrignola|Adrignola]]&nbsp;<small>[[User talk:Adrignola|discuss]]</small> 14:15, 25 February 2011 (UTC)
::[[File:Yes_check.svg|15px|link=|alt=]] '''Done'''. &ndash;&nbsp;[[User:Adrignola|Adrignola]]&nbsp;<small>[[User talk:Adrignola|discuss]]</small> 14:15, 25 February 2011 (UTC)

== Bug in [[MediaWiki:Common.js/RandomBook.js]] ==

The script is causing the following error when it executes <code>showRandBookLink()</code> on [http://en.wikibooks.org/wiki/Cookbook:Carrot?useskin=nostalgia&debug=1 nostalgia] or [http://en.wikibooks.org/wiki/Cookbook:Carrot?useskin=cologneblue&debug=1 cologneblue] skins on Google Chrome 13.0.782.107:
{| class=wikitable
|-
| Uncaught TypeError: Cannot call method 'getAttribute' of undefined || wikibits.js:287
|-
| window.updateTooltipAccessKeys || wikibits.js:287
|-
| showRandBookLink || index.php:77
|-
| jQuery.event.handle || load.php:1936
|-
| jQuery.event.add.elemData.handle.eventHandle || load.php:1599
|}
[[:pt:User:Helder.wiki|Helder]] 15:35, 9 August 2011 (UTC)

Revision as of 15:35, 9 August 2011

insertGoogleSearch()

The line var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; in insertGoogleSearch() dies in non-monobook skins. —Cryptic (talk) 12:58, 5 April 2007 (UTC)Reply

import_script();

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

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)Reply

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)Reply

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)Reply

By the way... the gadget doesn't work with the vector skin. Helder22:50, 5 July 2009 (UTC)Reply

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)Reply

Done. – Adrignola talk 19:33, 27 June 2010 (UTC)Reply
Thank you. I've made some minor tweaks; could you update it again? --hagindaz (talk) 00:21, 28 June 2010 (UTC)Reply
Done. – Adrignola talk 02:32, 28 June 2010 (UTC)Reply
Thank you. Could you update the CSS again? --hagindaz (talk) 18:20, 29 June 2010 (UTC)Reply
I updated the files. – Adrignola talk 18:50, 29 June 2010 (UTC)Reply
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)Reply
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)Reply
One more update please :) --hagindaz 06:49, 14 July 2010 (UTC)Reply

┌──────────────────────────┘
Done. – Adrignola talk 12:15, 14 July 2010 (UTC)Reply

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)Reply
Done. – Adrignola talk 04:12, 18 July 2010 (UTC)Reply
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)Reply
Done. – Adrignola talk 14:23, 18 July 2010 (UTC)Reply
One more update of the CSS only from User:Hagindaz/per book/French.css please. --hagindaz 23:11, 18 August 2010 (UTC)Reply
Done. – Adrignola talk 23:23, 18 August 2010 (UTC)Reply

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 (discusscontribs) 07:37, 10 February 2011 (UTC)Reply

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)Reply
Maybe MediaWiki:Common.css/ should only be used when wgIsArticle is not true, so only one is used at a time. --darklama 14:04, 10 February 2011 (UTC)Reply

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 edit.wikiEditor is defined and, if not, just return. This was made here. Helder 00:02, 25 February 2011 (UTC)Reply

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)Reply
Done. – Adrignola discuss 14:15, 25 February 2011 (UTC)Reply

Bug in MediaWiki:Common.js/RandomBook.js

The script is causing the following error when it executes showRandBookLink() on nostalgia or cologneblue skins on Google Chrome 13.0.782.107:

Uncaught TypeError: Cannot call method 'getAttribute' of undefined wikibits.js:287
window.updateTooltipAccessKeys wikibits.js:287
showRandBookLink index.php:77
jQuery.event.handle load.php:1936
jQuery.event.add.elemData.handle.eventHandle load.php:1599

Helder 15:35, 9 August 2011 (UTC)Reply