โค้ดแทนที่ชื่อบทความ & pickUpTextInternal() แก้

โค้ดแทนที่ชื่อบทความ และ ฟังก์ชัน pickUpTextInternal นำมาจาก http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=raw&ctype=text/javascript

-- bact' 07:51, 11 เมษายน 2007 (UTC)

Give search results even when page doesn't exist แก้

 
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 21:37, 12 ธันวาคม 2556 (ICT) (comments, translations and last instructions)

  สำเร็จ --Nullzero (พูดคุย) 21:37, 12 ธันวาคม 2556 (ICT)

Announced JavaScript change for badges implementation แก้

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* (พูดคุย) 02:22, 12 สิงหาคม 2557 (ICT)

Thank you :) --Nullzero (พูดคุย) 02:35, 12 สิงหาคม 2557 (ICT)

แจ้งโค้ดที่ไม่ได้ใช้ที่ควรจะลบออก (1) แก้

บรรทัด 55 ถึง 81 (linkFA) แก้

ซึ่งก็คือ

/** Interwiki links to featured articles ***************************************
 *
 *  Description: Highlights interwiki links to featured articles (or
 *               equivalents) by changing the bullet before the interwiki link
 *               into a star.
 *  Maintainers: [[User:R. Koot]]
 */
 
function LinkFA() 
{
    if ( document.getElementById( "p-lang" ) ) {
        var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
 
        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
        	var className = InterwikiLinks[i].className.match(/interwiki-[-\w]+/);
            if ( document.getElementById( className + '-fa' ) && InterwikiLinks[i].className.indexOf( 'badge-featuredarticle' ) === -1 ) {
                InterwikiLinks[i].className += " FA";
                InterwikiLinks[i].title = "บทความนี้เป็นบทความคัดสรรในภาษาอื่น";
            } else if ( document.getElementById( className + '-ga' ) && InterwikiLinks[i].className.indexOf( 'badge-goodarticle' ) === -1 ) {
                InterwikiLinks[i].className += " GA";
                InterwikiLinks[i].title = "บทความนี้เป็นบทความคุณภาพในภาษาอื่น";
            }
        }
    }
}
 
mw.hook( 'wikipage.content' ).add( LinkFA );

เนื่องจาก

  1. มี wikidata แทนแล้ว
  2. ในการเรียกโค้ดนี้ ต้องใช้ class ซึ่งเดิมสร้างขึ้นมาผ่าน {{Link GA}} และ {{Link FA}} แต่ปัจจุบันไม่มีทั้งสองแม่แบบแล้วทำให้ไม่ได้ใช้งาน
  3. ทดสอบด้วยการเปิด ?safemode=1 แล้วไม่พบผลกระทบที่เกิดจากการที่โค้ดนี้หายไป

บรรทัด 286 ถึง 290 แก้

ซึ่งก็คือ

/* Fixes for Windows XP font rendering */
if (navigator.appVersion.search(/windows nt 5/i) != -1) {
    mw.util.addCSS('.IPA {font-family: "Lucida Sans Unicode", "Arial Unicode MS";} ' + 
                   '.Unicode {font-family: "Arial Unicode MS", "Lucida Sans Unicode";}');
}

เนื่องจาก Windows XP ไม่มีคนใช้แล้ว (หรือมีใช้ก็น้อยมาก ๆ) จึงคิดว่าถึงเวลาสมควรที่จะยกเลิก

บรรทัด 500 ถึง 507 แก้

ซึ่งก็คือ

/**
 * Description: Stay on the secure server as much as possible
 * Maintainers: [[User:TheDJ]]
 */
if ( document.location && document.location.protocol === 'https:' ) {
    /* New secure servers */
    mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Common.js/secure new.js&action=raw&ctype=text/javascript");
}

เนื่องจากไม่มีแล้ว

Bebiezaza (คุย) 22:54, 18 ตุลาคม 2565 (+07)ตอบกลับ

  สำเร็จ ขอบคุณมากครับ --Geonuch (คุย) 22:50, 20 ตุลาคม 2565 (+07)ตอบกลับ

แจ้งโค้ดไม่ได้ใช้ที่สมควรจะลบออก (2) : บรรทัดที่ 55 ถึง 198 (Caractères spéciaux/Special Characters/Charinsert ยุคเก่า) แก้

ซึ่งก็คือ

/*
Caractères spéciaux
-------------------

Ajouter un menu pour choisir des sous-ensembles de caractères spéciaux.
Ecrit par Zelda, voir sur [[Utilisateur:Zelda/Edittools.js]].
Remplace l'ancienne fonction par une variante plus rapide.
*/

/**
 * Ajoute un menu déroulant permettant de choisir un jeu de caractères spéciaux
 * Les caractères spéciaux sont définis dans Mediawiki:Edittools
 */
function addCharSubsetMenu() {
  var specialchars = document.getElementById('specialcharsets');
  if (!specialchars) return;

  // Construction du menu de selection
  var charSubsetSelect = document.createElement("select");
  charSubsetSelect.setAttribute("style", "display:inline");
  charSubsetSelect.onchange = function () {
    chooseCharSubset(this.selectedIndex);
  };
  
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .

/**
 * Permet d'ajouter d'un jeu de caractères spéciaux dans le menu déroulant
 * paramètres :
 * - nom du jeu de caractères
 * - caractères spéciaux
 * exemple d'utilisation : addSpecialCharset("Français", "â ê î ô û");
 */
function addSpecialCharset(title, chars) {
  addSpecialCharsetHTML(title, "<span>" + chars + "</span>");
}

เนื่องจาก

  1. ในปัจจุบัน MediaWiki:Edittools ได้มีการปรับปรุงใหม่ ทำให้โค้ดดังกล่าวไม่สามารถจับ HTMLElement ที่ต้องการได้ โค้ดจึงหยุดทำงานตั้งแต่เริ่มแรก (หยุดที่บรรทัด 70)
  2. ถึงจะมีการปรับปรุง MediaWiki:Edittools แต่จากที่ตรวจสอบดูก็เหมือนว่าไม่ได้มีการใช้งาน เพราะมีแกเจ็ต MediaWiki:Gadget-charinsert เข้ามาทำหน้าที่แทนไปแล้ว ยิ่งทำให้โค้ดนี้ดูไร้บทบาทไปใหญ่

ทั้งนี้ แจ้งลบเพื่อลดจำนวนองค์ประกอบที่ต้องโหลดในทุกหน้าเช่นเคยครับ --Bebiezaza (คุย) 23:28, 21 ตุลาคม 2565 (+07)ตอบกลับ

  สำเร็จ --Geonuch (คุย) 12:39, 22 ตุลาคม 2565 (+07)ตอบกลับ
กลับไปที่หน้า "Common.js"