MediaWiki talk:Wdsearch-autodesc.js

Add Greek nationalities
Please add to the list of nationalities: Thanks. - geraki T L 17:32, 14 March 2014 (UTC)
 * ✅ I added the appropriate closing brackets. You might want to check the list did not get truncated as the list of language seemed rather small. --Salix alba (talk): 17:50, 14 March 2014 (UTC)

@Salix alba. There was some confusion here. There was already a list for el. I just wanted to add to the existing list, five rows higher from what it was added (that's why I had'n added closing brackets - I only mentioned where it should be added). Please merge the two lists. - geraki T L 12:58, 16 March 2014 (UTC)
 * Ah yes I see now. Lists merged now. --Salix alba (talk): 14:30, 16 March 2014 (UTC)

Add Dutch translation
I've made a Dutch translation, it can be found on Pastebin. I've posted the whole script on Pastebin (because of the complicated translation-system of this script), so it's just copy-and-paste. Sjoerd de Bruin  (talk)   21:29, 15 July 2014 (UTC)
 * Ping Writ Keeper: ^^ the onwiki request as you requested. :) Trijnstel talk 21:34, 15 July 2014 (UTC)
 * Done, thanks. Writ Keeper &#9863;&#9812; 21:46, 15 July 2014 (UTC)

Protected edit request on 16 August 2014
Please add the following lines to provide origin for organizations and groups of people, based on country of origin (P495) and headquarters location (P159):
 * => See diff on local version of WD User:Laddo userpage

This change improves descriptions such as this family or this band or this company.

Laddo (talk) 15:23, 16 August 2014 (UTC)
 * ✅--Salix alba (talk): 16:39, 16 August 2014 (UTC)

Add Polish translation (protected edit request)
Please add Polish translation, which I already made. It can be found on Pastebin. You should only copy and paste. Aw, this was not an easy translation task, as in inflecting language we have complicated declension. Also adjectives decline in Polish for gender (British actor is described by the adjective brytyjski, but British actress is described by the adjective brytyjska. Thus, I was forced to create unisex forms like: brytyjski/a). Thanks,

WTM (talk) 15:24, 17 August 2014 (UTC)
 * You've changed a lot of the whitespace in the file, which makes it hard to read the diff of your change. Could you post it again, this time preserving the whitespace? Best — Mr. Stradivarius  ♪ talk ♪ 20:38, 17 August 2014 (UTC)
 * Yes, I can see it now. Please use this text from my sandbox. --WTM (talk) 23:16, 17 August 2014 (UTC)
 * Yes check.svg Done Thanks! — Mr. Stradivarius  ♪ talk ♪ 23:22, 17 August 2014 (UTC)

Protected edit request on 8 January 2015
I've fixed the Dutch translation and trimmed some whitespace, please replace with this.

Sjoerd de Bruin  (talk)   20:18, 8 January 2015 (UTC)
 * Yes check.svg Done Thanks for the update! — Mr. Stradivarius  ♪ talk ♪ 20:33, 8 January 2015 (UTC)

usage is unclear
I think this is amazing, but it needs better explanation. Is there some page that explains it?

1. It appears to only does something on https://www.wikidata.org, right? So the comment should say "To add this to your common.js page on wikidata.org:"

Also in the code The comment  is on the wrong line, it should be after the test for.

2. Why is the script hosted on when it only works on wikidata.org?

3. It looks like this script started out matching Magnus Manske's AutoDesc code, but there's no mention of this in comments except the vague "The code hosted here also runs OUTSIDE of mediawiki scopes". Also the JavaScript on-wiki has drifted from the JS in that project.

4. It's unclear what it does on Wikidata. How do I know it's working? Even if I set  in my common.js on Wikidata before this script, I never see its generated wikidata auto-description. I can invoke  by hand by pasting the following into the browser's developer tools JavaScript console: and then it displays teh AutoDesc awesomeness:
 * "AutoDesc for Q2045965 item=Indian author and autobiographer (*1940); Padma Shri and Sahitya Akademi Award; spouse of Surinder Singh ♀"

I'm not sure where this description is supposed to appear on the Wikidata page Q2045965.
 * I figured 4. out, the AutoDesc short descriptions appear on wikidata's d:Special:Search results page and in the search suggestions dropdown on www.wikidata.org that appears when you enter "Padma S...". This is obvious from the script name  :-), but a comment mentioning this would be nice. The AutoDesc doesn't display on individual QNNNN pages as I expected. -- SPage (WMF) (talk) 21:50, 20 August 2015 (UTC)

Thanks for any elucidation, and maybe someone with rights can add comments to the script clarifying these. -- SPage (WMF) (talk) 21:01, 20 August 2015 (UTC)

Improve comments (protected edit request on 20 August 2015)
https://www.wikidata.org/w/index.php?title=User:SPage_%28WMF%29/Wdsearch-autodesc.js&oldid=244389496 adds and improves comments that avoid my confusion in. -- SPage (WMF) (talk) 22:29, 20 August 2015 (UTC)

SPage (WMF) (talk) 22:29, 20 August 2015 (UTC)
 * ✅. Thanks,  Nakon  23:35, 20 August 2015 (UTC)

jslint warnings
If I copy and edit it, the jslint in the code editor (extension CodeEditor I think) warns about various coding issues, as does standalone JSHint. Some of them have uncontroversial fixes, I made them in this diff. With these fixes I'm down to no warnings and one error, but the latter is "Too many errors. (34% scanned)." Other warnings involving tests for null and falsy require more consideration.

Koninkrijk der Nederlanden
Please add  to the nl-section, will come with more improvements later. Sjoerd de Bruin  (talk)   19:16, 13 August 2016 (UTC)
 * I'm not sure "exactly" what you want done. Can you please provide a current line as-is, and with your change included below?  (Then reactivate the edit request). —  xaosflux  Talk 22:49, 14 August 2016 (UTC)
 * I think this would do, as the former ones are no official nationalities. Sjoerd de Bruin   (talk)   12:33, 16 August 2016 (UTC)
 * That diff appears to remove entries, as well as add the new entry - is that what you intend?

Current: {'Ecuador':'Ecuadoraans','Ghana':'Ghanees','Rusland':'Russisch','Argentinië':'Argentijns','Australië':'Australisch','Oostenrijk':'Oostenrijks','België':'Belgisch','Brazilië':'Braziliaans','Canada':'Canadees','Chili':'Chileens','China':'Chinees','Denemarken':'Deens','Finland':'Fins','Faeröer':'Faeröers','Nederland':'Nederlands','Puerto Rico':'Puerto Ricaans','Frankrijk':'Frans','Luxemburg':'Luxemburgs','Duitsland':'Duits','Griekenland':'Grieks','Holland':'Nederlands','Hongarije':'Hongaars','IJsland':'IJslands','India':'Indiaas','Iran':'Iranees','Irak':'Irakees','Ierland':'Iers','Israël':'Israëlisch','Indonesië':'Indonesisch','Italië':'Italiaans','Japan':'Japans','Jamaica':'Jamaicaans','Jordanië':'Jordaans','Mexico':'Mexicaans','Nepal':'Nepalees','Nieuw-Zeeland':'Nieuw-Zeelands','Noorwegen':'Noors','Pakistan':'Pakistaans','Paraguay':'Paraguayaans','Peru':'Peruaans','Polen':'Pools','Roemenië':'Roemeens','Schotland':'Schots','Zuid-Afrika':'Zuid-Afrikaans','Spanje':'Spaans','Zwitserland':'Zwitsers','Syrië':'Syrisch','Thailand':'Thais','Turkije':'Turks','VS':'Amerikaans','Uruguay':'Uruguayaans','Venezuela':'Venezolaans','Wales':'Welsh','Verenigd Koninkrijk':'Brits','Verenigde Staten van Amerika':'Amerikaans','Zweden':'Zweeds'} }, Change to:
 * Like I said, I removed those because they are not valid nationalities. Sjoerd de Bruin   (talk)   23:05, 19 August 2016 (UTC)
 * Hello?!? Sjoerd de Bruin   (talk)   21:02, 28 August 2016 (UTC)
 * Hi! ✅ :) Legoktm (talk) 21:12, 28 August 2016 (UTC)

Please ignore claims marked with deprecated rank
Would you be able to avoid listing claims that are marked with a deprecated rank? Example: P31 for. Thanks, --Aeroid (talk) 06:49, 26 October 2016 (UTC)

If any claim with preferred rank is present, then claims with normal rank should be hidden as well. Petr Matas 23:06, 27 December 2016 (UTC)


 * Diff/756970705 should do the trick. Can anyone apply it and test it, please? Petr Matas 00:16, 28 December 2016 (UTC)
 * I spotted two things which I think are bugs in the filterClaims function. The first is the $.each syntax - the first parameter to the callback function is the array index, not the value. The second is the use of $.grep in a loop. According to the docs, this function alters the existing array. It would work fine on the first iteration if there are any preferred statements, but as the original values array is altered, on the second iteration $.grep would be working with an empty array (it has no preferred statements, and any normal or deprecated statements were removed in the first iteration). I've fixed both of these bugs in this diff, but I haven't tested the code yet. Could you look over my changes and see if they look ok? Best — Mr. Stradivarius  ♪ talk ♪ 01:23, 29 December 2016 (UTC)
 * Thank you for your review. Your fix of the $.each syntax seems correct. Concerning $.grep, its docs say that "The original array is not affected." Therefore I believe that the two versions are equivalent, except that Array.prototype.filter is only supported since IE 9. Petr Matas 05:22, 29 December 2016 (UTC)
 * Ah yes, you're quite right. Sorry about that. We should probably go with the version that is better supported, in that case. I've restored $.grep in your version - does the diff look ok to you now? — Mr. Stradivarius  ♪ talk ♪ 06:29, 29 December 2016 (UTC)
 * Yes, it does. I am keeping my fingers crossed. ;-) Petr Matas 06:41, 29 December 2016 (UTC)
 * Ok, I have put the change up live. Let me know if you notice any strange behaviour. — Mr. Stradivarius  ♪ talk ♪ 07:45, 29 December 2016 (UTC)
 * It seems to work as expected. Petr Matas 08:10, 29 December 2016 (UTC)

Language selection bugfix
There is a bug in this script. If the label in user's language is not present in the Wikidata item, then the first available language is used and the list of fallback languages (introduced by in Diff/600430404) is ignored.

Here is the fix to be applied. Petr Matas 21:44, 27 December 2016 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 00:47, 29 December 2016 (UTC)

Limit to mainspace to reduce query errors
If I search the help-namespace (using the inputbox at the main help:contents page), I get query errors for all results. See example search and screenshot. I suggest limiting this gadget to mainspace results, if feasible. Quiddity (talk) 18:50, 9 October 2017 (UTC)