คุยเรื่องมีเดียวิกิ:Common.js

ไม่รองรับเนื้อหาของหน้าในภาษาอื่น
จาก วิกิซอร์ซ

ตอนนี้คงต้องเปลี่ยนเนมสเปซของ "หน้าหลัก" จากหน้าบทความ เป็นหน้าหลักครับ เพื่อป้องกันการปะปนกันระหว่างหน้าหลักกับหน้าเอกสารครับ จากโค้ต

//

/**
 * เปลี่ยนแท็บสเปซของ 'หน้าหลัก' จาก 'บทความ' เป็น 'หน้าหลัก'
 *
 * ต้นฉบับจาก http://en.wikipedia.org/wiki/MediaWiki:Common.js
 */
function mainPageRenameNamespaceTab() {
  try {
    var Node = document.getElementById('ca-nstab-main').firstChild;
    if (Node.textContent) {      // Per DOM Level 3
      Node.textContent = 'หน้าหลัก';
    } else if (Node.innerText) { // IE doesn't handle .textContent
      Node.innerText = 'หน้าหลัก';
    } else {                       // Fallback
      Node.replaceChild(Node.firstChild, document.createTextNode('หน้าหลัก'));
    }
  } catch(e) {
    // bailing out!
  }
}
 
if (wgTitle == 'หน้าหลัก' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 )) {
  addOnloadHook(mainPageRenameNamespaceTab);
}
 
if (wgTitle == 'หน้าหลัก' && wgNamespaceNumber == 0) {
  addOnloadHook(mainPageAppendCompleteListLink);
}
 
function mainPageAppendCompleteListLink() {
     try {
         var node = document.getElementById( "p-lang" )
                            .getElementsByTagName('div')[0]
                            .getElementsByTagName('ul')[0];
 
         var aNode = document.createElement( 'a' );
         var liNode = document.createElement( 'li' );
 
         aNode.appendChild( document.createTextNode( 'ทุกภาษา' ) );
         aNode.setAttribute( 'href' , 'http://meta.wikimedia.org/wiki/List_of_Wikipedias' );
         liNode.appendChild( aNode );
         liNode.style.fontWeight = 'bold';
         node.appendChild( liNode );
      } catch(e) {
        // lets just ignore what's happened
        return;
     }
 }
//


(โค้ดด้านล่างนี้เอามาจากวิกิพีเดียไทย) --Mopza พูดคุย-ฝากคำถาม 14:09, 15 กุมภาพันธ์ 2552 (ICT)

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
// 
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 ~~~~~ (comments, translations and last instructions)