style: Seesaa Wikiニュートラルグレー共通スタイルシートおよび共通スクリプトを追加
This commit is contained in:
1 parent
a5a796b13c
commit
9bb55e4dda
2 files changed
+566
No files matched your search
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Seesaa Wiki ニュートラルグレー 共通スクリプト
|
||||
* FINAL FANTASY XIV 総合攻略Wiki
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// マクロコピーボタンの初期化
|
||||
document.querySelectorAll('.wiki-macro-box').forEach(box => {
|
||||
const header = box.querySelector('.wiki-macro-header');
|
||||
const code = box.querySelector('.wiki-macro-code');
|
||||
if (header && code) {
|
||||
const btn = document.createElement('button');
|
||||
btn.textContent = '📋 マクロをコピー';
|
||||
btn.style.cssText = 'background: #525a66; color: #fff; border: 1px solid #3c424c; padding: 2px 8px; font-size: 11px; cursor: pointer; border-radius: 2px;';
|
||||
btn.addEventListener('click', () => {
|
||||
navigator.clipboard.writeText(code.innerText.trim()).then(() => {
|
||||
btn.textContent = '✔ コピー完了!';
|
||||
setTimeout(() => { btn.textContent = '📋 マクロをコピー'; }, 2000);
|
||||
});
|
||||
});
|
||||
header.appendChild(btn);
|
||||
}
|
||||
});
|
||||
|
||||
// サイドバー簡易検索の初期化
|
||||
const searchInput = document.getElementById('sidebarSearchInput');
|
||||
const searchBtn = document.getElementById('sidebarSearchBtn');
|
||||
if (searchInput) {
|
||||
const doSearch = () => {
|
||||
const q = searchInput.value.trim();
|
||||
if (q) {
|
||||
// ルートの index.html にクエリ付きで遷移
|
||||
const rootPath = getWikiRootPath();
|
||||
window.location.href = `${rootPath}index.html?q=${encodeURIComponent(q)}`;
|
||||
}
|
||||
};
|
||||
if (searchBtn) searchBtn.addEventListener('click', doSearch);
|
||||
searchInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') doSearch();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function getWikiRootPath() {
|
||||
// 現在の階層からWikiルートへの相対パスを計算
|
||||
const path = window.location.pathname;
|
||||
const depth = (path.match(/\//g) || []).length;
|
||||
// IISのルートからの深さに応じて調整
|
||||
return '/';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user