MediaWiki talk:Common.js/Archive 21: Difference between revisions

Content deleted Content added
m Archiving 2 discussion(s) from MediaWiki talk:Common.js) (bot
m Archiving 2 discussion(s) from MediaWiki talk:Common.js) (bot
Line 95:
 
::{{U|Krinkle}} In short... confusion galore. The naming conventions doesn't help. I thought user.options was part of mw.user (confusion nr.1) and mw.user was stated to be part of mw.map, but not anymore (since today, confucion nr.2). Lastly, there are the base module ''and'' page modules, ''both'' starting with <code>mediawiki.</code> (or <code>.mw</code>?), which creates more confusion. For instance, I do not need to declare <code>mw.config</code>, but I ''do'' need to declare <code>mw.util</code>! ''That'' is why we want a simple list of which of these <code>mediawiki.</code> modules are part of the base module and should not be declared. Then I can happily declare everything else. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:46, 9 April 2014 (UTC)
 
== Move initializeRefTools to a default gadget ==
 
Hi!
 
I would like the [[MediaWiki:Common.js/edit.js|code of RefToolbar]] to be moved into [[MediaWiki:Gadget-refToolbar.js|a default gadget]] (as in [[:pt:MediaWiki:Gadget-refToolbar.js]]), which would be minified and loaded by ResourceLoader. This would also allow users to disable this script, and facilitate debugging (one can easily disable specific gadgets when looking for the cause of a problem).
 
Is there any reason not to do so? [[User:Helder.wiki|Helder.wiki]] 18:38, 7 April 2014 (UTC)
 
:Makes sense, but the pt version loads the core scripts from URLs, bypassing RL. Make those hidden core gadgets so they can be loaded as modules as well. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 20:17, 7 April 2014 (UTC)
::Yep! They are loading those URLs just because the English version is not (yet) made up of small RL modules. I could update them to use English Wikipedia's [//en.wikipedia.org/w/load.php load.php] to get the minified version once the code is migrated to gadgets. [[User:Helder.wiki|Helder.wiki]] 20:25, 7 April 2014 (UTC)
:::I don't think that's proper use of load.php. JS modules are loaded by way of a call to mw.loader.load(). <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 20:51, 7 April 2014 (UTC)
::::What I meant was that other wikis could use something like<br /><syntaxhighlight lang="javascript" enclose="none">mw.loader.load( '//bits.wikimedia.org/en.wikipedia.org/load.php?modules=ext.gadget.EXAMPLE&only=scripts' )</syntaxhighlight><br />instead of<br /><syntaxhighlight lang="javascript" enclose="none">mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-EXAMPLE.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' )</syntaxhighlight><br />to get the minified version of the module <code>ext.gadget.EXAMPLE</code>.
::::Anyway, that is only for other wikis. The loader on English Wikipedia will use just <syntaxhighlight lang="javascript" enclose="none">mw.loader.load( 'ext.gadget.EXAMPLE' )</syntaxhighlight> to load the modules by their names (since they are local). [[User:Helder.wiki|Helder.wiki]] 21:02, 7 April 2014 (UTC)
:::::Yes, but what I meant is; does load.php even support this manner of loading js modules? I've never seen it like this. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:09, 7 April 2014 (UTC)
::::::Never mind, should work in theory. Only plus is minification though. Doesn't save http requests. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:14, 7 April 2014 (UTC)
:::::::Although I've never used it, it seems the external wiki could save http requests if it uses [https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader-method-addSource addSource] and has more than one module to load from English Wikipedia. [[User:Helder.wiki|Helder.wiki]] 21:30, 7 April 2014 (UTC)
::::::FYI: These URLs appears in the "Sources" tab of the Google Chrome console when we [//en.wikipedia.org/wiki/Main_Page?debug=1 load a page in debug mode].
::::::I've [//test.wikipedia.org/w/index.php?title=Special:Contributions/Helder.wiki&dir=prev&offset=20140330191522&limit=9&target=Helder.wiki created a beta <gadget-refToolbar>] on [[testwiki:]]. Could you [[testwiki:Special:Preferences#mw-prefsection-gadgets|enable it on your preferences]] to check if it is working as expected? [[User:Helder.wiki|Helder.wiki]] 21:41, 7 April 2014 (UTC)
:::::::It seems to load OK, but I don't see any extra buttons. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 22:11, 7 April 2014 (UTC)
::::::::{{U|Edokter}}, which edit toolbar you tested? Which extra buttons were missing? [[User:Helder.wiki|Helder.wiki]] 22:27, 7 April 2014 (UTC)
:::::::::I have the enhanced toolbar. Never mind though, I found it. The gadget works. Now it's time to test the rest being converted to core-gadgets. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 22:36, 7 April 2014 (UTC)
{{Od}} Shouldn't there be a consensus for this established on some forum such as VPR before it is implemented here? I am requesting that this consensus be reached before implementation. I don't want to have this as a default thing (as IIRC it conflicts with other tools such as wikEd). — <span class="nowrap">&#123;&#123;U&#124;[[User:Technical 13|Technical 13]]&#125;&#125;</span> <sup>([[User talk:Technical 13|t]] • [[Special:EmailUser/Technical 13|e]] • [[Special:Contribs/Technical 13|c]])</sup> 22:04, 7 April 2014 (UTC)
:There shouldn't be any change in functionality. In fact, the goal is to load less code when not needed by splitting of functional code and only loading a stub loader by default. We have done a similair thing with [[MediaWiki:Gadget-charinsert.js]]. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 22:16, 7 April 2014 (UTC)
:How so, {{U|Technical 13}}? Currently the script is loaded by default. By moving it to a gadget it will be possible to disable it if you don't use it (and even if you use, you should receive less code as a result of the change). [[User:Helder.wiki|Helder.wiki]] 22:23, 7 April 2014 (UTC)
:* We may be talking about different things. I'm reading this as a request to make [[User:ProveIt GT]] a default gadget. — <span class="nowrap">&#123;&#123;U&#124;[[User:Technical 13|Technical 13]]&#125;&#125;</span> <sup>([[User talk:Technical 13|t]] • [[Special:EmailUser/Technical 13|e]] • [[Special:Contribs/Technical 13|c]])</sup> 22:36, 7 April 2014 (UTC)
::*Totally different. Reftoolbar is what you find under the "Cite" section of the enhanced toolbar. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 22:38, 7 April 2014 (UTC)
:::* Which I don't have. I am using wikEd and have {{Myprefs|Editing|uncheck=Show [[help:Edit toolbar|edit toolbar]] (requires JavaScript)}}. — <span class="nowrap">&#123;&#123;U&#124;[[User:Technical 13|Technical 13]]&#125;&#125;</span> <sup>([[User talk:Technical 13|t]] • [[Special:EmailUser/Technical 13|e]] • [[Special:Contribs/Technical 13|c]])</sup> 22:41, 7 April 2014 (UTC)
::::{{U|Technical 13}}, it may not be visible for you, but the the loader code which is at [[MediaWiki:Common.js/edit.js]] is still loaded for you anyway, and what is worse: it also requests [[MediaWiki:RefToolbarBase.js]] and [[MediaWiki:RefToolbarLegacy.js]] (I provided a fix for this specific issue in the [[MediaWiki_talk:Common.js#Protected_edit_request_on_7_April_2014|section below]]). Once the code is converted to a gadget, you will be able to avoid loading these three scripts. [[User:Helder.wiki|Helder.wiki]] 23:03, 7 April 2014 (UTC)
::::* If {{Myprefs|Editing|uncheck=Show [[help:Edit toolbar|edit toolbar]] (requires JavaScript)}} is disabled, then it should automatically detect that and not load that extra code slowing things down. Otherwise, people with that option unchecked will never get to benefit from this change because they will have no clue the change exists. Just my two cents about that. — <span class="nowrap">&#123;&#123;U&#124;[[User:Technical 13|Technical 13]]&#125;&#125;</span> <sup>([[User talk:Technical 13|t]] • [[Special:EmailUser/Technical 13|e]] • [[Special:Contribs/Technical 13|c]])</sup> 23:49, 7 April 2014 (UTC)
:::::Yes, the script should detect that. This is why I requested a separated fix for that problem below. [[User:Helder.wiki|Helder.wiki]] 23:53, 7 April 2014 (UTC)
 
===Edit request===
{{Editprotected|MediaWiki:Gadgets-definition|MediaWiki:Gadget-refToolbar.js|MediaWiki:Common.js/edit.js|MediaWiki:RefToolbar.js|MediaWiki:Gadget-refToolbarBase.js|answered=yes}}
So, {{U|Edokter}}, after testing a gadget version for a while on [[testwiki:]], I believe it is safe to do the following steps on English Wikipedia:
* [[MediaWiki:Gadgets-definition#editing]]: add the lines<pre>* refToolbar[ResourceLoader|default|dependencies=user.options,mediawiki.legacy.wikibits]|refToolbar.js</pre>and<pre>* refToolbarBase[ResourceLoader|hidden|rights=hidden]|refToolbarBase.js</pre>
* Move [[MediaWiki:RefToolbarBase.js]] to [[MediaWiki:Gadget-refToolbarBase.js]]
* [[MediaWiki:Gadget-refToolbarBase.js]]: [[Special:Diff/599725964/603905557|update the code]] to declare the global variables using <code>window.*</code>.
* [[MediaWiki:RefToolbar.js]]: [[Special:Diff/593032107/603904483|update the code and make some fixes]] suggested by jsHint validator
* [[MediaWiki:Gadget-refToolbar.js]]: update the loader with [[Special:Diff/534203339/603903140|these changes]].
* [[MediaWiki:Common.js/edit.js]]: [[Special:Diff/603512406/603903897|remove the code]] which is now in the loader.
* Re-create [[MediaWiki:RefToolbarBase.js]] with<blockquote><syntaxhighlight lang="javascript" enclose="none">mw.log.warn( '[[w:en:MediaWiki:RefToolbarBase.js]] was moved to [[w:en:MediaWiki:Gadget-refToolbarBase.js]].' );</syntaxhighlight><br /><syntaxhighlight lang="javascript" enclose="none">mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-refToolbarBase.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' );</syntaxhighlight></blockquote>for the convenience of other wikis which import this page into their site JS or gadgets
[[User:Helder.wiki|Helder.wiki]] 18:02, 12 April 2014 (UTC)
:All that's needed is a nice description. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 18:51, 12 April 2014 (UTC)
::Sure. I edited my previous comment to suggest descriptive summaries for each step. Feel free to improve on that :-) [[User:Helder.wiki|Helder.wiki]] 20:09, 12 April 2014 (UTC)
:::No... I mean the description for the gadget to go in [[MediaWiki:Gadget-refToolbar]]. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:46, 12 April 2014 (UTC)
::::Which is already there... D'oh. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:46, 12 April 2014 (UTC)
 
:Note that other wikis are pulling the code from its current ___location, so this will either need to be coordinated cross-wiki or the current script locations will need to continue to work. <span style="font-family:Broadway">[[User:Mr.Z-man|Mr.]][[User talk:Mr.Z-man|'''''Z-'''man'']]</span> 20:20, 12 April 2014 (UTC)
::{{U|Mr.Z-man}}, do you mean [[MediaWiki:RefToolbarBase.js]]? It is enough to re-create that page with a "redirect" and a deprecation log as I aded above. [[User:Helder.wiki|Helder.wiki]] 13:02, 13 April 2014 (UTC)
:::I will wait until this is settled. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 21:52, 12 April 2014 (UTC)
:::* Helder is correct, the note that it was moved and the redirect is the best way to go about it. There is no need to wait any longer. :) — <span class="nowrap">&#123;&#123;U&#124;[[User:Technical 13|Technical 13]]&#125;&#125;</span> <sup>([[User talk:Technical 13|t]] • [[Special:EmailUser/Technical 13|e]] • [[Special:Contribs/Technical 13|c]])</sup> 14:37, 15 April 2014 (UTC)
::I opened [[bugzilla:64704|a request on Bugzilla]] and Hoo provided a [https://bugzilla.wikimedia.org/attachment.cgi?id=15264 list of pages on WMF wikis using Reftoolbar from enwiki] so we can send a message to them about this change. [[User:Helder.wiki|Helder.wiki]] 18:58, 1 May 2014 (UTC)
:::I left a note in the talk pages of the affected scripts on other wikis, notifying the users who I believe are the maintainers. [[User:Helder.wiki|Helder.wiki]] 21:57, 1 May 2014 (UTC)
So? [[User:Helder.wiki|Helder.wiki]] 18:43, 19 April 2014 (UTC)
:{{ping|Helder.wiki|Technical 13|Edokter|Mr.Z-man}} is there code in place so that the current script locations will still work after the change, as Mr.Z-man suggested? If not then I should probably mark this edit request as answered until the code is in place, as this request has already been open for 11 days and nothing much seems to be happening with it. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 11:16, 23 April 2014 (UTC)
::Sorry about that. I haven't gotten around to review and test the code myself just yet. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 11:22, 23 April 2014 (UTC)
::{{ping|Mr. Stradivarius}} Yep. In the request above the only script which is being moved to another place is [[MediaWiki:RefToolbarBase.js]], which would be replaced by a "redirect" based on "<code>mw.loader.load</code>". [[User:Helder.wiki|Helder.wiki]] 11:32, 23 April 2014 (UTC)
Do I need to make anything else to get thes changes implemented so I can move on to the other parts of the script? [[User:Helder.wiki|Helder.wiki]] 11:58, 30 April 2014 (UTC)
 
:{{doing}} Expect a few minutes of disruption. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 13:19, 30 April 2014 (UTC)
:{{Done}}. [[WP:REFTOOLS]] will need updating. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 13:38, 30 April 2014 (UTC)
::Thanks {{U|Edokter}}!
::Did you remove the cache parameters "[[mw:Manual:Parameters_to_index.php#Raw|&smaxage=21600&maxage=86400]]" from [[MediaWiki:RefToolbarBase.js]] intentionally? [[User:Helder.wiki|Helder.wiki]] 13:54, 30 April 2014 (UTC)
:::Yes, they serve no purpose; they are the default cache parameters. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 14:23, 30 April 2014 (UTC)
::::{{Ping|Edokter}} You sure? Isn't the default [https://github.com/wikimedia/operations-mediawiki-config/blob/master/wmf-config/InitialiseSettings.php#L10332-L10333 31 days]? The examples from [[mw:RL/MGU#Gadgets]] uses 6 hours and 1 day as above. [[User:Helder.wiki|Helder.wiki]] 16:50, 30 April 2014 (UTC)
:::::OK, not entirely sure; the headers returned to me (over HTTP and HTTPS) always return zero. But I do notice that raw content is always 'fresh', so it seems to ignore those values. Perhaps someone else can explain the necessity/obsolescence of <code>&smaxage=21600&maxage=86400</code> for raw content. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 19:11, 30 April 2014 (UTC)
 
== Is RefToolbar being executed on pages where it shouldn't? ==
 
Most of the code of [[MediaWiki:RefToolbar.js|version 2.0b (dialogs)]] is inside of a test like this:
<syntaxhighlight lang="javascript" highlight="5,6">
// Only execute on edit, unless it is a user JS/CSS page
// TODO: Remove tests already done by [[MediaWiki:Gadget-refToolbar.js]]
if (
( mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit' ) &&
( ( mw.config.get('wgNamespaceNumber') !== 2 && mw.config.get('wgNamespaceNumber') !== 4 ) ||
( mw.config.get('wgPageName').indexOf('.js') === -1 && mw.config.get('wgPageName').indexOf('.css') === -1 ) )
) { ... }
</syntaxhighlight>
On the other hand, the highlighted tests are missing on versions [[MediaWiki:RefToolbarNoDialogs.js|2.0a (no dialogs)]] and [[MediaWiki:RefToolbarLegacy.js|1.0. (legacy)]]. Is that the desired behavior? Shouldn't all versions be present in the same set of pages/namespaces?
* If the answer is yes, we could make all these tests just before calling "$( initializeRefTools )" on [[MediaWiki:Gadget-refToolbar.js]], to avoid loading other parts unnecessarily.
* If not, they could still be moved to the loader, but would be inside the if-block which loads the version 2.0b
[[User:Helder.wiki|Helder.wiki]] 21:43, 30 April 2014 (UTC)
:What do you think, {{U|Mr.Z-man}}, {{U|Edokter}}? [[User:Helder.wiki|Helder.wiki]] 19:37, 1 May 2014 (UTC)
::I wouldn't bother with the old toolbar, but ideally, yes, the tests should be for all versions. <span style="font-family:'Trebuchet MS'"> — [[User:Edokter|<span style="color:#008"><i>E</i>dokter</span>]] ([[User talk:Edokter|<span style="color:#080">talk</span>]]) — </span> 19:44, 1 May 2014 (UTC)
::I don't think it really makes much of a difference whether its loaded on CSS/JS pages or not, but if we're going to do it, doing the checks as early as possible would be best. <span style="font-family:Broadway">[[User:Mr.Z-man|Mr.]][[User talk:Mr.Z-man|'''''Z-'''man'']]</span> 21:17, 1 May 2014 (UTC)
:A better check might be mw.config.get('wgPageContentModel') !== 'wikitext'. [[User:Legoktm|Legoktm]] ([[User talk:Legoktm|talk]]) 23:43, 18 May 2014 (UTC)
::Agreed. [[User:Kaldari|Kaldari]] ([[User talk:Kaldari|talk]]) 00:37, 19 May 2014 (UTC)