MediaWiki talk:Gadget-HotCat.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


Error induced by local_defaults sub-page (SOLVED)[edit]

I have had HotCat running on MW-1.31 but after upgrading to 1.35 I simply cannot get it to work. It has been hot-loaded from Commons but even statically copying the source code does not work.

In LocalSettings.php, there is $wgUseInstantCommons = true; which should do for enabling cross-origin resource sharing, right? The Gadgets extension is activated and HotCat can be enabled in the user settings. However, it does not appear to function at all.

Activating Debugging including a log-file does not show anything special. Any hints on how to track down the error? Thanks in advance! --Sm8ps (talk) 12:34, 16 July 2021 (UTC)[reply]

@Sm8ps: Do you mean $wgDebugLogFile? That doesn’t record JavaScript errors like gadgets’ errors. Instead you should use client-side debugging tools. —Tacsipacsi (talk) 14:54, 16 July 2021 (UTC)[reply]
@Tacspacsi: Thank you so much for your valuable answer! Indeed, I had set up $wgDebugLogFile and your hint made it clear to me that I had to take the client side approach. Below is the error message I get. Am I the only one experiencing this issue? I shall double-check everything in a short while. — Preceding unsigned comment added by Sm8ps (talk • contribs) 15:37, 16 July 2021 (UTC)[reply]
17:29:58.669 Uncaught ReferenceError: wgArticleId is not defined

So here is what I have found out.

  1. The source page MediaWiki:Gadget-HotCat.js does indeed look for conf.wgArticleId where conf essentially equals mw.config.get( 'wgServer' ). In my LocalSettings.php I had had $wgServer = "https://mediawiki.my.domain";. Removing the protocol part "https:" (but leaving the two slashes as explained in Manual:$wgServer made this error go away and HotCat works an Firefox mobile.
  2. However, it does not work on a desktop version of Firefox. Instead, the error is simply replaced by a different one -- and several things like the ability to edit pages break. The new error complains that the GET https://mediawiki.my.domain/index.php/mediawiki.my.domain/index.php?title=MediaWiki%3AGadget-HotCat.js%2Flocal_defaults&action=raw&ctype=text/javascript results in HTTP/2 403 Forbidden which is easy to understand as the URL contains twice the part "mediawiki.my.domain/index.php/". However, I have at best a very faint idea of what could be the cause.
  3. I have come to wits' end. I tried playing around with $wgServer = "https://mediawiki.my.domain"; and $wgScriptPath=""; to no avail. — Preceding unsigned comment added by Sm8ps (talk • contribs) 18:16, 16 July 2021 (UTC)[reply]
@Sm8ps: Really weird, I have no idea either what’s going on. Hopefully someone else will know it. —Tacsipacsi (talk) 20:45, 16 July 2021 (UTC)[reply]

OK, here comes the solution to this very specific problem! I had imported a non-functional version of the page 'MediaWiki:Gadget-HotCat.js/local defaults'. Presumably I had been following the instructions from https://incubator.wikimedia.org/wiki/MediaWiki:Gadget-HotCat.js/Documentation#Installing_HotCat_on_another_Wiki -- however I cannot tell for sure. The Javascript error resulted from that page but did show up in the debugger console as related to the main Gadget-HotCat.js, probably because that one imports the local defaults page. Deleting that page solved the problems. --Sm8ps (talk) 09:03, 6 November 2021 (UTC)[reply]

Cursor jumping to the end[edit]

I keep having trouble with the cursor jumping to the end of the input. It seems that whenever it automatically uppercases the first letter or removes leading whitespace/underscores, it moves the cursor to the end regardless of where the cursor was before. For example, if the current name is "Example" and the cursor is at the beginning:

  • Pressing "a" turns into "AExample"
  • Pressing the delete key turns into "Xample"
  • Pasting a lowercase word like "another" turns into "AnotherExample"
  • Pressing the space bar removes the space

and then the cursor moves to the end.

It looks like the problem is caused by sanitizeInput and makeActive in the textchange function. The former changes the capitalisation and strips leading whitespace/underscores, and the latter moves the cursor to the end if actualValue.indexOf( expectedInput ) is false, which is the case when the values are the same (indexOf is 0) or when the capitalisation is different (indexOf is -1).

- Nikki (talk) 18:18, 27 July 2021 (UTC)[reply]

+1, this bug is annoying. Let's hope it will be solved eventually. --Enyavar (talk) 13:58, 27 January 2022 (UTC)[reply]
+1 indeed! -- Tuválkin 22:07, 28 January 2022 (UTC)[reply]

Deprecated API queries[edit]

Can someone stop this version of HotCat doing action=query&prop=info&intoken API queries that are deprecated?

See phab:T286551/phab:T280806.

Thanks!

Reedy (talk) 20:35, 3 August 2021 (UTC)[reply]

I've done it now ;) - [1] Reedy (talk) 20:43, 3 August 2021 (UTC)[reply]
@Reedy it doesn’t seem to be working. I fixed a missing character in the URL, but I still get “Uncaught TypeError: can't access property "csrftoken", json.query.tokens is undefined” when loading a file page. Lucas Werkmeister (talk) 21:00, 3 August 2021 (UTC)[reply]
I’ve added |tokens to another API URL, but it still doesn’t work, because apparently HotCat uses callback style to make API requests, and you’re not allowed to get tokens in that mode, IIUC. I’ll see if I can rework that. Lucas Werkmeister (talk) 21:05, 3 August 2021 (UTC)[reply]
I think it’s working again now. Lucas Werkmeister (talk) 21:09, 3 August 2021 (UTC)[reply]

Not respecting minordefault preference[edit]

Hi, the gadget is currently not respecting the minordefault preference. The line

minorEdits = json.query.userinfo.options.minordefault === 1;

should be changed to

minorEdits = json.query.userinfo.options.minordefault === '1';

Thanks! --Porplemontage (talk) 18:37, 10 September 2021 (UTC)[reply]

automatically putting new categories inside <noinclude> tags for DRs?[edit]

I noticed that some users are automatically adding <noinclude> tags when using HotCat to categorize deletion requests. However, this does not happen for me. How do I configure HotCat to insert <noinclude> tags and place new categories inside them for certain pages?

Thanks. Ixfd64 (talk) 06:07, 1 October 2021 (UTC)[reply]

@Ixfd64: I don’t think it’s possible. However, if you disable autocommit – either one-off by clicking the (++) link before the (+) link, or permanently by putting window.hotcat_no_autocommit = 1; in your common.js or global.js file –, you’re brought to the edit form with the category preloaded, and you can manually add the tags. This means two page loads instead of one, but HotCat still helps with autocomplete. —Tacsipacsi (talk) 11:46, 2 October 2021 (UTC)[reply]
Thanks. I'm guessing those users are manually adding the <noinclude> tags before saving the page. Ixfd64 (talk) 17:49, 2 October 2021 (UTC)[reply]

API deprecation notice about rvslots[edit]

The response contains an api deprecation notice.

"Because "rvslots" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."

For both use of rvprop=content the param rvslots=main should be added. Also page.revisions[ 0 ][ '*' ] must changed to page.revisions[ 0 ][ 'slots' ][ 'main' ][ '*' ]. The mediainfo slot does not support categories and is ignored in that case. This is untested. Der Umherirrende (talk) 21:29, 14 January 2022 (UTC)[reply]