Files
ff14-guide/common/js/wiki_common.js
T

808 lines
17 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* FINAL FANTASY XIV 総合攻略Wiki
* 共通ナビゲーション&UI自動レンダリングエンジン
* Seesaa Wiki ニュートラルグレー テンプレート準拠
*/
// サイト共通ナビゲーション定義マスター
const WIKI_NAV_CONFIG = {
siteTitle: 'FINAL FANTASY XIV 総合攻略Wiki',
siteDesc: '光の戦士のための実戦立ち回り・XHB配置・マクロ詳細・育成ロードマップ集成 (パッチ7.x 黄金のレガシー対応)',
globalNav: [
{ title: '🏠 トップ', path: 'index.html' },
{ title: '⭐ フリートライアル最強装備', path: 'equipment/freetrial_gear_guide.html' },
{ title: '🐎 マウント完全攻略', path: 'mounts/index.html' },
{ title: '🏰 ダンジョン完全攻略一覧', path: 'dungeons/index.html' },
{ title: '🔥 討滅戦完全攻略一覧', path: 'trials/index.html' },
{ title: '👑 レイド完全攻略一覧', path: 'raids/index.html' },
{ title: '⚔️ バトル・ルーレット完全攻略', path: 'battle_contents/index.html' },
{ title: '🏡 ハウジング・潜水艦完全攻略', path: 'housing/index.html' }
],
sidebar: [
{
type: 'search',
title: 'サイト内検索'
},
{
type: 'links',
title: 'メインメニュー',
links: [
{ text: '🏠 Wiki トップ', path: 'index.html' },
{ text: '⭐ フリートライアル最強装備', path: 'equipment/freetrial_gear_guide.html' },
{ text: '🐎 マウント総合・全一覧', path: 'mounts/index.html' },
{ text: '🏰 ダンジョン完全攻略一覧', path: 'dungeons/index.html' },
{ text: '🔥 討滅戦完全攻略一覧', path: 'trials/index.html' },
{ text: '👑 レイド完全攻略一覧', path: 'raids/index.html' },
{ text: '⚔️ バトル・ルーレット完全攻略', path: 'battle_contents/index.html' },
{ text: '🏡 ハウジング・潜水艦完全攻略', path: 'housing/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: 'dungeons/index.html' },
{ text: 'サスタシャ侵食洞 (Lv15)', path: 'dungeons/sastasha.html' },
{ text: 'タムタラの墓所 (Lv16)', path: 'dungeons/tam_tara.html' },
{ text: 'カッパーベル銅山 (Lv17)', path: 'dungeons/copperbell.html' },
{ text: '記憶幻想 アレクサンドリア (Lv100)', path: 'dungeons/alexandria.html' },
{ text: 'サボテンダーバレー (Lv100)', path: 'dungeons/tender_valley.html' },
{ text: 'ブレイフロクスの野営地 (Lv32)', path: 'dungeons/brayflox.html' },
{ text: 'カルン埋没寺院 (Lv35)', path: 'dungeons/sunken_temple.html' },
{ text: 'カッターズクライ (Lv38)', path: 'dungeons/cutter_cry.html' },
{ text: 'ストーンヴィジル (Lv41)', path: 'dungeons/stone_vigil.html' },
{ text: 'オーラムヴェイル (Lv47)', path: 'dungeons/aurum_vale.html' }
]
},
{
name: '【討滅戦個別攻略】',
links: [
{ text: '討滅戦総合ポータル', path: 'trials/index.html' },
{ text: 'イフリート討滅戦 (Lv20)', path: 'trials/ifrit.html' },
{ text: 'タイタン討滅戦 (Lv34)', path: 'trials/titan.html' },
{ text: 'ガルーダ討滅戦 (Lv44)', path: 'trials/garuda.html' },
{ text: 'アルテマウェポン破壊作戦 (Lv50)', path: 'trials/ultima_weapon.html' }
]
},
{
name: '【レイド個別攻略】',
links: [
{ text: 'レイド総合ポータル', path: 'raids/index.html' },
{ text: 'アルカディア LH1層 (Lv100)', path: 'raids/arcadia_lh1.html' },
{ text: '古代の民の迷宮 (Lv50)', path: 'raids/labyrinth_of_ancients.html' }
]
}
]
},
{
type: 'links',
title: '⚔️ バトル・特殊コンテンツ',
links: [
{ text: 'CF・ルーレット・トームストーン', path: 'battle_contents/index.html' },
{ text: 'コンサポ&フェイス完全攻略', path: 'battle_contents/duty_support.html' },
{ text: '宝の地図 G1〜G17完全攻略', path: 'battle_contents/treasure_hunt.html' },
{ text: 'モブハント・A連戦・S湧かせ', path: 'battle_contents/hunt.html' },
{ text: 'ディープダンジョン完全攻略', path: 'deep_dungeon/index.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: 'housing/index.html' },
{ text: '内装・浮かせ技・レイアウト', path: 'housing/interior_layout.html' },
{ text: '潜水艦・ボイジャー金策', path: 'housing/submarine_airship.html' },
{ text: 'リテイナー&マーケット金策', path: 'retainer/index.html' },
{ text: 'ミラプリ&2箇所染色ガイド', path: 'glamour/index.html' },
{ text: 'ゴールドソーサー&MGP稼ぎ', path: 'gold_saucer/index.html' }
]
},
{
type: 'links',
title: '⭐ 装備・IL・育成',
links: [
{ text: 'フリトラ最強装備ガイド', path: 'equipment/freetrial_gear_guide.html' }
]
},
{
type: 'links',
title: '🐎 マウント完全攻略',
links: [
{ text: 'マウント総合トップ・全一覧', path: 'mounts/index.html' },
{ text: 'ストーリー・クエスト入手', path: 'mounts/quest_story.html' },
{ text: '友好部族(蛮族)マウント', path: 'mounts/tribal_quests.html' },
{ text: '極蛮神・連動マウント', path: 'mounts/extreme_trials.html' },
{ text: '高難易度レイド・零式', path: 'mounts/raids_savage.html' },
{ text: 'ゴールドソーサー(MGP)', path: 'mounts/gold_saucer.html' },
{ text: 'DD・特殊探索・VD', path: 'mounts/deep_dungeon_field.html' },
{ text: 'アチーブメント・PvP', path: 'mounts/achievements_pvp.html' },
{ text: '生活系・復興・無人島', path: 'mounts/life_island_hunt.html' },
{ text: 'オンラインストア・絶版', path: 'mounts/store_events.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: '⚔️ PvP完全攻略',
links: [
{ text: 'PvP総合・クリコン&FL立ち回り', path: 'pvp/index.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('/mounts/') ||
pathname.includes('/equipment/') ||
pathname.includes('/housing/') ||
pathname.includes('/battle_contents/') ||
pathname.includes('/glamour/') ||
pathname.includes('/retainer/') ||
pathname.includes('/gold_saucer/') ||
pathname.includes('/pvp/') ||
pathname.includes('/deep_dungeon/') ||
pathname.includes('/dungeons/') ||
pathname.includes('/trials/') ||
pathname.includes('/raids/') ||
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 items = WIKI_NAV_CONFIG.globalNav.map(item => {
const active = isCurrentPage(item.path) ? ' class="active"' : '';
return `<li><a href="${rootPrefix}${item.path}"${active}>${item.title}</a></li>`;
}).join('');
nav.innerHTML = `<ul class="wiki-nav-list">${items}</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">
<form onsubmit="doSearch(event)" class="sidebar-search-box">
<input type="text" id="sidebarSearchInput" class="sidebar-search-input" placeholder="キーワード検索...">
<button type="submit" id="sidebarSearchBtn" class="sidebar-search-btn">検索</button>
</form>
</div>
</div>
`;
} else if (section.type === 'links') {
const linksHtml = section.links.map(l => {
const active = isCurrentPage(l.path) ? ' class="active"' : '';
return `<li><a href="${rootPrefix}${l.path}"${active}>${l.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(g => {
const groupLinks = g.links.map(l => {
const active = isCurrentPage(l.path) ? ' class="active"' : '';
return `<li><a href="${rootPrefix}${l.path}"${active}>${l.text}</a></li>`;
}).join('');
groupsHtml += `
<p style="font-size: 11px; font-weight: bold; color: var(--wiki-text-muted); margin: 6px 0 2px;">${g.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 copyToClipboard(button, targetId) {
const target = document.getElementById(targetId);
if (!target) return;
const text = target.innerText;
navigator.clipboard.writeText(text).then(() => {
const originalText = button.innerText;
button.innerText = 'コピー完了!';
button.classList.add('copied');
setTimeout(() => {
button.innerText = originalText;
button.classList.remove('copied');
}, 2000);
}).catch(err => {
console.error('コピー失敗:', err);
});
}
// サイト内検索実行
function doSearch(event) {
if (event) event.preventDefault();
const input = document.getElementById('sidebarSearchInput');
const q = input ? input.value.trim() : '';
if (q) {
const root = getWikiRootPrefix();
window.location.href = `${root}index.html?q=${encodeURIComponent(q)}`;
}
}
// 初期化実行
document.addEventListener('DOMContentLoaded', () => {
const root = getWikiRootPrefix();
const sidebarFrame = document.querySelector('.wiki-sidebar-frame');
const headerFrame = document.querySelector('.wiki-header-frame');
// iframe読み込み失敗時のフォールバックレンダリング
if (!sidebarFrame) {
renderSidebar(root);
}
if (!headerFrame) {
renderHeader(root);
renderGlobalNav(root);
}
renderFooter();
});