사용자:하늘/addArticleMenuItem.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
1번째 줄: 1번째 줄:
function dropdownItem() {
function newDropdownItem(htmlObject) {
     this.lastDropDownItem = document.querySelector('.content-tools .dropdown-item:last-child');
     this.menuitem = htmlObject;
     this.AddItem = function ( func ) {
     this.AddItem = function (func, buttonname, buttontitle) {
         var toAddItem = this.lastDropDownItem.cloneNode(true);
         var toAddItem = this.menuitem.cloneNode(true);
         toAddItem.href = 'javascript:;';
         toAddItem.href = 'javascript:;';
         toAddItem.innerHTML = '본문으로 이전';
         toAddItem.innerHTML = buttonname;
         toAddItem.accessKey = '';
         toAddItem.accessKey = '';
         toAddItem.title = '사용자 문서를 본문으로 이동합니다.';
         toAddItem.title = buttontitle;
         toAddItem.onclick = func;
         toAddItem.onclick = func;
         this.lastDropDownItem.after(toAddItem);
         this.menuitem.after(toAddItem);
     }
     };
    this.SetMenuItem = function (htmlObject) { this.menuitem = htmlObject; };
}
}
new dropdownItem.AddItem( function () {
    wgPageName = mw.config.get('wgPageName');
    mw.notification.autoHideSeconds = { 'short': 2 };
    const to = wgPageName.split('/').pop(); //시리즈:리브레 한자사전/櫻
    new mw.Api().postWithToken('csrf', {
        "action": "move",
        "format": "json",
        "formatversion": "latest",
        "utf8": 1,
        "from": wgPageName,
        "to": to,
        "reason": "시리즈 이전",
        "movetalk": 1,
        "noredirect": 1,
        "movesubpages": 1
    }).done(data => {
        mw.notify('이동 완료!');
        location.href = mw.config.values.wgServer + "/wiki/" + to;
    }).fail(data => {
        mw.notify('이동 실패');
        console.log(data);
    });
})

2022년 5월 3일 (화) 00:45 판

function newDropdownItem(htmlObject) {
    this.menuitem = htmlObject;
    this.AddItem = function (func, buttonname, buttontitle) {
        var toAddItem = this.menuitem.cloneNode(true);
        toAddItem.href = 'javascript:;';
        toAddItem.innerHTML = buttonname;
        toAddItem.accessKey = '';
        toAddItem.title = buttontitle;
        toAddItem.onclick = func;
        this.menuitem.after(toAddItem);
    };
    this.SetMenuItem = function (htmlObject) { this.menuitem = htmlObject; };
}