MediaWiki:Extra-tabs.js

Dari Wikikutip bahasa Indonesia, koleksi kutipan bebas.

Catatan: Setelah disimpan, Anda mungkin perlu melewati tembolok peramban web untuk melihat perubahan.

  • Firefox/Safari: Tekan dan tahan Shift sembari mengeklik Reload, atau tekan Ctrl-F5 atau Ctrl-R (⌘-R di Mac)
  • Google Chrome: Tekan Ctrl-Shift-R (⌘-Shift-R di Mac)
  • Internet Explorer / Edge: Tahan Ctrl sembari mengeklik Refresh, atau tekan Ctrl-F5
  • Opera: Tekan Ctrl-F5.
 /* ------------------------------------------------------------------------------- */
 /* Extra-tabs: memunculkan tab tambahan, ide asli dari commons
 /* ------------------------------------------------------------------------------- */ 
 // namespace names
 var tab_ns_user = 'Pengguna:';
 var tab_ns_usertalk = 'Bicara_Pengguna:';
 var tab_editcount = 'Jumlah suntingan'; 
 var tab_purge = 'Hapus singgahan';
 // Appends a new tab.
 function global_append_tab(url, name)
 {
   var na = document.createElement('a');
   na.setAttribute('href', url);  
   var txt = document.createTextNode(name);
   na.appendChild(txt);
   var li = document.createElement('li');
   li.appendChild(na);
   // Grab the element we want to append the tab and append the tab to it.
   //var c1 = document.getElementById('column-one');
   //var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
   //tabs.appendChild(li);
   var c1 = document.getElementById('p-tb');
   var tabs = c1.getElementsByTagName('ul')[0];
   var firstElm = tabs.getElementsByTagName('li')[0];
   //tabs.insertBefore(li, firstElm );
   tabs.appendChild(li);
 }
 // Gets the article lemma, with the namespace and with sub pages.
 function global_get_tidy_title()
 {
   // get the article link from the label 'ca-edit' out of the document text.
   var editlk = document.getElementById('ca-edit');
   // If a page is write protected (for that user, a sysop will always have 'ca-edit')
   // we need 'ca-viewsource' as 'ca-edit' does not exist there.
   if (editlk == null)
   {
     editlk = document.getElementById('ca-viewsource');
   }
   // editlk will still be null on a Special page.  Now we try the ca-article tab.
   if (editlk == null)
   {
     editlk = document.getElementById('ca-article');
   }
   editlk = editlk.getElementsByTagName('a')[0].href; 
   // If we found the ca-edit or ca-viewsource tab, the link will have title=.
   // If we found the ca-article tab (on a Special page) it won't.
   if (editlk.indexOf('title=') >= 0)
   {
     // Cut everything up to "title=" from the start and everything past "&action=edit"
     // from the end.
     editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.indexOf('&'));
   }
   else
   {
     // Cut everything up to "/wiki/" from the start.
     editlk = editlk.substring(editlk.indexOf('/wiki/') + 6);
   }
   return editlk;
 }
 function global_add_user_tabs(username)
 {
   username = username.substring(username.indexOf(':') + 1); // strip off namespaces like "User:"
   username = username.replace(/\/.*$/, ''); //removing subpages from the link
   global_append_tab('//tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=idwiki_p&user=' + username , tab_editcount);
 }
 function global_add_main_tabs(title)
 {
   global_append_tab('//id.wikipedia.org/wiki/' + title + '?action=purge' , tab_purge);
 }
 function global_do_onload()
 {
   // extract the namespace
   var title = global_get_tidy_title();
   if (title.indexOf(tab_ns_user) == 0 || title.indexOf(tab_ns_usertalk) == 0)
   {
     global_add_user_tabs(title);
   }
   else global_add_main_tabs(title);
 }
 if (window.addEventListener) 
    window.addEventListener("load", global_do_onload, false);
 else if (window.attachEvent) 
    window.attachEvent("onload", global_do_onload);
 /* ------------------------------------------------------------------------------- */
 /* End of extra-tabs
 /* ------------------------------------------------------------------------------- */