Thảo luận MediaWiki:Common.js

Nội dung trang không được hỗ trợ ở ngôn ngữ khác.
Bách khoa toàn thư mở Wikipedia

Give search results even when page doesn't exist[sửa mã nguồn]

Screenshot of the Earth test search, with this script adding links to Wikidata, Reasonator, Commons, and Wikipedia.

Hello, I propose to enable the tool created by Magnus Manske (creator of MediaWiki) to provide results from other languages and Commons (via Wikidata) when a page doesn't exist here: links are added to Special:Search and noarticletext. This helps to encourage translation and to make readers use your wiki more, because they can be sure to find something even if it's not local (rather than searching directly on the biggest wiki). The Italian and Polish Wikipedias, among others already enabled it by default.
Examples: [1] [2] [3]. More information: Magnus blog.
How to: just add the following line at the end of Common.js.

// Results from Wikidata
// [[File:Wdsearch_script_screenshot.png]]
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
	importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}

--Nemo 10:57, ngày 14 tháng 12 năm 2013 (UTC) (comments, translations and last instructions)[trả lời]

☑Y done.--~~~~ thảo luận quên ký tên này là của Cheers! (thảo luận • đóng góp) vào lúc 09:18, ngày 12 tháng 12 năm 2013.
Great, thanks! Sorry for the unclosed pre above. --Nemo bis (thảo luận) 10:57, ngày 14 tháng 12 năm 2013 (UTC)[trả lời]

createNavigationBarToggleButton[sửa mã nguồn]

I noticed Mxn replaced mw.hook("wikipage.content").add(function () { mw.loader.using("jquery.makeCollapsible", function () { createNavigationBarToggleButton(); }); }); by mw.hook("wikipage.content").add(mw.loader.using("jquery.makeCollapsible", createNavigationBarToggleButton)); but as far as I know, mw.hook(...).add only accepts a function or a list of functions as parameters. My suggestion is to use mw.hook("wikipage.content").add(function () { mw.loader.using("jquery.makeCollapsible", createNavigationBarToggleButton); }); instead. Helder 13:39, ngày 28 tháng 7 năm 2014 (UTC)[trả lời]

Đã sửa Thanks! – Nguyễn Xuân Minh (thảo luận, đóng góp) 12:55, ngày 30 tháng 7 năm 2014 (UTC)[trả lời]

Announced JavaScript change for badges implementation[sửa mã nguồn]

Hi! I want to let you know that in near future badges will be deployed on Wikidata and the Wikipedias. They help us with displaying the good and featured article icons next to the sitelinks and will replace the javascript hack which is used at the moment together with the Link GA and Link FA templates. To avoid an overlap where the current system and the new feature conflict, I will add a minor fix to your Common.js which adds the class names to the interwiki links. This is part of my task as a global edit interface editor for the Wikidata team. Thanks, Bene* (thảo luận) 19:23, ngày 11 tháng 8 năm 2014 (UTC)[trả lời]

Phím tắt đến hướng dẫn tải lên tập tin[sửa mã nguồn]

@P.T.Đ: Nhờ bạn sửa liên kết ở dòng 484 thành Wikipedia:Trình tải lên tập tin thay vì Wikipedia:Tải tập tin lên. Không hiểu tại sao khi click liên kết "Tải tập tin lên" thì nó chỉ tới Wikipedia:Trình tải lên tập tin như bình thường còn khi nhấn tổ hợp ALT-SHIFT-U thì nó lại chỉ tới Wikipedia:Tải tập tin lên? – #MASTERENDLESS (thảo luận) 04:38, ngày 16 tháng 9 năm 2021 (UTC)[trả lời]

(Cụ thể) Đổi
/* Cố định liên kết "Tải tập tin lên"
 */
mw.hook("wikipage.content").add(function() {
	$("#t-upload a").attr("href", mw.util.getUrl("Wikipedia:Tải tập tin lên"));
});
thành
/* Cố định liên kết "Tải tập tin lên"
 */
mw.hook("wikipage.content").add(function() {
	$("#t-upload a").attr("href", mw.util.getUrl("Wikipedia:Trình tải lên tập tin"));
});
Tôi thử tại trang mã JS của tôi và thấy có hiệu quả. Nhờ bạn sửa lại, cảm ơn. #MASTERENDLESS (thảo luận) 03:47, ngày 18 tháng 9 năm 2021 (UTC)[trả lời]
☑Y P.T.Đ đã giải quyết xong. Cảm ơn bạn! #MASTERENDLESS (thảo luận) 05:19, ngày 19 tháng 9 năm 2021 (UTC)[trả lời]