Discussion MediaWiki:Gadget-HotCatsMulti.js

Dernier commentaire : il y a 9 ans par Andyrom75 dans le sujet hotcat_SiteCustom

hotcat_SiteCustom modifier

We need support on customization of it:voy:MediaWiki:Gadget-HotCatMulti.js. Could you take a look and suggest any needed changes? Although we have configured hotcat_text_ResumeScript = "[[Aiuto:Gadget-HotCatsMulti|HotCatMulti]] : ";, we keep on seeing a link to Projet:JavaScript/Notices/HotCatsMulti

Thanks, --Andyrom75 (discuter) 12 mars 2015 à 16:25 (CET)Répondre

  Andyrom75 :
You should not have to translate most of the texts. The translation can be managed (for all people using HotCatsMulti) here (ask on the talk page for any change).
Texts you may want to change for your site configuration are :
  • hotcat_text_NoCatTemplate (the "no categories" template name, to be removed when you add a category)
  • hotcat_text_ResumeScript (the text used at the beginning of the edit comments)
  • hotcat_docURL (the link towards the doc, when you click on the legenda)
  • hotcat_HiddenCatsLinkID (the id of a link to show/hide the hidden cats (you may not have this feature enabled, but if you have it, this will permit to copy-paste the link at the right place))
For your problem of non-working configuration, try to define hotcat_SiteCustom() function BEFORE you load the script.
⇨ Dr Brains ∞ Consultation ∞ 12 mars 2015 à 17:48 (CET)Répondre
Même pas vérifié, mais je crois que les scripts sont maintenant encapsulés dans des functions (depuis le Resource Loader). Si c'est bien cela, faut remplacer les var truc par window.truc. od†n ↗blah 12 mars 2015 à 20:31 (CET)Répondre
Dr Brains, although a bit skeptik I've tried your suggestion to invert the order of the functions definition, but unfortunately when they are executed, this order seems to be not relevant.
I would still link the source code here because it's better to centralize its maintenance, so I would just override the definition of those variables. Is it possible that the problem is on the main script instead of the external one?
od†n, I'm not sure I've got your point. Could you rephrase it? --Andyrom75 (discuter) 14 mars 2015 à 15:10 (CET)Répondre
  Andyrom75 :
I edited the main script the way od†n told and it seems to work now : I see the it.voy config working.
A little error remains : hotcat_docURL needs the complete URL, not only the page name.
⇨ Dr Brains ∞ Consultation ∞ 14 mars 2015 à 15:28 (CET)Répondre
  Dr Brains :
Do you mean that I have to write
hotcat_docURL = "//it.wikivoyage.org/wiki/Aiuto:Gadget-HotCatsMulti";
instead of
hotcat_docURL = "Aiuto:Gadget-HotCatsMulti";
?
I still have a doubt about the od†n patch. Assuming that I'm correct on the previous point, does it mean that I have to write it in this way:
window.hotcat_docURL = "//it.wikivoyage.org/wiki/Aiuto:Gadget-HotCatsMulti";
?
Let me know, --Andyrom75 (discuter) 14 mars 2015 à 16:32 (CET)Répondre
  Andyrom75 :
You have to write "//it.wikivoyage.org/wiki/Aiuto:Gadget-HotCatsMulti" (https: is not needed anymore, wikimedia wikis using relative protocols).
The window. object is only needed at the first declaration, in the main script. In your config, you can choose any of the solution, it doesn't matter (but keep it simple and do not use window.)
⇨ Dr Brains ∞ Consultation ∞ 14 mars 2015 à 16:52 (CET)Répondre
@Andyrom75 My comment above was solely for Dr Brains about the script code, and was unrelated to your config. od†n ↗blah 14 mars 2015 à 19:13 (CET)Répondre
Thanks od†n for the clarification.
Dr Brains, we have made a couple of test adding/removing a category but the variable hotcat_text_ResumeScript still show in the summary "[[Projet:JavaScript/Notices/HotCatsMulti|HotCatsMulti]] : " (initialized in your script) instead of "[[Aiuto:Gadget-HotCatsMulti|HotCatMulti]] : " (assigned in our function).
Any idea? --Andyrom75 (discuter) 15 mars 2015 à 09:40 (CET)Répondre
  Andyrom75 :
It works. Did you bypass your cache ?
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 12:38 (CET)Répondre
  Dr Brains :, I'm experiencing a very strange behaviour. If I activate the gadget from the preferences it does NOT work (see test), but if I copy and paste the same code in the console, it works (see test2). Any explanation for this? Maybe it's the cache server side? If so, how to purge it? PS I've already purge my and your page. --Andyrom75 (discuter) 15 mars 2015 à 12:53 (CET)Répondre
Analyzing the session I've noticed that when I activate the gadget from the preferences it's loaded MediaWiki:Gadget-HotCatsMultiCustomEdit.js‎ instead of MediaWiki:Gadget-HotCatMulti.js. Everything seems to be correctly configurated but evidently there's a mistake somewhere that I cannot see. Could you give a look? --Andyrom75 (discuter) 15 mars 2015 à 13:35 (CET)Répondre
  Andyrom75 :
I activated the gadget from my preferences (as you can see in my contribs, I didn't create any .js page), and it worked.
Delete (or blank) MediaWiki:Gadget-HotCatsMultiCustomEdit.js‎. It is not supposed to be used to re-import the gadget, but to define a function hotcat_EditCustom() launched just before the edit (see for example MediaWiki:Gadget-HotCatsMultiCustomEdit.js‎, used here to delete a category in hidden comment on file pages (ns:6) that make HotCats put the categories in the wrong place (inside the hidden comment)). Perhaps the problem comes from here.
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 13:43 (CET)Répondre
Ok I'll delete that .JS. To test correctly the tool, delete your common.js, because it has the same effect of the JS I've created, i.e. forcing the import. --Andyrom75 (discuter) 15 mars 2015 à 13:50 (CET)Répondre
  Andyrom75 :
I forgot that I've created the page. I'm getting too old for these shits...
OK, I think I understand: it is the same problem Od1n talked about.
In it:voy:MediaWiki:Gadget-HotCatMulti.js, try to replace :
function hotcat_SiteCustom(){

	// .... Your stuffs

}
with
window.hotcat_SiteCustom = function(){

	// .... Your stuffs

}
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 14:08 (CET)Répondre
  Dr Brains :, Done (look if it's exactly what you mean) and purged, but apparently nothing has changed.
Previously I was conflicted by your edit, but I was also adding the following:
Considering that it perform an avoidable http request for few lines of code, could it be a good idea to include those lines inside the main script if are strictly necessary? On the other hand, if are not necessary (as I suppose because it address specifically "Catégorie:Image sur Wikipédia"), could be created another window.var to skip its loading setting it at false locally? --Andyrom75 (discuter) 15 mars 2015 à 14:14 (CET)Répondre
  Dr Brains : Eureka! Finally it works! My test was quicker than cache update! :-) Thanks a lot!!!
What about the inner import? --Andyrom75 (discuter) 15 mars 2015 à 14:18 (CET)Répondre
  Andyrom75 :
The import of MediaWiki:Gadget-HotCatsMultiCustomEdit.js‎ is perhaps useless for now, but it could be needed in the future. It doesn't cost a lot because 1 the page is empty, 2 it is cached. So I think it would be better to let it as it is.
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 14:23 (CET)Répondre
  Dr Brains :, as you prefer. Thanks again! --Andyrom75 (discuter) 15 mars 2015 à 14:25 (CET)Répondre
  Andyrom75 :
A last problem in it:voy:MediaWiki:Gadget-HotCatMulti.js ; hotcat_suggestion_delay should be a number.
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 14:27 (CET)Répondre
Done. thanks again. --Andyrom75 (discuter) 15 mars 2015 à 14:54 (CET)Répondre
  Andyrom75 :
No, it is not done. I said number, not string. Delete the quotes around the number.
⇨ Dr Brains ∞ Consultation ∞ 15 mars 2015 à 19:03 (CET)Répondre
  Dr Brains : Now it's really done :-P Thanks for double checking it. --Andyrom75 (discuter) 17 mars 2015 à 23:20 (CET)Répondre
Revenir à la page « Gadget-HotCatsMulti.js ».