コンテンツにスキップ

利用者:青子守歌/trunk/protectionStatus.js

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

// ページ名の左に保護状態を表示する
$(function()
{
    // 編集状態の規定値
    var editptext = '無';
    var moveptext = '無';
    var editpcolor = 'cccccc';
    var editpcolor = 'cccccc';
    var protected = false;
    var wgRestrictionMove = mw.config.get( 'wgRestrictionMove', [] );
    var wgRestrictionEdit = mw.config.get('wgRestrictionEdit', []);

    // 編集保護状態
    switch(wgRestrictionEdit[0])
    {
        // 半保護
        case 'autoconfirmed':
            editptext = '半';
            editpcolor = 'ffff55';
            protected = true;
            break;
        
        // 全保護
        case 'sysop':
            editptext = '全';
            editpcolor = 'ff5555';
            protected = true;
            break;
    }

    // 移動保護状態
    switch(wgRestrictionMove[0])
    {
        // 半保護
        case 'autoconfirmed':
            moveptext = '半';
            movepcolor = 'ffff55';
            protected = true;
            break;

        // 全保護
        case 'sysop':
            moveptext = '全';
            movepcolor = 'ff5555';
            protected = true;
            break;
    }


    // 保護されていれば
    if(protected)
    {

    // 表生成
    var table = document.createElement('table');

    // class, id およびスタイルを設定
    table.setAttribute("class", "noprint");
    table.setAttribute("id", "protectionStatus");
    table.setAttribute("style", "font-size: 45%; float: left; line-height: 60%;");
    table.setAttribute("cellspacing", 0);

    // 中身を生成
    table.innerHTML = '<tbody><tr style=\"background-color: #'
    + editpcolor
    + '\" id=\"LWeditprtected\"><th style="padding: 4px; font-weight: normal;\">編集</th><td style=\"padding: 4px;\">'
     + editptext
     + '</td></tr><tr style=\"background-color: #'
    + movepcolor
    + '\" id=\"LWmoveprtected\"><th style=\"padding: 4px; font-weight: normal;\">移動</th><td style=\"padding: 4px;\">'
    + moveptext
    + '</td></tr></tbody></table>';


    // ページ名<h1>取得
    var firstHeading = document.getElementById("firstHeading");
    
    // ページ名の左に表を表示
    firstHeading.insertBefore(table, firstHeading.firstNode);
    }
});