미디어위키토론:Common.js
보이기
마지막 의견: 11년 전 (Priviet님) - 주제: 틀 숨김 기능 버그 수정요청
보안 서버용 스크립트
{{보호 문서 편집 요청}}
/* 보안 서버 링크 스크립트
* 보안 서버에 있을 때 일반 링크를 보안 서버 링크로 변경하여 일반 서버 접속으로 전환되는 것을 최소화
*/
if (wgServer == "https://secure.wikimedia.org") importScriptURI('https://secure.wikimedia.org/wikipedia/en/w/index.php?title=MediaWiki:Common.js/secure.js&action=raw&ctype=text/javascript');
보안 서버에서 간혹 일반 서버 접속으로 바뀌는 경우가 있습니다. 외부 링크 형식으로 된 위키백과 내 링크나 인터위키 링크를 클릭하면 일반 서버 접속으로 바뀌게 됩니다. 보안 서버에 있을 때는 보안 서버 연결을 항상 유지시키기 위해 위 스크립트의 추가를 요청합니다. Kwj2772 (msg) 2011년 1월 8일 (토) 23:00 (KST)
틀 숨김 기능 버그 수정요청
![]() | 이 보호 문서에 대한 편집이 요청되었습니다. (보호 기록 보기) 이 틀 아래에는 요청 내용을 구체적으로 적어주세요. 관리자가 요청한 내용을 파악하는 데 도움이 됩니다. 이 틀은 분쟁의 여지가 없거나 지침 및 토론에 따라 결정된 편집을 요청하는 데만 쓰입니다. 논쟁이 될 수 있는 편집에 대한 요청은 이 틀을 사용하기 전에 먼저 토론을 통해 의견을 나누시기 바랍니다. |
위키백과:사랑방 (일반)/2013년 제45주#숨김 틀에 이상..?의 오류에 대해서 bug 56824의 답변을 올립니다.
The problem is the use of addHandler() in the createCollapseButtons function in
This function is now deprecated. There is an updated version of what looks like the same function in [2] that should work.
이 지시에 따라 수정하면 버그가 해결된다고 하는군요. 수정부탁드립니다. -Привет(토론) 2013년 11월 10일 (일) 22:22 (KST)
- 구체적인 수정안은 다음과 같습니다. :
collasible table을 다음으로 치환하여 주세요.
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[:en:Wikipedia:NavFrame]].
* Maintainers: [[:en:User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = '숨기기';
var expandCaption = '보이기';
window.collapseTable = function ( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
var i;
if ( Button.firstChild.data === collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
};
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) continue;
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if ( !Header ) continue;
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
Button.className = 'collapseButton'; /* Styles are declared in Common.css */
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
}
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
mw.hook( 'wikipage.content' ).add( createCollapseButtons );