「MediaWiki:Common.js」の版間の差分

大文字から小文字に変換
a
 
(同じ利用者による、間の19版が非表示)
29行目: 29行目:
/* PCスキンでサブタイトルを消す処理 ここまで */
/* PCスキンでサブタイトルを消す処理 ここまで */


/* beta1 */
/* beta2 */
     const pageTitle = mw.config.get('wgPageName')
     const pageTitle = mw.config.get('wgPageName')
     const apibase = 'https://wiki.tmyt105.com/w/api.php';
     const pageNo = mw.config.get('wgRevisionId')
    const url = `https://wiki.tmyt105.com/w/api.php?action=query&format=json&prop=revisions&formatversion=2&revids=${pageNo}&rvprop=user`;
     const updaterElement = document.getElementById('last-updater-name');
     const updaterElement = document.getElementById('last-updater-name');
    const params = {
        action: 'query',
        prop: 'revisions',
        titles: pageTitle,
        rvlimit: 1,
        rvprop: 'user',
        format: 'json',
        origin: '*'
    };
    const url = new URL(apibase);
    Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));


     fetch(url)
     fetch(url)
68行目: 56行目:
             if (revisions && revisions.length > 0) {
             if (revisions && revisions.length > 0) {
                 const lastUpdater = revisions[0].user;
                 const lastUpdater = revisions[0].user;
                 updaterElement.textContent = lastUpdater.charAt(0).toLowerCase() + s.slice(1);
                 updaterElement.textContent = lastUpdater.charAt(0).toLowerCase() + lastUpdater.slice(1);
             } else {
             } else {
                 updaterElement.textContent = 'null';
                 updaterElement.textContent = 'null';
80行目: 68行目:
         });
         });


/* beta1 ここまで */
/* beta2 ここまで */
 
/* スマホめにゅー */
(function() {
    function injectCustomMenu() {
        if ($('#p-custom-links').length) return
        if (!(mw.config.get('skin') === "minerva")) return
 
        var $navUl = $('#p-navigation');
        var $personalUl = $('#p-personal');
 
        if ($navUl.length && $personalUl.length) {
            var items = [
                { label: '方針', url: '/wiki/Wiki:方針', icon: 'expand' },
                { label: '特別ページ一覧', url: '/wiki/特別:特別ページ一覧', icon: 'star' },
                { label: '全てのページ', url: '/wiki/特別:ページ一覧', icon: 'listBullet' },
                { label: '最近の更新', url: '/wiki/特別:最近の更新', icon: 'history' }
            ];
 
            var html = '<ul id="p-custom-links" class="toggle-list__list">';
           
            items.forEach(function(item) {
                html += '<li class="toggle-list-item">' +
                            '<a href="' + item.url + '" class="toggle-list-item__anchor menu__item--' + item.icon + '">' +
                                '<span class="minerva-icon minerva-icon--' + item.icon + '"></span>' +
                                '<span class="toggle-list-item__label">' + item.label + '</span>' +
                            '</a>' +
                        '</li>';
            });
           
            html += '</ul>';
 
            $navUl.after(html);
        }
    }
 
    $(document).ready(injectCustomMenu);
    var timer = setInterval(injectCustomMenu, 500);
    setTimeout(function() { clearInterval(timer); }, 5000);
})();


console.log("OK Common.js")
console.log("OK Common.js")