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

편집 요약 없음
(문서를 비움)
태그: 비우기
 
(같은 사용자의 중간 판 9개는 보이지 않습니다)
1번째 줄: 1번째 줄:
function extendedDropdownItem(htmlObject) {
    this.menuitem = htmlObject;
   
    this.AddItem = function (buttontitle, buttonname, callbackOrUrl) {
        let newItem = this.menuitem.cloneNode(true);
        this.menuitem.after(newItem);
        newItem.innerHTML = buttonname;
        newItem.accessKey = '';
        newItem.style.cursor = 'pointer';
        newItem.title = buttontitle;
       
        switch (typeof callbackOrUrl) {
       
        case 'string':
        try {
        new URL(callbackOrUrl);
        } catch (e) {
        newItem.href = 'javascript:;'; // 'Invalid URL'
        console.log('a');
        return ;
        }
        newItem.href = callbackOrUrl;
        console.log('b');
        break;
       
        case 'function':
        newItem.onclick = callbackOrUrl;
        newItem.href = 'javascript:;'; // 'Invalid URL'
        break;
        }
    };
   
    this.SetMenuItem = function (htmlObject) { this.menuitem = htmlObject; };
}


if (mw.config.get('skin') == "liberty") {
window.extendedDropdownItemArray = window.extendedDropdownItemArray || new extendedDropdownItem(document.querySelector('.content-tools .dropdown-item:last-child'));
}
else if (mw.config.get('skin') == "timeless") {
window.extendedDropdownItemArray = window.extendedDropdownItemArray || new extendedDropdownItem(document.querySelector('.mw-portlet-body #ca-move.mw-list-item'));
}

2024년 1월 6일 (토) 17:33 기준 최신판