「MediaWiki:Common.js」の版間の差分
提供: スター・ウォーズの鉄人!
(新規) |
細 |
||
5行: | 5行: | ||
if (document.getElementById('ToggleSwitch')) { | if (document.getElementById('ToggleSwitch')) { | ||
− | + | document.getElementById('ToggleSwitch').innerHTML = '<a href="javascript:hide();" id="ToggleSwitchLink">[非表示]</a>'; | |
− | + | var i, k, flg, flg2; | |
− | + | var TableLines; | |
− | + | ||
− | + | ||
− | + | TableLines = document.getElementById('InfoboxTable').getElementsByTagName("td"); | |
− | + | for (k = 0, i = 0; i < TableLines.length; i++) { | |
− | + | if (TableLines[i].getAttributeNode("class").value == "infoboxlabel") { | |
− | + | if (k++ % 2) { | |
− | + | TableLines[i].getAttributeNode("class").value = "infoboxlabel odd"; | |
− | + | } | |
} | } | ||
− | + | } | |
− | + | TableLines = document.getElementById('InfoboxTable').getElementsByTagName("td"); | |
− | + | for (k = 0, i = 0; i < TableLines.length; i++) { | |
− | + | if (TableLines[i].getAttributeNode("class").value == "infoboxcell") { | |
− | + | if (k++ % 2) { | |
− | + | TableLines[i].getAttributeNode("class").value = "infoboxcell odd"; | |
− | } | + | flg = 0; |
+ | } else { | ||
+ | flg = 1; | ||
+ | } | ||
} | } | ||
− | + | } | |
− | + | ||
− | + | TableLines = document.getElementById('InfoboxTable2').getElementsByTagName("td"); | |
− | + | for (k = flg, i = 0; i < TableLines.length; i++) { | |
− | + | if (TableLines[i].getAttributeNode("class").value == "infoboxcell a") { | |
− | + | if (k++ % 2) { | |
− | } | + | TableLines[i].getAttributeNode("class").value = "infoboxcell a odd"; |
+ | flg2 = 1; | ||
+ | } else { | ||
+ | flg2 = 0; | ||
+ | } | ||
} | } | ||
+ | else if (TableLines[i].getAttributeNode("class").value == "infoboxcell b") { | ||
+ | if (flg2) { | ||
+ | TableLines[i].getAttributeNode("class").value = "infoboxcell b odd"; | ||
+ | } | ||
+ | } | ||
+ | else if (TableLines[i].getAttributeNode("class").value == "infoboxcell c") { | ||
+ | if (flg2) { | ||
+ | TableLines[i].getAttributeNode("class").value = "infoboxcell c odd"; | ||
+ | } | ||
+ | } | ||
+ | else if (TableLines[i].getAttributeNode("class").value == "infoboxcell d") { | ||
+ | if (flg2) { | ||
+ | TableLines[i].getAttributeNode("class").value = "infoboxcell d odd"; | ||
+ | } | ||
+ | } | ||
+ | } | ||
} | } | ||
40行: | 61行: | ||
function hide() | function hide() | ||
{ | { | ||
− | + | if (hidemode == 0) { | |
− | + | if (document.getElementById('InfoboxTable')) { | |
− | + | document.getElementById('InfoboxTable').style.display = "none"; | |
− | + | } | |
− | + | if (document.getElementById('InfoboxTable2')) { | |
+ | document.getElementById('InfoboxTable2').style.display = "none"; | ||
+ | } | ||
+ | document.getElementById('ToggleSwitchLink').innerText = "[表示]"; | ||
+ | hidemode = 1; | ||
+ | } else { | ||
+ | if (document.getElementById('InfoboxTable')) { | ||
document.getElementById('InfoboxTable').style.display = "block"; | document.getElementById('InfoboxTable').style.display = "block"; | ||
− | |||
− | |||
} | } | ||
+ | if (document.getElementById('InfoboxTable2')) { | ||
+ | document.getElementById('InfoboxTable2').style.display = "block"; | ||
+ | } | ||
+ | document.getElementById('ToggleSwitchLink').innerText = "[非表示]"; | ||
+ | hidemode = 0; | ||
+ | } | ||
} | } |
2013年9月20日 (金) 16:46時点における最新版
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ var hidemode = 0; if (document.getElementById('ToggleSwitch')) { document.getElementById('ToggleSwitch').innerHTML = '<a href="javascript:hide();" id="ToggleSwitchLink">[非表示]</a>'; var i, k, flg, flg2; var TableLines; TableLines = document.getElementById('InfoboxTable').getElementsByTagName("td"); for (k = 0, i = 0; i < TableLines.length; i++) { if (TableLines[i].getAttributeNode("class").value == "infoboxlabel") { if (k++ % 2) { TableLines[i].getAttributeNode("class").value = "infoboxlabel odd"; } } } TableLines = document.getElementById('InfoboxTable').getElementsByTagName("td"); for (k = 0, i = 0; i < TableLines.length; i++) { if (TableLines[i].getAttributeNode("class").value == "infoboxcell") { if (k++ % 2) { TableLines[i].getAttributeNode("class").value = "infoboxcell odd"; flg = 0; } else { flg = 1; } } } TableLines = document.getElementById('InfoboxTable2').getElementsByTagName("td"); for (k = flg, i = 0; i < TableLines.length; i++) { if (TableLines[i].getAttributeNode("class").value == "infoboxcell a") { if (k++ % 2) { TableLines[i].getAttributeNode("class").value = "infoboxcell a odd"; flg2 = 1; } else { flg2 = 0; } } else if (TableLines[i].getAttributeNode("class").value == "infoboxcell b") { if (flg2) { TableLines[i].getAttributeNode("class").value = "infoboxcell b odd"; } } else if (TableLines[i].getAttributeNode("class").value == "infoboxcell c") { if (flg2) { TableLines[i].getAttributeNode("class").value = "infoboxcell c odd"; } } else if (TableLines[i].getAttributeNode("class").value == "infoboxcell d") { if (flg2) { TableLines[i].getAttributeNode("class").value = "infoboxcell d odd"; } } } } function hide() { if (hidemode == 0) { if (document.getElementById('InfoboxTable')) { document.getElementById('InfoboxTable').style.display = "none"; } if (document.getElementById('InfoboxTable2')) { document.getElementById('InfoboxTable2').style.display = "none"; } document.getElementById('ToggleSwitchLink').innerText = "[表示]"; hidemode = 1; } else { if (document.getElementById('InfoboxTable')) { document.getElementById('InfoboxTable').style.display = "block"; } if (document.getElementById('InfoboxTable2')) { document.getElementById('InfoboxTable2').style.display = "block"; } document.getElementById('ToggleSwitchLink').innerText = "[非表示]"; hidemode = 0; } }