MediaWiki talk:Wdsearch-autodesc.js: Difference between revisions

Content deleted Content added
m Obsolete HTML tags "tt" swapped out for "code". Project Lint
 
(37 intermediate revisions by 14 users not shown)
Line 1:
== Add Greek nationalities ==
----------
 
{{editprotected|ans=yes}}
Please add to the list of nationalities:
<sourcesyntaxhighlight lang="javascript">
language_specific : { el : { 'nationality' : {
 
'Αυστρία':'Αυστριακός', 'Ηνωμένες Πολιτείες Αμερικής':'Αμερικανός', 'Σουηδία':'Σουηδός', 'Πολωνία':'Πολωνός', 'Ουκρανία':'Ουκρανός', 'Ιρλανδία':'Ιρλανδός', 'Σερβία':'Σέρβος', 'Γιουγκοσλαβία':'Γιουγκοσλάβος'
 
</syntaxhighlight>
</source>
Thanks. -[[User:Geraki|<fontspan colorstyle="color: green">'''geraki'''</fontspan>]] <sup>[[User_talk:Geraki|T]]</sup><sub class="plainlinks" >[http://en.wikipedia.org/w/index.php?title=Special:Log&type=&user=Geraki L]</sub> 17:32, 14 March 2014 (UTC)
:{{done}} 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. --[[User:Salix alba|Salix alba]] ([[User talk:Salix alba|talk]]): 17:50, 14 March 2014 (UTC)
 
@[[User:Salix alba|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. -[[User:Geraki|<fontspan colorstyle="color: green">'''geraki'''</fontspan>]] <sup>[[User_talk:Geraki|T]]</sup><sub class="plainlinks" >[http://en.wikipedia.org/w/index.php?title=Special:Log&type=&user=Geraki L]</sub> 12:58, 16 March 2014 (UTC)
:{{ping|Geraki L}} Ah yes I see now. Lists merged now. --[[User:Salix alba|Salix alba]] ([[User talk:Salix alba|talk]]): 14:30, 16 March 2014 (UTC)
 
Line 18:
 
{{editprotected|answered=yes}}
I've made a Dutch translation, it can be found on [http://pastebin.com/sHmz14ss 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. {{[[User:Sjoerddebruin|<span style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif" color="#325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif" color="#325186"><small>(talk)</small></Signature}}span>]] 21:29, 15 July 2014 (UTC)
:Ping [[User:Writ Keeper|Writ Keeper]]: ^^ the onwiki request as you requested. :) [[User:Trijnstel|<fontspan colorstyle="color: #064EA3" face="Verdana" size="2">Trijnstel</fontspan>]]<sub>[[User talk:Trijnstel|<fontspan colorstyle="color: #000000">talk</fontspan>]]</sub> 21:34, 15 July 2014 (UTC)
::Done, thanks. [[User:Writ Keeper|Writ&nbsp;Keeper]]&nbsp;[[User Talk: Writ Keeper|&#9863;]][[Special:Contributions/Writ_Keeper|&#9812;]] 21:46, 15 July 2014 (UTC)
 
Line 36:
== Add Polish translation (protected edit request) ==
 
{{edit protected|MediaWiki:Wdsearch-autodesc.js|answered=noyes}}
<!-- Begin request -->
Please add Polish translation, which I already made. It can be found on [http://pastebin.com/VWAEbq8k 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,
Line 42:
[[User:WTM|WTM]] ([[User talk:WTM|talk]]) 15:24, 17 August 2014 (UTC)
:{{ping|WTM}} 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 — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 20:38, 17 August 2014 (UTC)
::{{ping|Mr. Stradivarius}}: Yes, I can see it now. Please use this text [[User:WTM/tmp.js|from my sandbox]]. --[[User:WTM|WTM]] ([[User talk:WTM|talk]]) 23:16, 17 August 2014 (UTC)
:::[[File:Yes check.svg|20px|link=]] '''Done'''<!-- Template:EP --> Thanks! — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 23:22, 17 August 2014 (UTC)
 
== Protected edit request on 8 January 2015 ==
 
{{edit protected|MediaWiki:Wdsearch-autodesc.js|answered=yes}}
<!-- Begin request -->
I've fixed the Dutch translation and trimmed some whitespace, please replace with [https://nl.wikipedia.org/w/index.php?title=Gebruiker:Sjoerddebruin/js&oldid=42954723 this].
<!-- End request -->
[[User:Sjoerddebruin|<span style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif" color="#325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif" color="#325186"><small>(talk)</small></span>]] 20:18, 8 January 2015 (UTC)
:[[File:Yes check.svg|20px|link=]] '''Done'''<!-- Template:EP --> Thanks for the update! — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 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
<syntaxhighlight lang=php>
if (typeof mw !== 'undefined' && typeof prevent_wd_auto_desc === 'undefined' ) { // On Wikidata
$(document).ready( function() {
if ( mw.config.get('wgSiteName') != 'Wikidata' ) return ;
...
</syntaxhighlight>
The comment <syntaxhighlight lang=php inline> // On Wikidata</syntaxhighlight> is on the wrong line, it should be after the test for <code>wgSiteName</code>.
 
2. Why is the script hosted on {{SERVERNAME}} when it only works on wikidata.org?
 
3. It looks like this script started out matching [https://bitbucket.org/magnusmanske/autodesc/src/HEAD/www/js/short_autodesc.js?at=master 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 <code>wd_auto_desc_wd_always_show = true;</code> in my common.js on Wikidata before this script, I never see its generated wikidata auto-description. I can invoke <code>loadItem()</code> by hand by pasting the following into the browser's developer tools JavaScript console:<syntaxhighlight lang=javascript>
wd_auto_desc.loadItem ( "Q2045965" , { callback: function ( q , html , opt ) {
console.log( "AutoDesc for " + q + " item=" + html );
} } ) ;
</syntaxhighlight>
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 [[d: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 <code>{{ARTICLEPAGENAME}}</code> :-) , but a comment mentioning this would be nice. The AutoDesc doesn't display on individual Q''NNNN'' pages as I expected. -- [[User:SPage (WMF)|SPage (WMF)]] ([[User talk: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. -- [[User:SPage (WMF)|SPage (WMF)]] ([[User talk:SPage (WMF)|talk]]) 21:01, 20 August 2015 (UTC)
 
== Improve comments (protected edit request on 20 August 2015) ==
 
{{edit fully-protected|MediaWiki:Wdsearch-autodesc.js|answered=yes}}
<!-- Begin request -->
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 [[#usage is unclear]]. -- [[User:SPage (WMF)|SPage (WMF)]] ([[User talk:SPage (WMF)|talk]]) 22:29, 20 August 2015 (UTC)
<!-- End request -->
[[User:SPage (WMF)|SPage (WMF)]] ([[User talk:SPage (WMF)|talk]]) 22:29, 20 August 2015 (UTC)
:{{done}}. Thanks, [[User:Nakon|<span style="color:#C50;">'''Nakon'''</span>]] 23:35, 20 August 2015 (UTC)
 
== jslint warnings ==
 
If I copy {{ARTICLEPAGENAME}} 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 [https://www.wikidata.org/w/index.php?title=User%3ASPage_%28WMF%29%2FWdsearch-autodesc.js&type=revision&diff=244393005&oldid=244389496 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 ==
{{editrequest|answered=yes}}
Please add <code>'Koninkrijk der Nederlanden':'Nederlands'</code> to the nl-section, will come with more improvements later. [[User:Sjoerddebruin|<span style="color: #325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="color: #325186"><small>(talk)</small></span>]] 19:16, 13 August 2016 (UTC)
:{{notdone}} {{u|Sjoerddebruin}} 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). — [[User:Xaosflux|<span style="color:#FF9933; font-weight:bold; font-family:monotype;">xaosflux</span>]] <sup>[[User talk:Xaosflux|<span style="color:#009933;">Talk</span>]]</sup> 22:49, 14 August 2016 (UTC)
::I think [[Special:Diff/734745225|this]] would do, as the former ones are no official nationalities. [[User:Sjoerddebruin|<span style="color: #325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="color: #325186"><small>(talk)</small></span>]] 12:33, 16 August 2016 (UTC)
:{{u|Sjoerddebruin}} That diff appears to '''remove''' entries, as well as add the new entry - is that what you intend?
 
'''Current''':<br>
<pre>
{'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'}
} ,
</pre>
'''Change to''':{{?}}</br>
::Like I said, I removed those because they are not valid nationalities. [[User:Sjoerddebruin|<span style="color: #325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="color: #325186"><small>(talk)</small></span>]] 23:05, 19 August 2016 (UTC)
:::Hello?!? [[User:Sjoerddebruin|<span style="color: #325186">'''Sjoerd de Bruin'''</span>]] [[User talk:Sjoerddebruin|<span style="color: #325186"><small>(talk)</small></span>]] 21:02, 28 August 2016 (UTC)
::::Hi! {{done}} :) [[User:Legoktm|Legoktm]] ([[User talk: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 [https://www.wikidata.org/wiki/Help:Ranking#Deprecated_rank deprecated rank]? Example: P31 for {{Q|1596}}.
Thanks, --[[User:Aeroid|Aeroid]] ([[User talk: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. <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 23:06, 27 December 2016 (UTC)
 
{{editprotected|answered=yes}}
: [[Special:Diff/756970705|Diff/756970705]] should do the trick. Can anyone apply it and test it, please? <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 00:16, 28 December 2016 (UTC)
:: {{ping|Petr Matas}} 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 [http://api.jquery.com/jquery.grep/ 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 [[Special:Diff/756970705/757143441|this diff]], but I haven't tested the code yet. Could you look over my changes and see if they look ok? Best — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 01:23, 29 December 2016 (UTC)
::: {{ping|Mr. Stradivarius}} 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. <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 05:22, 29 December 2016 (UTC)
:::: {{ping|Petr Matas}} 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 [https://en.wikipedia.org/wiki/Special:ComparePages?page1=&rev1=757138647&page2=&rev2=757176210&action=&diffonly=&unhide= diff] look ok to you now? — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 06:29, 29 December 2016 (UTC)
::::: {{ping|Mr. Stradivarius}} Yes, it does. I am keeping my fingers crossed. ;-) <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 06:41, 29 December 2016 (UTC)
:::::: {{ping|Petr Matas}} Ok, I have put the change up live. Let me know if you notice any strange behaviour. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 07:45, 29 December 2016 (UTC)
::::::: It seems to work as expected. <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 08:10, 29 December 2016 (UTC)
 
== Language selection bugfix ==
 
{{edit fully-protected|answered=yes}}
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 {{u|Magnus Manske}} in [[Special:Diff/600430404|Diff/600430404]]) is ignored.
 
[https://en.wikipedia.org/wiki/Special:ComparePages?page1=MediaWiki%3AWdsearch-autodesc.js&rev1=736636595&page2=User%3APetr+Matas%2FWdsearch-autodesc.js&rev2=756952077&action=&diffonly=&unhide= Here is the fix] to be applied. <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 21:44, 27 December 2016 (UTC)
:[[File:Yes check.svg|20px|link=|alt=]] '''Done'''<!-- Template:EP --> — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 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 [https://www.wikidata.org/w/index.php?search=name&title=Special:Search&profile=advanced&fulltext=1&ns12=1 example search] and [http://storage6.static.itmages.com/i/17/1008/h_1507502125_8121460_1d0b947ee6.png screenshot]. I suggest limiting this gadget to mainspace results, if feasible. [[User:Quiddity|Quiddity]] ([[User talk:Quiddity|talk]]) 18:50, 9 October 2017 (UTC)