(function () { // カテゴリー情報JSON Path const jsonPath = "https://support.rohto.co.jp/iask/"; const target = jsonPath + "catid.json"; // 現在のカテゴリーID let myCatID = 0; let myURL; let myRef, myRefID; // 自身のカテゴリーID判定 myURL = location.href; if (myURL.length) { myCatID = getParam("category", myURL); } // 回答ページ if ($("#faq_detail").length) { // リファラーからID取得 if (myCatID == 0) { // リファラー取得 myRef = document.referrer; if (myRef.length) { myRefID = getParam("category", myRef); if (myRefID > 0) { myCatID = myRefID; } } } // リンクpathからID取得 if (myCatID == 0) { myRef = $("#faqcat-box-in .faqcat-list:nth-child(1) > .faqcat-item:last-child a").attr("href"); myCatID = getParam("category", myRef); } // カテゴリーリスト取得 -> h2タイトル let catList = new Array(); let myCatTitle = "ご質問への回答"; /* IE動作エラー $.getJSON(target, (data) => { for (var i in data) { catList[data[i].cat] = data[i].title; } if (catList.length) { if (myCatID > 0) { myCatTitle = catList[myCatID] + "に関するご質問"; } } $("#detail_title").html(myCatTitle); }); */ $.ajax({ url: target, cache: false, dataType: "json", success: function (data) { for (var i in data) { catList[data[i].cat] = data[i].title; } if (catList.length) { if (myCatID > 0) { myCatTitle = catList[myCatID] + "に関するご質問"; } } $("#detail_title").html(myCatTitle); }, }); // パンくず補完 let checkID, catUrl; $(".faqcat-list").each(function () { catUrl = $(this).find(".faqcat-item:last-child a").attr("href"); checkID = getParam("category", catUrl); if (checkID == myCatID) { $("#link-item01").html($(this).find(".faqcat-item:first-child a").clone()); $("#link-item02").html($(this).find(".faqcat-item:last-child a").clone()); return false; } }); } // メニュー操作 if ($(".lnav .faq_nav").length) { // メニューOPENボタン追加 $(".lnav .faq_nav > li").append(''); // デフォルト開閉 let faqID; $(".lnav .faq_nav li").each(function () { faqID = getParam("category", $(this).find(">a").attr("href")); let targetNav; if (faqID == myCatID) { if ($(this).parent().hasClass("faq_subnav")) { targetNav = $(this).parent(); $(this).addClass("active"); targetNav.addClass("active"); targetNav.css({ height: targetNav.get(0).scrollHeight + "px", transition: "height 0s" }); targetNav.next("span").addClass("active"); } else if ($(this).parent().hasClass("faq_nav")) { targetNav = $(this).find(".faq_subnav"); targetNav.addClass("active"); targetNav.css("height", targetNav.get(0).scrollHeight + "px"); targetNav.next("span").addClass("active"); } return false; } }); // OPENボタンアクション $(".lnav .faq_nav > li > .fmenu_open").click(function () { $(this).toggleClass("active"); let openTarget = $(this).prev("ul"); openTarget.toggleClass("active"); if (openTarget.hasClass("active")) { openTarget.css("height", openTarget.get(0).scrollHeight + "px"); openTarget.css("transition", "height 0.2s ease-out"); } else { openTarget.css("height", "0px"); openTarget.css("transition", "height 0.2s ease-out"); } }); $(".lnav .lnav-lv1").addClass("fadein"); } // Get the URL parameter value function getParam(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); //if (!results) return null; //if (!results[2]) return ""; if (!results) return 0; if (!results[2]) return 0; return decodeURIComponent(results[2].replace(/\+/g, " ")); } })();