refactor: ヘッダー・ナビ・サイドメニューの共通化エンジン導入と全ページプレースホルダー統合
- common/js/wiki_common.js に共通ナビゲーション設定マスターおよび自動レンダリングエンジンを実装 - スクリプトパス・階層深さに応じた相対プレフィックス(./, ../, ../../)の自動解決 - 全39ファイルの直書きヘッダー・サイドバー重複コードを共通プレースホルダーに統合し、リンクばらつきを根絶 - iframe埋め込み用の独立パーツHTML(common/sidebar.html, common/header.html)を作成 - 全対象ファイルのUTF-8 BOMあり + CRLF改行コード統一
This commit is contained in:
1 parent
e7fc16de3e
commit
037c9f6d5c
42 files changed
+746
-5126
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base target="_top">
|
||||
<title>Wiki 共通ヘッダー (iframe用)</title>
|
||||
<link rel="stylesheet" href="css/seesaa_neutral_gray.css">
|
||||
<style>
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#wiki-header {
|
||||
padding: 18px 24px 14px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 共通ヘッダー -->
|
||||
<header id="wiki-header"></header>
|
||||
|
||||
<!-- 共通グローバルバー -->
|
||||
<nav id="wiki-global-nav"></nav>
|
||||
|
||||
<script src="js/wiki_common.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+292
-30
@@ -1,15 +1,289 @@
|
||||
/**
|
||||
* Seesaa Wiki ニュートラルグレー 共通スクリプト
|
||||
* FINAL FANTASY XIV 総合攻略Wiki
|
||||
* 共通ナビゲーション&UI自動レンダリングエンジン
|
||||
* Seesaa Wiki ニュートラルグレー テンプレート準拠
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// マクロコピーボタンの初期化
|
||||
// サイト共通ナビゲーション定義マスター
|
||||
const WIKI_NAV_CONFIG = {
|
||||
siteTitle: 'FINAL FANTASY XIV 総合攻略Wiki',
|
||||
siteDesc: '光の戦士のための実戦立ち回り・XHB配置・マクロ詳細・育成ロードマップ集成 (パッチ7.x 黄金のレガシー対応)',
|
||||
globalNav: [
|
||||
{ title: 'トップ', path: 'index.html' },
|
||||
{ title: 'XHB・操作', path: 'xhb/index.html' },
|
||||
{ title: '巴術士', path: 'jobs/arcanist/index.html' },
|
||||
{ title: '召喚士', path: 'jobs/summoner/index.html' },
|
||||
{ title: '学者', path: 'jobs/scholar/index.html' },
|
||||
{ title: '吟遊詩人', path: 'jobs/bard/index.html' },
|
||||
{ title: '侍', path: 'jobs/samurai/index.html' },
|
||||
{ title: 'ギャザクラ', path: 'crafter_gatherer/index.html' },
|
||||
{ title: '便利マクロ集', path: 'macros/useful_macros.html' },
|
||||
{ title: 'マルチプレイ', path: 'multiplayer/index.html' }
|
||||
],
|
||||
sidebar: [
|
||||
{
|
||||
type: 'search',
|
||||
title: 'サイト内検索'
|
||||
},
|
||||
{
|
||||
type: 'links',
|
||||
title: 'メインメニュー',
|
||||
links: [
|
||||
{ text: '🏠 Wiki トップ', path: 'index.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'links',
|
||||
title: '🎮 XHB・操作設計',
|
||||
links: [
|
||||
{ text: 'XHB総合案内・思想', path: 'xhb/index.html' },
|
||||
{ text: '全ジョブ共通XHB配置', path: 'xhb/common_layout.html' },
|
||||
{ text: 'WXHB・同時押し設定', path: 'xhb/wxhb_settings.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'groups',
|
||||
title: '⚔️ 戦闘ジョブ攻略',
|
||||
groups: [
|
||||
{
|
||||
name: '【巴術士】',
|
||||
links: [
|
||||
{ text: '巴術士基礎・ジョブ解放', path: 'jobs/arcanist/index.html' },
|
||||
{ text: '巴術士専用マクロ', path: 'jobs/arcanist/macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: '【召喚士】',
|
||||
links: [
|
||||
{ text: '召喚士トップ・基礎', path: 'jobs/summoner/index.html' },
|
||||
{ text: 'Lv34スキル回し', path: 'jobs/summoner/rotation_lv34.html' },
|
||||
{ text: 'Lv50〜100バースト回し', path: 'jobs/summoner/rotation_lv50_100.html' },
|
||||
{ text: '召喚士専用XHB配置', path: 'jobs/summoner/xhb.html' },
|
||||
{ text: '召喚士実戦マクロ集', path: 'jobs/summoner/macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: '【学者】',
|
||||
links: [
|
||||
{ text: '学者トップ・Lv34基礎', path: 'jobs/scholar/index.html' },
|
||||
{ text: 'フェアリー操作の極意', path: 'jobs/scholar/fairy_guide.html' },
|
||||
{ text: '学者専用XHB配置', path: 'jobs/scholar/xhb.html' },
|
||||
{ text: '学者実戦マクロ集', path: 'jobs/scholar/macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: '【吟遊詩人】',
|
||||
links: [
|
||||
{ text: '吟遊詩人トップ・基礎', path: 'jobs/bard/index.html' },
|
||||
{ text: '3大戦歌ローテーション', path: 'jobs/bard/songs_rotation.html' },
|
||||
{ text: 'Lv70〜100スキル回し', path: 'jobs/bard/rotation_lv70_100.html' },
|
||||
{ text: '固定48枠XHB完全設計', path: 'jobs/bard/xhb.html' },
|
||||
{ text: '12×1 CD監視ホットバー', path: 'jobs/bard/cd_hotbar.html' },
|
||||
{ text: '吟遊詩人実戦マクロ集', path: 'jobs/bard/macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: '【侍】',
|
||||
links: [
|
||||
{ text: '侍トップ・基礎', path: 'jobs/samurai/index.html' },
|
||||
{ text: '雪月花・コンボ・バースト', path: 'jobs/samurai/combos_rotation.html' },
|
||||
{ text: '固定48枠XHB完全設計', path: 'jobs/samurai/xhb.html' },
|
||||
{ text: '12×1 CD監視ホットバー', path: 'jobs/samurai/cd_hotbar.html' },
|
||||
{ text: '侍実戦マクロ集', path: 'jobs/samurai/macros.html' }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'links',
|
||||
title: '🔨 ギャザラー・クラフター',
|
||||
links: [
|
||||
{ text: 'ギャザクラ総合トップ', path: 'crafter_gatherer/index.html' },
|
||||
{ text: '全ギルド・NPC座標一覧', path: 'crafter_gatherer/npc_locations.html' },
|
||||
{ text: '爆速レベル上げロードマップ', path: 'crafter_gatherer/leveling_roadmap.html' },
|
||||
{ text: 'リーヴ&GC調達納品', path: 'crafter_gatherer/leves_gc_supply.html' },
|
||||
{ text: '復興・釣り・お得意様', path: 'crafter_gatherer/ishgard_ocean_custom.html' },
|
||||
{ text: 'ギャザクラ製作マクロ集', path: 'crafter_gatherer/macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'links',
|
||||
title: '📜 システム・便利マクロ',
|
||||
links: [
|
||||
{ text: 'プレイ快適化・便利マクロ大全', path: 'macros/useful_macros.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'links',
|
||||
title: '🛡️ マルチプレイ基礎',
|
||||
links: [
|
||||
{ text: '初心者心得・基本マナー', path: 'multiplayer/index.html' },
|
||||
{ text: 'ID・討伐戦立ち回り基礎', path: 'multiplayer/dungeon_basics.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
footer: {
|
||||
copyright: '© SQUARE ENIX CO., LTD. All Rights Reserved. | FINAL FANTASY XIV',
|
||||
subText: 'FF14 攻略Wiki (Seesaa Wiki ニュートラルグレー テンプレート完全準拠)'
|
||||
}
|
||||
};
|
||||
|
||||
// Wikiルートへの相対パスプレフィックスを検出
|
||||
function getWikiRootPrefix() {
|
||||
const scripts = document.querySelectorAll('script');
|
||||
for (let i = 0; i < scripts.length; i++) {
|
||||
const src = scripts[i].getAttribute('src') || '';
|
||||
const idx = src.indexOf('common/js/wiki_common.js');
|
||||
if (idx !== -1) {
|
||||
return src.substring(0, idx);
|
||||
}
|
||||
// common/ 内のパーツHTML (common/sidebar.html 等) からの読み込み
|
||||
if (src.endsWith('wiki_common.js') && (src.includes('js/') || src === 'wiki_common.js')) {
|
||||
return '../';
|
||||
}
|
||||
}
|
||||
const pathname = window.location.pathname.replace(/\\/g, '/');
|
||||
if (pathname.includes('/jobs/')) return '../../';
|
||||
if (pathname.includes('/crafter_gatherer/') || pathname.includes('/xhb/') || pathname.includes('/multiplayer/') || pathname.includes('/macros/') || pathname.includes('/common/')) return '../';
|
||||
return '';
|
||||
}
|
||||
|
||||
// 現在のページ判定
|
||||
function isCurrentPage(linkPath) {
|
||||
const currentPath = window.location.pathname.replace(/\\/g, '/');
|
||||
if (currentPath.endsWith('/' + linkPath) || currentPath.endsWith(linkPath)) {
|
||||
return true;
|
||||
}
|
||||
if (linkPath.endsWith('index.html')) {
|
||||
const dirPath = linkPath.replace(/index\.html$/, '');
|
||||
if (currentPath.endsWith('/' + dirPath) || currentPath.endsWith(dirPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ヘッダーレンダリング
|
||||
function renderHeader(rootPrefix) {
|
||||
const header = document.getElementById('wiki-header');
|
||||
if (!header) return;
|
||||
header.innerHTML = `
|
||||
<div class="wiki-site-title">
|
||||
<a href="${rootPrefix}index.html">${WIKI_NAV_CONFIG.siteTitle}</a>
|
||||
</div>
|
||||
<div class="wiki-site-desc">
|
||||
${WIKI_NAV_CONFIG.siteDesc}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// グローバルナビレンダリング
|
||||
function renderGlobalNav(rootPrefix) {
|
||||
const nav = document.getElementById('wiki-global-nav');
|
||||
if (!nav) return;
|
||||
const itemsHtml = WIKI_NAV_CONFIG.globalNav.map(item => {
|
||||
const fullHref = rootPrefix + item.path;
|
||||
const activeClass = isCurrentPage(item.path) ? ' class="active"' : '';
|
||||
return `<li><a href="${fullHref}"${activeClass}>${item.title}</a></li>`;
|
||||
}).join('');
|
||||
nav.innerHTML = `<ul class="wiki-nav-list">${itemsHtml}</ul>`;
|
||||
}
|
||||
|
||||
// サイドバーレンダリング
|
||||
function renderSidebar(rootPrefix) {
|
||||
const sidebar = document.getElementById('wiki-sidebar');
|
||||
if (!sidebar) return;
|
||||
let html = '';
|
||||
WIKI_NAV_CONFIG.sidebar.forEach(section => {
|
||||
if (section.type === 'search') {
|
||||
html += `
|
||||
<div class="sidebar-box">
|
||||
<div class="sidebar-title">${section.title}</div>
|
||||
<div class="sidebar-content">
|
||||
<div class="sidebar-search-box">
|
||||
<input type="text" id="sidebarSearchInput" class="sidebar-search-input" placeholder="キーワード検索...">
|
||||
<button type="button" id="sidebarSearchBtn" class="sidebar-search-btn">検索</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
} else if (section.type === 'links') {
|
||||
const linksHtml = section.links.map(link => {
|
||||
const fullHref = rootPrefix + link.path;
|
||||
const currentClass = isCurrentPage(link.path) ? ' class="current"' : '';
|
||||
return `<li${currentClass}><a href="${fullHref}">${link.text}</a></li>`;
|
||||
}).join('');
|
||||
html += `
|
||||
<div class="sidebar-box">
|
||||
<div class="sidebar-title">${section.title}</div>
|
||||
<div class="sidebar-content">
|
||||
<ul>${linksHtml}</ul>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
} else if (section.type === 'groups') {
|
||||
let groupsHtml = '';
|
||||
section.groups.forEach((group, idx) => {
|
||||
const marginTop = idx === 0 ? '4px' : '8px';
|
||||
const groupLinks = group.links.map(link => {
|
||||
const fullHref = rootPrefix + link.path;
|
||||
const currentClass = isCurrentPage(link.path) ? ' class="current"' : '';
|
||||
return `<li${currentClass}><a href="${fullHref}">${link.text}</a></li>`;
|
||||
}).join('');
|
||||
groupsHtml += `
|
||||
<p style="font-size: 11px; font-weight: bold; color: #525a66; margin: ${marginTop} 0 2px;">${group.name}</p>
|
||||
<ul>${groupLinks}</ul>
|
||||
`;
|
||||
});
|
||||
html += `
|
||||
<div class="sidebar-box">
|
||||
<div class="sidebar-title">${section.title}</div>
|
||||
<div class="sidebar-content">
|
||||
${groupsHtml}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
sidebar.innerHTML = html;
|
||||
}
|
||||
|
||||
// フッターレンダリング
|
||||
function renderFooter() {
|
||||
const footer = document.getElementById('wiki-footer');
|
||||
if (!footer) return;
|
||||
footer.innerHTML = `
|
||||
<p>${WIKI_NAV_CONFIG.footer.copyright}</p>
|
||||
<p>${WIKI_NAV_CONFIG.footer.subText}</p>
|
||||
`;
|
||||
}
|
||||
|
||||
// サイト内検索機能の初期化
|
||||
function initSearch(rootPrefix) {
|
||||
const searchInput = document.getElementById('sidebarSearchInput');
|
||||
const searchBtn = document.getElementById('sidebarSearchBtn');
|
||||
if (searchInput) {
|
||||
const doSearch = () => {
|
||||
const q = searchInput.value.trim();
|
||||
if (q) {
|
||||
window.location.href = `${rootPrefix}index.html?q=${encodeURIComponent(q)}`;
|
||||
}
|
||||
};
|
||||
if (searchBtn) searchBtn.addEventListener('click', doSearch);
|
||||
searchInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') doSearch();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// マクロコピーボタンの初期化
|
||||
function initMacroCopy() {
|
||||
document.querySelectorAll('.wiki-macro-box').forEach(box => {
|
||||
const header = box.querySelector('.wiki-macro-header');
|
||||
const code = box.querySelector('.wiki-macro-code');
|
||||
if (header && code) {
|
||||
if (header && code && !header.querySelector('button')) {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = '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', () => {
|
||||
@@ -21,31 +295,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
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 '/';
|
||||
}
|
||||
|
||||
// DOMContentLoaded 時に一括実行
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const rootPrefix = getWikiRootPrefix();
|
||||
|
||||
// 共通コンポーネント自動レンダリング
|
||||
renderHeader(rootPrefix);
|
||||
renderGlobalNav(rootPrefix);
|
||||
renderSidebar(rootPrefix);
|
||||
renderFooter();
|
||||
|
||||
// 機能の初期化
|
||||
initSearch(rootPrefix);
|
||||
initMacroCopy();
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base target="_top">
|
||||
<title>Wiki 共通サイドメニュー (iframe用)</title>
|
||||
<link rel="stylesheet" href="css/seesaa_neutral_gray.css">
|
||||
<style>
|
||||
body {
|
||||
background-color: var(--wiki-sidebar-bg, #f2f3f5);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
#wiki-sidebar {
|
||||
width: 100%;
|
||||
border-right: none;
|
||||
box-sizing: border-box;
|
||||
padding: 12px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 共通サイドバー配置エリア -->
|
||||
<div id="wiki-sidebar"></div>
|
||||
|
||||
<script src="js/wiki_common.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user