Add debounce on api calls

It would be good to apply a debounce technique when calling the API, instead of just delaying the api call. If the user continues typing, there's no need to call the api for suggestions on every keystroke (hammering the server unnecessarily), but instead do only one call every suggest_delay.

This technique is described here: https://css-tricks.com/debouncing-throttling-explained-examples/#debounce

I've implemented it here, with the bonus that there will be one call every suggest_delay even if the user doesn't stop typing. --Ciencia Al Poder (talk) 15:26, 22 November 2020 (UTC)[]

Mobile view

Categories in mobile view now behave like in Desktop view. But HotCat doesn't work correctly, for example category suggestions are barely readable. --Discostu (talk) 09:24, 12 June 2021 (UTC)[]

Yes, I have this exact same issue, and it's driving me nuts. The suggestions get jumbled due to overlapping the underlying text, can't read anything or click anything properly. The older version where it would take you to a new page for adding / removing categories was much better. STC1 (talk) 03:55, 10 July 2021 (UTC)[]

How to trouble-shoot?

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)[]

@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)[]
@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)[]
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)[]
@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)[]

Cursor jumping to the end

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)[]

Deprecated API queries

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)[]

I've done it now ;) - [1] Reedy (talk) 20:43, 3 August 2021 (UTC)[]
@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)[]
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)[]
I think it’s working again now. Lucas Werkmeister (talk) 21:09, 3 August 2021 (UTC)[]

Not respecting minordefault preference

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)[]

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

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)[]

@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)[]
Thanks. I'm guessing those users are manually adding the <noinclude> tags before saving the page. Ixfd64 (talk) 17:49, 2 October 2021 (UTC)[]