미디어위키:Common.js

十八子(십팔자) (討論(토론) | 寄與(기여))님의 2023()10()23()())11()33() ()

參考(참고): 設定(설정)貯藏(저장)()에 바뀐 점을 確認(확인)하기 ()해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R入力(입력) (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 入力(입력) (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5入力(입력).
  • 오페라: 메뉴 → 設定(설정)(맥의 境遇(경우) 오페라 → 環境(환경)設定(설정))으로 移動(이동)한 다음 個人(개인) 情報(정보) 保護(보호)保安(보안)檢索(검색) 데이터 지우기 → 캐시한 映像(영상) 및 파일을 누름.
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */

window.addEventListener('DOMContentLoaded', function() {
    if(window.matchMedia) {
        var match = window.matchMedia('(prefers-color-scheme: dark)');
        if(match.matches) {
            document.body.classList.add('dark-mode');
        }
        match.addEventListener('change', function(event) {
            var darkMode = event.matches;
            document.body.classList.toggle('dark-mode', darkMode);
        });
    }
});

mw.loader.using(['mediawiki.util'], function() {
    document.querySelector('input#searchInput').addEventListener('input', function() {
        $(this).trigger('keypress');
    });
});

var customizeToolbar = function () {
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
            'cite': {
                label: '註釋',
                type: 'button',
                icon: '//upload.wikimedia.org/wikipedia/commons/4/4f/Cite_icon.svg',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "{{*|",
                        peri: "內容",
                        post: "}}"
                    }
                }
            }
        }
    } );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}