미디어위키:Common.js: 두 판 사이의 차이
둘러보기로 이동
검색으로 이동
백괴게임>아라 잔글편집 요약 없음 |
백괴게임>아라 잔글편집 요약 없음 |
||
325번째 줄: | 325번째 줄: | ||
continue; | continue; | ||
} | } | ||
/* licheck = document.getElementsByTagName( 'li' ); | |||
for( i = 0; i < licheck.length; i++ ) { | for( i = 0; i < licheck.length; i++ ) { | ||
if( licheck[i].getAttribute( 'id' ) == 'ca-viewsource' ) { | if( licheck[i].getAttribute( 'id' ) == 'ca-viewsource' ) { | ||
331번째 줄: | 331번째 줄: | ||
} | } | ||
else | else | ||
{ | { */ | ||
editLink = document.getElementById( 'ca-edit' ).firstChild; | editLink = document.getElementById( 'ca-edit' ).firstChild; | ||
/* } */ | |||
editLink.removeAttribute( 'href', 0 ); | editLink.removeAttribute( 'href', 0 ); | ||
editLink.style.color = 'gray'; | editLink.style.color = 'gray'; |
2011년 7월 5일 (화) 21:00 판
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
/*<source lang="javascript"><nowiki>*/
/** [[틀:USERNAME]]에서 사용하는 바꿔치기 함수
* 작성자: [[사용자:Peremen]]
*/
function UserNameReplace() {
if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace) return;
if (!document.getElementById('pt-userpage')) return;
$("span.insertusername").each(function(i) {
$(this).text(wgUserName)
})
};
$(UserNameReplace);
/** [[틀:제목]]에서 사용하는 제목 바꿔치기 함수
* 작성자: [[사용자:Peremen]]
*/
function rewriteTitle() {
if (typeof(disableTitleRewrite) != 'undefined' && disableTitleRewrite) return;
if (!document.getElementById('title-meta')) return;
$('h1.firstHeading').each( function(i){
$(this).html( $("#title-meta").html()).css('text-align', $("#title-align").text())
})
}
$(rewriteTitle);
/* from en: */
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
}
)();
/*
[[:en:Wikipedia:WikiProject User scripts/Scripts/Add edit section 0]]
[[위키백과:사랑방/2007년 1월#듕귁어판을 보니 section 0 편집 방법이 있더군요]]
*/
/* 영어 위키백과 버전 */
function addEditZero() {
var x;
if (!(x = document.getElementById('ca-edit') )) return;
var url;
if (!(url = x.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
var y = addPortletLink('p-cactions', url+"§ion=0", '0', 'ca-edit-0',
'문서의 첫 부분만을 편집합니다.', '0', x.nextSibling);
y.className = x.className; // steal classes from the the edit tab...
x.className = 'istalk'; // ...and make the edit tab have no right margin
// exception: don't steal the "selected" class unless actually editing section 0:
if (/(^| )selected( |$)/.test(y.className)) {
if (!document.editform || !document.editform.wpSection
|| document.editform.wpSection.value != "0") {
y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
x.className += ' selected';
}
}
}
addOnloadHook(addEditZero);
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* Wikipedia:NavFrame.
* Maintainers: User:R. Koot
*/
//var autoCollapse = 2;
//var collapseCaption = "hide";
//var expandCaption = "show";
function collapseTable( tableIndex ) {
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.getElementsByTagName( "tr" );
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( var 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 = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
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.style.styleFloat = "right";
Button.style.cssFloat = "right";
Button.style.fontWeight = "normal";
Button.style.textAlign = "right";
Button.style.width = "6em";
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
/* only add button and increment count if there is a header row to work with */
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
}
}
addOnloadHook( createCollapseButtons );
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
/** Dynamic Navigation Bars (experimental) *************************************
*
* Description: See [[:en:Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
// set up the words in your language
var autoCollapse = 2;
var collapseCaption = "숨기기";
var expandCaption = "보이기";
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = autoCollapse;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar) {
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if ( hasClass( NavChild, 'NavPic' ) ) {
NavChild.style.display = 'none';
}
if ( hasClass( NavChild, 'NavContent') ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'block';
}
if (hasClass(NavChild, 'NavContent')) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
// iterate over all < div >-elements
var divs = document.getElementsByTagName("div");
for (var i=0;NavFrame = divs[i];i++) {
// if found a navigation bar
if (hasClass(NavFrame, "NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for (
var j=0;
j < NavFrame.childNodes.length;
j++
) {
if (hasClass(NavFrame.childNodes[j], "NavHead")) {
NavFrame.childNodes[j].appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for (
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
addOnloadHook( createNavigationBarToggleButton );
/** 특집 게임에 별표를 붙이는 함수.
* 작성자: [[사용자:Peremen]]
*/
function LinkFA() {
// iterate over all <span>-elements
$("span.FA").each(function(i, e) {
var a = e.id;
$("#p-lang li").each( function(j, k) {
if (k.className == "interwiki-"+a) {
k.className += " FA";
k.title = "이 게임은 특집 게임입니다.";
}
});
});
}
$(LinkFA);
/** 대문의 탭을 "프로젝트"->"대문"으로 바꾸는 함수.
* 작성자: [[사용자:Peremen]]
*/
function MainPageRenameNamespaceTab() {
var title = mw.config.get( 'wgPageName' );
var hasMainPageTab = (title == '백괴게임:대문' || title == '백괴게임토론:대문');
if ( hasMainPageTab ){
$( '#ca-nstab-project a' ).text( "대문" );
}
var hasGameListTab = (title == '백괴게임:게임_목록' || title == '백괴게임토론:게임_목록');
if ( hasGameListTab ){
$( '#ca-nstab-project a' ).text( "게임 목록" );
}
$( '#ca-nstab-main a' ).text( "게임" );
}
$(MainPageRenameNamespaceTab);
/*
* @author [[User:Devunt]]
*/
addOnloadHook(function()
{
if (wgPageName!="백괴게임:낙서장")
return;
if (document.URL.lastIndexOf("action=edit") != -1)
{
if (document.URL.lastIndexOf("fakeaction=clean") == -1)
return;
var dbindex = document.editform.wpTextbox1;
dbindex.value = "{{이 줄은 지우지 마세요 (낙서장 안내문)}}";
document.editform.wpSummary.value = "낙서장 비움";
document.editform.wpSave.click();
return;
}
});
/** 편집 탭 비활성화 *************************************
* 편집을 하지 못하도록 편집 탭을 비활성화합니다.
* Page can still be edited by going via the edit tab on the history etc, or by
* typing the edit address manually.
* By [[:en:User:Spang|Spang]]
*/
function disableArticleEdit() {
spancheck = document.getElementsByTagName( 'span' );
for( i = 0; i < spancheck.length; i++ ) {
if( spancheck[i].getAttribute( 'id' ) != 'nosourceview' ) {
continue;
}
/* licheck = document.getElementsByTagName( 'li' );
for( i = 0; i < licheck.length; i++ ) {
if( licheck[i].getAttribute( 'id' ) == 'ca-viewsource' ) {
editLink = document.getElementById( 'ca-viewsource' ).firstChild;
}
else
{ */
editLink = document.getElementById( 'ca-edit' ).firstChild;
/* } */
editLink.removeAttribute( 'href', 0 );
editLink.style.color = 'gray';
if (mw.config.get("skin") == 'vector')
{
editLink.innerHTML = '<br /><span style="font-size:small">편집 안됨</span>';
}
else
{
editLink.innerHTML = '편집 안됨';
}
}
}
addOnloadHook( disableArticleEdit );
/** 임베드 플래시 무비 **************************************************
* 문서에 플래시 파일을 넣을 수 있게 합니다. 오직 현재 사용자공간에서 활성화됩니다.
* [[틀:플래시]]를 참고하십시오.
* By [[:en:User:Olipro|Olipro]]
*/
var flashOk;
function embedFlashMovie( flashOk ) {
mainbody = document.getElementById( 'bodyContent' );
mainbody.innerHTML = contentTempHolder;
spancheck = document.getElementsByTagName( 'span' );
for( i = 0; i < spancheck.length; i++ ) {
if( spancheck[i].getAttribute( 'id' ) != 'embedFlashDoc' ) {
continue;
}
obj = spancheck[i].innerHTML.split( '@' );
flwidth = obj[0];
flheight = obj[1];
flfile = obj[2].replace( 'fullurl://', 'http://' );
showFlash = ' ';
if( flashOk ) {
showFlash = '<object width="' + flwidth + '" height="' + flheight + '"';
showFlash += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
showFlash += 'codebase="http://fpdownload.macromedia.com/pub/';
showFlash += 'shockwave/cabs/flash/swflash.cab#version=8,0,0,0">';
showFlash += '<param name="movie" value="' + flfile + '" />';
showFlash += '<embed src="' + flfile + '" width="' + flwidth + '" height=';
showFlash += '"' + flheight + '" type="application/x-shockwave-flash" ';
showFlash += 'pluginspage="http://www.macromedia.com/go/getflashplayer" />';
showFlash += '</object>';
} else {
showFlash = '<a class="plainlinks" href="javascript:embedFlashMovie(true)" onClick="embedFlashMovie(true)">' + flfile + '</a> (신뢰하는 경우 보려면 클릭하십시오.)';
}
spancheck[i].innerHTML = showFlash;
spancheck[i].style.display = 'inline';
}
}
var contentTempHolder;
function embedFlashCheck() {
if( !document.getElementById( 'embedFlashDoc' ) ) {
return;
}
mainbody = document.getElementById( 'bodyContent' );
contentTempHolder = mainbody.innerHTML;
if( typeof displayFlashOverride != 'undefined' ) {
embedFlashMovie( displayFlashOverride );
return;
}
askmessage = '<div align="center" id="askflash">이 게임에는 ';
askmessage += '<a href="/wiki/백괴:플래시" class="plainlinks">플래시</a>가 들어있습니다.<br />';
askmessage += '컴퓨터에 해를 끼칠 수 있으므로 신뢰하는 경우에만 여십시오.<br />';
askmessage += '플래시가 포함된 게임을 보시겠습니까?<br /><b><a href="javascript:embedFlashMovie(true)" ';
askmessage += 'onClick="embedFlashMovie(true)">예</a> | <a ';
askmessage += 'href="javascript:embedFlashMovie(false)" ';
askmessage += 'onClick="embedFlashMovie(false)">아니오</a> | <a ';
askmessage += 'href="/index.php?title=User:' + wgUserName + '/' + skin + '.js&';
askmessage += 'action=edit§ion=new&preload=틀:플래시/비활성">';
askmessage += '이 메시지를 다시 표시하지 않음</a></b></div>';
mainbody.innerHTML = askmessage;
}
addOnloadHook( embedFlashCheck );
/*</nowiki></source>*/