Pengguna:FBN122645/SidebarTranslation.js

Revisi sejak 10 Oktober 2020 01.55 oleh FBN122645 (bicara | kontrib) (←Membuat halaman berisi '// _____________________________________________________________________________________ // |...')
(beda) ← Revisi sebelumnya | Revisi terkini (beda) | Revisi selanjutnya → (beda)

Catatan: Setelah menyimpan, Anda harus memintas tembolok (cache) peramban Anda untuk melihat perubahannya. Google Chrome, Firefox, Microsoft Edge dan Safari: Tahan tombol Shift dan klik Muat ulang (Reload) di tombol bilah alat. Untuk detail dan instruksi tentang peramban lain, lihat halaman menghapus singgahan (Inggris).

//  _____________________________________________________________________________________
// |                                                                                     |
// |                    === WARNING: GLOBAL GADGET FILE ===                              |
// |                  Changes to this page affect many users.                            |
// | Please discuss changes on the [[Wiktionary:Grease Pit]] before editing.             |
// |_____________________________________________________________________________________|
//
// This script changes timestamps such as those in comments to be relative to the local time.

mediaWiki.loader.load(mediaWiki.config.get('wgServer') + mediaWiki.config.get('wgScript') + '?title=MediaWiki:langcode2name.js&action=raw&ctype=text/javascript');
 
function languagereplace () {
  //Can be caused by delay in timing
  if(typeof(langcode2name) == 'undefined'){
    if(! document.callbacks_langcode ) {
      document.callbacks_langcode = {};
    }
    document.callbacks_langcode.sidebartranslate = languagereplace;
    return false;
  }
function sortByLang(a, b) {
    var x = a.Lang.toLowerCase();
    var y = b.Lang.toLowerCase();
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function LangItem(Lang, className, href, innerHTML, title) {
    this.Lang = Lang;
    this.className = className;
    this.href = href;
    this.innerHTML = innerHTML;
    this.title = title;
}

   if (document.getElementById('p-lang')) {
      var LangNodes=document.getElementById('p-lang').getElementsByTagName('ul')[0].getElementsByTagName('li');
      var myData = [];
      var x;
      for(x = 0; x < LangNodes.length; x++ ) {
         LangNodes[x].getElementsByTagName('a')[0].innerHTML = localtoEnglish(LangNodes[x].getElementsByTagName('a')[0].innerHTML);
         myData[myData.length++] = new LangItem(LangNodes[x].getElementsByTagName('a')[0].innerHTML, LangNodes[x].className, LangNodes[x].getElementsByTagName('a')[0].href, LangNodes[x].getElementsByTagName('a')[0].innerHTML, LangNodes[x].getElementsByTagName('a')[0].title);
         }
      
      myData.sort(sortByLang);
      
      for(x = 0; x < myData.length; x++ ) {
         LangNodes[x].className = myData[x].className;
         LangNodes[x].getElementsByTagName('a')[0].href = myData[x].href;
         LangNodes[x].getElementsByTagName('a')[0].innerHTML = myData[x].innerHTML;
         LangNodes[x].getElementsByTagName('a')[0].title = myData[x].title;
         }
      }
   }

$ (languagereplace);
 
function localtoEnglish(localname) {
	lcode = FLname2code(localname);
	return ((typeof(lcode) == 'undefined') ? localname : langcode2name(lcode));
}