User:ToePeu/modern.js

From translatewiki.net
Jump to: navigation, search
/* Add "Show Wikipedia" link for MediaWiki namespace */
/* Add "Show Other language" link for MediaWiki namespace */
addOnloadHook(function () {
  if (wgCanonicalNamespace != "MediaWiki") return;
 
  var body = document.getElementById ('contentSub');

  if (wgPageName.indexOf('/')>0) {
    body.innerHTML += '<p><a href="http://'+ wgPageName.substring(wgPageName.indexOf('/')+1, wgPageName.length) +'.wikipedia.org/wiki/'+wgPageName.substring(0, wgPageName.indexOf('/'))+'">Show this message in Wikipedia</a></p>'

    function linkLang(lang) {
      return '<p><a href="'+wgServer+wgArticlePath.substring(0, wgArticlePath.indexOf("$1"))+wgPageName.substring(0, wgPageName.indexOf(wgUserLanguage))+lang+'">Show this message in '+lang+'</a></p>';
    }

    if (wgPageName.substring(wgPageName.indexOf('/')+1, wgPageName.length)==wgUserLanguage) {
      body.innerHTML += linkLang('ja');
    } else
      body.innerHTML += linkLang(wgUserLanguage);
  }
});

// 위로 버튼 추가 시작
var editbtnname = '편집';
// section 0 버튼 때문에 변경한 부분 주석처리
function getElementsByCondition(condition,container)
{
   container = container||document;
   var all = container.all||container.getElementsByTagName('*');
   var arr = [];
   for(var k=0;k<all.length;k++) {
     var elm = all[k];
     if(condition(elm,k)) arr[arr.length] = elm;
   }
   return arr;
} 
 
addOnloadHook(function(){
   var x;
   if (!(x = document.getElementById('ca-edit') )) return;
   var url;
   if (!(url = x.getElementsByTagName('a')[0] )) return;
   if (!(url = url.href )) return;
 
// section 0 section new 편집 버튼 맨아래로 버튼 추가 시작
 
   var body = document.getElementById ('mw_contentholder');
   if(!body) return;
 
   var sec0 = '<strong><span class="editsection" id="ca-edit-0">[<a href="' + url + '&section=0"  title="부분 편집: 첫머리">편집</a>]</spa'+'n></strong>';
   var secn = '<h2><span class="editsection" id="ca-edit-new">[<a href="' + url + '&section=new" title="부분 편집: 덧붙이기">편집</a>]</spa'+'n></h2>';
 
//   if(body.innerHTML.match('class="editsection"')){
     body.innerHTML = sec0 + body.innerHTML + secn;
//   }
 
//section 0 section new 편집 버튼 맨아래로 버튼 추가 끝
 
   editpage = '[<strong><a href="' + url + '" title="문서를 고칩니다. [Alt-Shift-e]">*</a></strong>]';
   totop = '[<strong><a'+' href="#" title="위로 가기" onclick="window.scrollTo(0,0); return false">↑</'+'a></strong>]';
   tobottom = '[<strong><a'+' href="#" title="아래로 가기" onclick="window.scrollTo(0,height); return false">↓</'+'a></strong>]';
 
   var ed = getElementsByCondition(function(el){return el.className=="editsection"});
   //for(var i=0; i<ed.length;i++)
   ed[0].innerHTML += tobottom;
   for(var i=1; i<ed.length;i++) {
     ed[i].innerHTML += totop;
   }
   for(i=0; i<ed.length; i++) {
     ed[i].innerHTML =  editpage + ed[i].innerHTML.replace('>'+editbtnname+'<', '>&plusmn;<');
   }
 
});
// 위로 버튼 추가 끝