「MediaWiki:Common.js」の版間の差分
提供: 3代目クッキー☆解説Wiki
LogicalBloom (トーク | 投稿記録) 細 「MediaWiki:Common.js」を保護しました ([編集=管理者のみ許可] (無期限) [移動=管理者のみ許可] (無期限)) |
LogicalBloom (トーク | 投稿記録) 編集の要約なし |
||
9行目: | 9行目: | ||
} | } | ||
}()); | }()); | ||
(function() { | |||
// このコードがトップページでのみ実行されるようにする | |||
if (mw.config.get('wgPageName') !== 'トップページ') { | |||
return; | |||
} | |||
// DOMの準備ができてから実行 | |||
document.addEventListener('DOMContentLoaded', function() { | |||
var pool = document.querySelectorAll('#random-spotlight-pool .random-item'); | |||
var displayArea = document.getElementById('random-spotlight-display'); | |||
if (pool.length > 0 && displayArea) { | |||
// 候補の中からランダムに1つ選ぶ | |||
var randomIndex = Math.floor(Math.random() * pool.length); | |||
var selectedItem = pool[randomIndex]; | |||
// 選んだ要素を表示場所に移動する | |||
if (selectedItem) { | |||
displayArea.appendChild(selectedItem); | |||
} | |||
} | |||
}); | |||
})(); |
2025年6月8日 (日) 17:10時点における版
(function () {
// ユーザーが 'sysop' (管理者) グループに所属していない場合
if (mw.config.get('wgUserGroups').indexOf('sysop') === -1) {
// 'sysop-only' というクラス名を持つ要素をすべて非表示にする
var elements = document.querySelectorAll('.sysop-only');
elements.forEach(function(el) {
el.style.display = 'none';
});
}
}());
(function() {
// このコードがトップページでのみ実行されるようにする
if (mw.config.get('wgPageName') !== 'トップページ') {
return;
}
// DOMの準備ができてから実行
document.addEventListener('DOMContentLoaded', function() {
var pool = document.querySelectorAll('#random-spotlight-pool .random-item');
var displayArea = document.getElementById('random-spotlight-display');
if (pool.length > 0 && displayArea) {
// 候補の中からランダムに1つ選ぶ
var randomIndex = Math.floor(Math.random() * pool.length);
var selectedItem = pool[randomIndex];
// 選んだ要素を表示場所に移動する
if (selectedItem) {
displayArea.appendChild(selectedItem);
}
}
});
})();