MediaWiki talk:Wdsearch.js/Archive 1

Deprecated code
The function addOnloadHook (used at autodesc.js) was deprecated and now causes a warning in the console. Could you replace it by its jQuery equivalent? Helder 17:07, 9 November 2013 (UTC)
 * please can you describe the exact change you are requesting? I'm not familiar with javascript. &mdash; Martin (MSGJ · talk) 12:51, 21 November 2013 (UTC)
 * Hmm, since this code is on Labs, only can fix it (by replacing   ->  ). Helder 12:58, 21 November 2013 (UTC)
 * Done, please check if I broke it... --Magnus Manske (talk) 13:54, 2 December 2013 (UTC)

Script error
Hi, I would like to report a script error. With this search: I see this error in the browser error console: "Error: TypeError: v.claims is undefined Source File: https://en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript Line: 145". Nice tool btw. --Rotpunkt (talk) 20:14, 26 November 2013 (UTC)
 * ✅ - Hoo man (talk) 22:44, 28 November 2013 (UTC)
 * Thanks. Now I have another error at line 151 (TypeError: v.labels is undefined). I think it's just a cut&paste error, it should be:

if ( undefined !== v.labels && undefined !== v.labels[wgUserLanguage] ) { // Label instead of: if ( undefined !== v.descriptions && undefined !== v.labels[wgUserLanguage] ) { // Label
 * --Rotpunkt (talk) 13:11, 2 December 2013 (UTC)
 * Thanks, fixed! --Magnus Manske (talk) 13:55, 2 December 2013 (UTC)

mw.loader.using
All of the $.dialog calls should be wrapped in mw.loader.using('jquery.ui.dialog', function { stuff } ); just to be extra safe. Legoktm (talk) 07:35, 4 December 2013 (UTC)

Don't load external JS
Can we store the JavaScript currently being pulled from tool labs on wiki somewhere? If we enable this as a gadget, we could set it as a dependency so it gets loaded via ResourceLoader. Legoktm (talk) 07:34, 4 December 2013 (UTC)
 * ✅ Legoktm (talk) 06:24, 5 December 2013 (UTC)

Script disabled
The script has been disabled for the line: "importScriptURI("https://tools.wmflabs.org/wikidata-todo/autodesc.js");" that it's executed for each visitor on wikipedia when this script is called from a global common.js. Is it possible to move that script autodesc.js somewhere else? and/or refactor a bit that import stuff? --Rotpunkt (talk) 21:09, 4 December 2013 (UTC)
 * Yes. I'll update it with which fixes the issue once labs stabilizes a bit. Legoktm (talk) 21:47, 4 December 2013 (UTC)
 * ✅ a while back. Legoktm (talk) 06:24, 5 December 2013 (UTC)
 * Thanks! --Rotpunkt (talk) 09:38, 5 December 2013 (UTC)

Language dependant ordering
In some language, as in English, the pattern might be " " (e.g. French politician), but in some other languages, the ordering might be reversed: "  " (e.g. in Indonesian: "politisi Perancis"). Is there any way to reorder the wording? Bennylin (talk) 10:46, 30 December 2013 (UTC)

More robust appending to noarticletext
I'm told that the script doesn't display anything with s:it:MediaWiki:Noarticletext because it doesn't include a table element. I see pl:MediaWiki:Noarticletext doesn't either, nor the default, and this is probably why I don't see anything added to pl:Salticoididae and lb:Salticoididae, unlike it:Salticoididae. Ideas? --Nemo 06:21, 13 December 2013 (UTC)
 * See also meta:Talk:Wikidata, Nemo. --Atlasowa (talk) 20:55, 4 May 2014 (UTC)

hu
Can you add the following translation? Thanks! --Tacsipacsi (talk) 14:05, 4 May 2014 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 11:50, 6 May 2014 (UTC)

encodeURIComponent
Please use  instead of. Using  is necessary for (non-Latin) Unicode characters;   converts some Unicode characters into codes that start with "%u" which are invalid in URLs. 4 instances would need to be replaced. Whym (talk) 09:02, 13 May 2014 (UTC)
 * To clarify, the purpose of the request above is to allow use of the script on other Wikipedias including Japanese and by English Wikipedia users who have one of those affected languages as their user language. This search result page shows how the links given by Wdsearch are broken when one enters a query "東京都千代田区" ("Chiyoda, Tokyo" in Japanese). The second link on the first line of Wdsearch's results points to https://ja.wikipedia.org/wiki/%u5343%u4EE3%u7530%u533A (which gives you a "400 Bad Request" error), while the correct link is ja:千代田区. Whym (talk) 13:10, 14 May 2014 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 21:27, 14 May 2014 (UTC)

I was working a bit on this yesterday, in a couple of cases it should probably be mw.util.wikiurlencode but i will work on it a bit more in the coming days. —Th e DJ (talk • contribs) 07:00, 15 May 2014 (UTC)
 * Thank you for working on this. I failed to find previously but MediaWiki:Wdsearch-autodesc.js has 3 instances of escape too, and would need the same fix, whether it is encodeURIComponent or mw.util.wikiurlencode. Whym (talk) 08:06, 15 May 2014 (UTC)
 * Thanks for the swift fix,, I can confirm that it works for Japanese now. Whym (talk) 11:11, 15 May 2014 (UTC)
 * That last part was reverted by Magnus, so if it is broken again now, I suggest you ask him to fix it. —Th e DJ (talk • contribs) 20:30, 15 May 2014 (UTC)
 * I reverted it because you broke it for external tools. Search here is still broken after your changes; I'll try to find your bug, but keep your condescending tone for someone who buys your BS. Just be more careful next time, OK? --Magnus Manske (talk) 20:14, 19 May 2014 (UTC)
 * condenscending... annoyed at most. —Th e DJ (talk • contribs) 07:20, 20 May 2014 (UTC)

Query error next to search results
Thanks for continued work, but recent changes seem to be a bit too invasive: making a query for each search result hangs my computer. What's worse, I've only seen "Query error" in blue next to reach result; not very helpful. :) --Nemo 15:25, 15 May 2014 (UTC)
 * Yeah noticed the same. Was there anything there before ? I'm not really a user of the script, so I don't remember. To me it looks like that part of the code was written for the Search page on wikidata.org and not actually for the search page of en.wp... —Th e DJ (talk • contribs) 20:36, 15 May 2014 (UTC)
 * I hope this gets fixed soon. -Ash_Crow (talk) 11:31, 17 May 2014 (UTC)
 * No, previously there wasn't anything next to each search result: only at the bottom of the page. --Nemo 16:49, 17 May 2014 (UTC)
 * TheDJ introduced a race condition bug. Fixed now. --Magnus Manske (talk) 20:34, 19 May 2014 (UTC)
 * For future reference, I removed a global variable and made it local without noticing. Accidents like these are one of the reasons implicit globals in JS should be avoided. Thx for fixing Magnus. —Th e DJ (talk • contribs) 07:31, 20 May 2014 (UTC)
 * Thanks a lot, and, for working on this. Whym (talk) 07:45, 7 June 2014 (UTC)

make this a gadget
I just made a simple gadget for this and put it online on the Dutch Wikipedia and Commons. Three steps: Maybe a good idea to do that here too? Multichill (talk) 19:53, 8 January 2015 (UTC)
 * Create MediaWiki:Gadget-Wdsearch.js (nl / Commons)
 * Create MediaWiki:Gadget-Wdsearch (nl / Commons en / Commons nl /)
 * Modify MediaWiki:Gadgets-definition ([//nl.wikipedia.org/w/index.php?title=MediaWiki%3AGadgets-definition&diff=42954042&oldid=42496385 nl] / Commons)

Error: Syntax error, unrecognized expression
On this search on Commons I get: Error: Syntax error, unrecognized expression: #MediaWiki talk:Gadget-AuthorityControl.js/Archive/2014 span.wd_desc. Helder 22:57, 6 July 2015 (UTC)
 * This also happens on wikispecies, when searching for "Template:Sister project links". Helder 16:18, 25 August 2015 (UTC)

Error: Syntax error, unrecognized expression: unsupported pseudo: Sister
Search for "Template:Sister" and it breaks. Helder 16:18, 25 August 2015 (UTC)
 * Also happens for Module:JSON ( Error: Syntax error, unrecognized expression: unsupported pseudo: JSON ). Helder 16:02, 8 September 2015 (UTC)

Potential for XSS Vulnerabilities
I just saw this script today, and frankly it scares me a bit. This seems to make very minimal attempts to prevent XSS vulnerabilities, it just concatenates strings from the API with bits of html and sticks them into the page. I think this needs a full security review and update to follow security best practices. I'm not saying there are for certain vulnerabilities here, just that it is not written in a way that makes it easy to prove that they don't exist. EBernhardson (WMF) (talk) 15:20, 4 November 2015 (UTC)

Script not working on Telugu Wikipedia
Hello,

The Wikidata search script is not working on Telugu Wikipedia. It is linked to the end of Mediawiki:Common.js. --Rahmanuddin Shaik (talk) 09:48, 18 June 2016 (UTC)
 * You have many outdated parts in your Common.js (e.g. tooltips and custom edit buttons should not be declared this way, see on MediaWiki.org). One of the legacy functions is  which can be changed to   safely (as seen at WikiMiniAtlas). I don’t know if this causes the error, but if not, it will soon anyway. —Tacsipacsi (talk) 10:16, 18 June 2016 (UTC)

Title from matched words
Currently if an item's label is not available, the item's title will fall back to the list of words matched by the search, instead of the item's Q number. This behavior is implemented by the following code:

var snip = $(' '+v.snippet+' ') ; $.each ( snip.find('span.searchmatch'), function ( a , b ) {					var txt = $(b).text ;					if ( -1 != $.inArray ( txt , title ) ) return ;					title.push ( txt ) ;				} );

It was implemented by in the [//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&oldid=580458464 initial version] of the script, which did not make use of the labels at all. At that time he probably considered the matched words to be better than the mere Q number. Now the labels are utilized and falling back to the matched words (for missing label) is confusing. Compare the two presentations of the result Johanneskirche (Q26772401) when searching for "rissen":

Therefore I propose to remove or comment out the piece of code above.

More labels will be available if we use the Wikidata's language fallback mechanism: Please add after. Petr Matas 18:33, 29 December 2016 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 14:46, 1 January 2017 (UTC)

Add link to search
Would it be possible to add a link to the complete search results on Wikidata (either on the "Wikidata search results" title or close to that). For example, if I search for "test" on it.wikipedia and I want to switch directly to the results of Wikidata (e.g.). -- Superchilum (talk to me!) 08:10, 27 February 2017 (UTC)
 * I've done a simple patch for this improvement with retro-compatibility. Only if the  field is specified, it shows a link to the complete search page. Here is the diff: Special:Diff/828066868. Thanks for applying. --Valerio Bozzolan (talk) 10:46, 28 February 2018 (UTC)

Translations
To change the header line to your language: add the appropriate line below, and request an admin to update the script.

pt and pt-BR
Hi!

Could you add the following translations? Helder 17:07, 9 November 2013 (UTC)
 * ✅ - Hoo man (talk) 10:41, 11 November 2013 (UTC)

Updated version: Helder 09:15, 5 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:03, 5 December 2013 (UTC)

it
Please add Italian translation "Categoria in Commons", "Voci di Wikipedia", "Risultati da Wikidata". --Nemo 11:37, 17 November 2013 (UTC)
 * ✅ - Hoo man (talk) 16:41, 17 November 2013 (UTC)
 * Please update Italian translation. Thanks! --&beta;16 - (talk) 09:26, 14 October 2015 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:06, 14 October 2015 (UTC)

fr
Could you add the French translation: "Catégorie sur Commons", "Articles sur Wikipédia" and "Résultats sur Wikidata"? Thanks. --Coyau (talk) 10:51, 18 November 2013 (UTC)
 * ✅ --Magnus Manske (talk) 13:58, 2 December 2013 (UTC)

el
Please add Greek (el) translation:

Also in autodesc.js:

and

-- geraki T L 11:37, 18 November 2013 (UTC)
 * ✅ --Magnus Manske (talk) 13:50, 2 December 2013 (UTC)

Please update greek translation as: Thanks. -- geraki  (talk) 09:59, 20 November 2019 (UTC)
 * Geraki - ✅.  ~Oshwah~  (talk) (contribs)   04:14, 24 November 2019 (UTC)

sv
Could you please add the following translation? Cheers/ André Costa (WMSE) (talk) 22:52, 20 November 2013 (UTC)
 * ✅ --Magnus Manske (talk) 13:51, 2 December 2013 (UTC)

bn
please add the following translation. --Aftab1995 (talk) 15:24, 3 December 2013 (UTC)
 * ✅ --Magnus Manske (talk) 00:32, 4 December 2013 (UTC)

please add following line also. --Aftab1995 (talk) 00:41, 7 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:27, 12 December 2013 (UTC)

eo
please add the following translation. Thanks --KuboF (talk) 22:39, 5 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:27, 12 December 2013 (UTC)

sk
please add the following translation. Thanks --KuboF (talk) 22:39, 5 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:27, 12 December 2013 (UTC)

he
please add the following translation for the hebrew wikipedia: Thanks, קובי כרמל (talk) 09:33, 12 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 10:27, 12 December 2013 (UTC)

ilo
Please add the following Ilokano translations.

Thanks. Lam-ang (talk) 15:56, 12 December 2013 (UTC)

Minor correction--Lam-ang (talk) 18:57, 12 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 21:47, 12 December 2013 (UTC)

eu
Please add the Basque translation: Thank you. --Xabier Armendaritz(talk) 21:39, 12 December 2013 (UTC)
 * ✅ --Magnus Manske (talk) 10:46, 13 December 2013 (UTC)

ru
Please add the Russian translation: Thank you. --Kaganer (talk) 12:26, 13 December 2013 (UTC)
 * Yes check.svg Done thank you. Callanecc (talk • contribs • logs) 12:33, 13 December 2013 (UTC)

zh
Please add the Chinese translation: Thanks.  Jianhui67 talk ★ contribs 19:50, 13 December 2013 (UTC)
 * ✅ Rjd0060 (talk) 23:41, 14 December 2013 (UTC)

es
Spanish translation: Thanks. --Kizar (talk) 12:49, 14 December 2013 (UTC)
 * ✅ Rjd0060 (talk) 23:41, 14 December 2013 (UTC)

id
Bennylin (talk)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 14:10, 19 December 2013 (UTC)

udm
--Kaganer (talk) 22:51, 20 December 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 15:06, 23 December 2013 (UTC)

cs
Please add the following translation: Thank you. --Blahma (talk) 15:48, 25 December 2013 (UTC)
 * Yes check.svg Done --Magnus Manske (talk) 11:51, 7 January 2014 (UTC)

gu
Will appreciate if you could add following translation for Gujarati, as I have just enabled it on gu.wiki: Many Thanks.-- DhavalTalk 23:50, 29 December 2013 (UTC)
 * Yes check.svg Done --Magnus Manske (talk) 11:52, 7 January 2014 (UTC)

vi
Would an administrator please add the following Vietnamese translation to MediaWiki:Wdsearch.js:

If you're comfortable with JavaScript, please also merge the following translations into MediaWiki:Wdsearch-autodesc.js:

Thanks!

– Minh Nguyễn (talk, contribs) 08:43, 9 January 2014 (UTC)


 * I've added the translations. The rest still needs to be done. — Mr. Stradivarius  ♪ talk ♪ 17:45, 13 January 2014 (UTC)


 * ✅ all part done now. I've not really tested it so could you test that its working fine.--Salix alba (talk): 10:12, 26 January 2014 (UTC)


 * Yes, it works, thanks! – Minh Nguyễn (talk, contribs) 12:39, 26 January 2014 (UTC)

fa
please add this: Thank you Ladsgroupبحث 10:12, 19 February 2014 (UTC) ✅, see here. Thank you. Rjd0060 (talk) 12:05, 19 February 2014 (UTC)

ur
Please add this: Thanks Muhammad Shuaib (talk) 15:26, 26 April 2014 (UTC)
 * ✅. To Muhammad Shuaib - next time you should use the edit protected template, otherwise admins might not see your request. All the best — Mr. Stradivarius  ♪ talk ♪ 09:28, 13 May 2014 (UTC)

ja
Please add the Japanese ('ja') translations below to the script. Whym (talk) 08:59, 13 May 2014 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 09:21, 13 May 2014 (UTC)

lv
Please add the Latvian ('lv') translations below to the script. --Papuass (talk) 10:16, 25 November 2014 (UTC)

nb and nn
Please add the Norwegian Bokmål ('nb') and Norwegian Nynorsk ('nn') translations below to the script. Jon Harald Søby (talk) 09:21, 6 February 2015 (UTC)


 * ✅ &mdash; Martin (MSGJ · talk) 09:40, 6 February 2015 (UTC)

kk
please add the following translation. Thanks

Arystanbek (talk) 14:44, 8 February 2015 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 23:46, 9 February 2015 (UTC)

de
please replace 'de' with this: Thanks, --CennoxX (talk @ dewiki) 15:17, 19 February 2015 (UTC)
 * Yes check.svg Done — <span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius  ♪ talk ♪ 05:10, 20 February 2015 (UTC)

min

 * Thanks,  Ę-oиė    >>>   ™ 07:25, 31 October 2015 (UTC)
 * &mdash; Martin (MSGJ · talk) 22:01, 31 October 2015 (UTC)

hy

 * Thanks.--ԱշոտՏՆՂ (talk) 13:08, 27 April 2016 (UTC)
 * &mdash; Martin (MSGJ · talk) 13:35, 27 April 2016 (UTC)

ca
Please add transtions to Catalan:
 * Thanks in advance. --Vriullop (talk) 19:55, 26 April 2017 (UTC)
 * Done. Jo-Jo Eumerus (talk, contributions) 15:06, 27 April 2017 (UTC)

ro
Please add the following translations. Thank you. Strainu (talk) 17:07, 16 October 2019 (UTC)
 * Strainu - ✅.  ~Oshwah~  (talk) (contribs)   06:37, 19 October 2019 (UTC)

sw
Please add the following translation. Thanks. Benson Muite (talk) 12:07, 28 January 2020 (UTC)
 * is this meant to be for sw? Your code above has this overriding en. Please confirm and reactivate the edit request when ready. — xaosflux  Talk 14:00, 23 February 2020 (UTC)
 * Changed en to sw Benson Muite (talk) 08:26, 26 February 2020 (UTC)
 * Yes check.svg Done &mdash; Martin (MSGJ · talk) 09:47, 26 February 2020 (UTC)