document.addEventListener("DOMContentLoaded", function() {
const form = document.getElementById("diagnosisForm");
form.addEventListener("submit", function(event) {
event.preventDefault();
const year = Number(document.getElementById("year").value);
const month = Number(document.getElementById("month").value);
const day = Number(document.getElementById("day").value);
const resultDiv = document.getElementById("result");
if (!year || !month || !day) {
resultDiv.textContent = "すべての項目を正しく入力してください。";
return;
}
const date = new Date(year, month - 1, day);
if (
date.getFullYear() !== year ||
date.getMonth() + 1 !== month ||
date.getDate() !== day
) {
resultDiv.textContent = "ありえない日です";
return;
}
const data = [
{"year":1946,"month":11,"day":1,"type":"A6"},
// 必要な全データをここに追加
];
const match = data.find(
entry => entry.year === year && entry.month === month && entry.day === day
);
if (match && match.type) {
const pageIdMap = {
F1: 2801, F2: 2802, F3: 2803, F4: 2804,
A5: 2881, A6: 2882, A7: 2883, A8: 2884,
M9: 2891, M10: 2892, M11: 2893, M12: 2894
};
const pageId = pageIdMap[match.type] || "";
resultDiv.innerHTML = `
あなたのタイプは
${match.type} です。
${match.type}タイプの詳しい解説を見る
`;
} else {
resultDiv.textContent = "該当データが見つかりませんでした。";
}
});
});