미디어위키:Gadget-Rollback-Comment.js: 두 판 사이의 차이

리버티게임, 모두가 만들어가는 자유로운 게임
백괴게임>탈퇴한 회원2
(새 문서: function addExtRbLink() { var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName ? function(a, b, c) { return a.getElementsByClassName(c) }...)
 
백괴게임>유한림
잔글 (개선)
 
1번째 줄: 1번째 줄:
function addExtRbLink() {
 
     var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName
function addExtRbLink($container) {
        ? function(a, b, c) { return a.getElementsByClassName(c) }
     var $rbnode = $([]), index = {};
        : getElementsByClassName;
     if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array)
     if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array)
         for (var i = 0; i < rollbackLinksDisable.length; i++)
         for (var i = 0; i < rollbackLinksDisable.length; i++)
             index[rollbackLinksDisable[i]] = true;
             index[rollbackLinksDisable[i]] = true;
     if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||
     if (
    !('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||
         !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||
         !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||
         !('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist")
         !('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist" ||
         rbnode = gebcn(document.getElementById("bodyContent"), "span", "mw-rollback-link");
         !('history' in index) && wgAction == "history" ||
    else if (!('history' in index) && wgAction == "history")
         !('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))
         rbnode = gebcn(document.getElementById("pagehistory"), "span", "mw-rollback-link");
    ) {
    else if (!('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2")))
         $rbnode = $container.find( 'span.mw-rollback-link' );
         rbnode = gebcn(diffnode, "span", "mw-rollback-link");
     }
     for (var i = 0, len = rbnode.length; i < len; i++)
$rbnode.each( function () { addExtendedRollbackLink( this ); } );
        addExtendedRollbackLink(rbnode[i]);
};
};
   
   
29번째 줄: 28번째 줄:
     else if (summary == "")
     else if (summary == "")
         return true;
         return true;
     this.href += "&summary=" + '[[특수:기여/$2|$2]]의 모든 편집을 되돌림: '.replace(/\$2/g, user) + encodeURIComponent(summary.replace(/\$user/g, user));
     this.href += "&summary=" + '[[Special:Contributions/$2|$2]]([[User talk:$2|토론]])의 편집을 전부 되돌림: '.replace(/\$2/g, user) + encodeURIComponent(summary.replace(/\$user/g, user));
     return true;
     return true;
};
};
42번째 줄: 41번째 줄:
     var alink = rblink.cloneNode(true);
     var alink = rblink.cloneNode(true);
     alink.className = "";
     alink.className = "";
     alink.firstChild.nodeValue = "(+ 편집 요약)";
     alink.firstChild.nodeValue = "(+편집 요약)";
     alink.onclick = confirmRollback;
     alink.onclick = confirmRollback;
     rbnode.insertBefore(alink, rblink.nextSibling);
     rbnode.insertBefore(alink, rblink.nextSibling);
50번째 줄: 49번째 줄:
         var blink = rblink.cloneNode(true);
         var blink = rblink.cloneNode(true);
         blink.className = "";
         blink.className = "";
         blink.firstChild.nodeValue = "(+ 봇)";
         blink.firstChild.nodeValue = "(+봇)";
         blink.onclick = rollbackAsBot;
         blink.onclick = rollbackAsBot;
         rbnode.insertBefore(blink, alink.nextSibling);
         rbnode.insertBefore(blink, alink.nextSibling);

2018년 1월 22일 (월) 20:33 기준 최신판

function addExtRbLink($container) {
    var $rbnode = $([]), index = {};
    if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array)
        for (var i = 0; i < rollbackLinksDisable.length; i++)
            index[rollbackLinksDisable[i]] = true;
    if (
    	!('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||
        !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||
        !('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist" ||
        !('history' in index) && wgAction == "history" ||
        !('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))
    ) {
        $rbnode = $container.find( 'span.mw-rollback-link' );
    }
	$rbnode.each( function () { addExtendedRollbackLink( this ); } );
};
 
function confirmRollback() {
    var url = this.href;
    var user = url.match(/[?&]from=([^&]*)/);
    if (!user) return;
    user = decodeURIComponent(user[1].replace(/\+/g, " "));
    var summary = prompt("추가할 편집 요약을 입력하세요\n\n$user 는 편집이 되돌려질 사용자 이름으로 치환됩니다.",
                         rollbackSummaryDefault);
    if (summary == undefined)
        return false;
    else if (summary == "")
        return true;
    this.href += "&summary=" + '[[Special:Contributions/$2|$2]]([[User talk:$2|토론]])의 편집을 전부 되돌림: '.replace(/\$2/g, user) + encodeURIComponent(summary.replace(/\$user/g, user));
    return true;
};

function rollbackAsBot() {
    this.href += "&bot=1";
    return true;
}
 
function addExtendedRollbackLink(rbnode) {
    var rblink = rbnode.getElementsByTagName("a")[0];
    var alink = rblink.cloneNode(true);
    alink.className = "";
    alink.firstChild.nodeValue = "(+편집 요약)";
    alink.onclick = confirmRollback;
    rbnode.insertBefore(alink, rblink.nextSibling);
    rbnode.insertBefore(document.createTextNode(" | "), alink);
    if (userIsInGroup('sysop'))
    {
        var blink = rblink.cloneNode(true);
        blink.className = "";
        blink.firstChild.nodeValue = "(+봇)";
        blink.onclick = rollbackAsBot;
        rbnode.insertBefore(blink, alink.nextSibling);
        rbnode.insertBefore(document.createTextNode(" | "), blink);
    }
};
if (typeof rollbackLinksDisable == 'undefined')
    rollbackLinksDisable = [];
if (typeof rollbackSummaryDefault == 'undefined')
    rollbackSummaryDefault = "";

mw.hook( 'wikipage.content' ).add(addExtRbLink);

function userIsInGroup (group)
{
  if (wgUserGroups) {
    if (!group || group.length == 0) group = '*';
    return wgUserGroups.join (' ').indexOf (group) >= 0;
  }
  return false;
}