// // ユーザーエージェントにてViewport書き換え // $(function() { // spView = 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0'; // tbView = 'width=1200px, maximum-scale=1.0, user-scalable=1'; // if (navigator.userAgent.indexOf('iPhone') > 0 || navigator.userAgent.indexOf('iPod') > 0 || (navigator.userAgent.indexOf('Android') > 0 && navigator.userAgent.indexOf('Mobile') > 0)) { // $('head').prepend(''); // } else if (navigator.userAgent.indexOf('iPad') > 0 || (navigator.userAgent.indexOf('Android') > 0 && navigator.userAgent.indexOf('Mobile') == -1) || navigator.userAgent.indexOf('A1_07') > 0 || navigator.userAgent.indexOf('SC-01C') > 0) { // $('head').prepend(''); // } // // iPhone6 Plus Landscape Viewport // if (navigator.userAgent.indexOf('iPhone') > 0) { // if (window.devicePixelRatio == 3) { // if (window.orientation == 0) { // $('#viewport').attr('content', spView); // } else { // $('#viewport').attr('content', tbView); // } // window.onorientationchange = setView; // // function setView() { // setTimeout(function() { // location.reload(); // return false; // }, 500); // } // } // } // }); // // ユーザーエージェントにてiPhoneXの場合、htmlに「iphonex」クラスを付与 // document.addEventListener('DOMContentLoaded', function() { // if (isIPhoneX()) { // document.documentElement.className = "iphonex"; // } // }, false); // function isIPhoneX() { // return isIPhone() && (window.screen.width === 375 && window.screen.height === 812 || window.screen.width === 812 && window.screen.height === 375); // } // function isIPhone() { // return !!(navigator.userAgent.match(/iPhone/i)); // } // // ユーザーエージェントにてbodyにiPhone = 「iphone」、android = 「android」クラスを付与 // $(function() { // if (navigator.userAgent.indexOf('iPhone') > 0) { // $('body').addClass('iphone'); // }; // if (navigator.userAgent.indexOf('Android') > 0) { // $('body').addClass('android'); // }; // }); // // iPhone safari,firefoxにてページ遷移後戻った際にページリロードし初期状態にする // $(function() { // window.onpageshow = function(event) { // if (event.persisted) { // window.location.reload(); // } // }; // }); // // ios10以上でuser-scalable=noが効かない為、代わりにピンチズーム機能を無効にする // $(function() { // document.documentElement.addEventListener('touchstart', function(event) { // if (event.touches.length > 1) { // event.preventDefault(); // } // }, false); // var lastTouchEnd = 0; // document.documentElement.addEventListener('touchend', function(event) { // var now = (new Date()).getTime(); // if (now - lastTouchEnd <= 300) { // event.preventDefault(); // } // lastTouchEnd = now; // }, false); // }); // スマホ時自動で電話番号リンクに $(function () { var ua = navigator.userAgent; if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0) { $('.js_tel_link').each(function () { var str = $(this).text(); $(this).html($('').attr('href', 'tel:' + str.replace(/-/g, '')).append(str + '')); }); } }); // .js_add_hoverにマウスオーバーしてaddclass $(function () { var ua = navigator.userAgent; if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0) { // SP $('.js_add_hover').on('touchstart', function () { $(this).addClass('_hover'); }); $('.js_add_hover').on('touchend', function () { $(this).removeClass('_hover'); }); } else { // PC $('.js_add_hover').mouseover(function () { $(this).addClass('_hover'); }).mouseout(function () { $(this).removeClass('_hover'); }); } }); // マウスオーバー透過アニメーション $(function () { var ua = navigator.userAgent; if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0) { // SP $('.js_hover').on('touchstart', function () { $(this).stop().fadeTo(200, .5) }); $('.js_hover').on('touchend', function () { $(this).stop().fadeTo(200, 1) }); } else { // PC $('.js_hover').mouseover(function () { $(this).stop().fadeTo(200, .5) }).mouseout(function () { $(this).stop().fadeTo(200, 1) }); } }); // マウスオーバーでsrc置換 $(function () { $('.js_src img').hover(function () { $(this).attr('src', $(this).attr('src').replace('_off', '_on')); }, function () { if (!$(this).hasClass('currentPage')) { $(this).attr('src', $(this).attr('src').replace('_on', '_off')); } }); }); // スムーススクロール document.addEventListener('DOMContentLoaded', function () { var mql = window.matchMedia('screen and (min-width: 1025px)'); function checkBreakPoint(mql) { if (mql.matches) { // pc var headerHight = 70; $('.js_anchor').on('click', function () { var href = $(this).attr('href'); var target = $(href == '#' || href == '' ? 'html' : href); var position = target.offset().top - headerHight; $('html, body').animate({ scrollTop: position }, 500, 'linear'); return false; }); } else { // sp var headerHight = 50; $('.js_anchor').on('click', function () { var href = $(this).attr('href'); var target = $(href == '#' || href == '' ? 'html' : href); var position = target.offset().top - headerHight; $('html, body').animate({ scrollTop: position }, 500, 'linear'); return false; }); } } mql.addListener(checkBreakPoint); checkBreakPoint(mql); }); // スクロールすると出てくる「ページトップへ」ボタン $(function () { var topBtn = $('.js_btn_p_top'); topBtn.hide(); $(window).scroll(function () { if ($(this).scrollTop() > 100) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } }); topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); }); // 要素がウィンドウに入ったら実行 $(function () { $(window).scroll(function () { $('.js_window_in').each(function () { var obj_t_pos = $(this).offset().top; var scr_count = $(document).scrollTop() + (window.innerHeight / 1); if (scr_count > obj_t_pos) { $(this).removeClass('_hide'); $(this).addClass('_show'); } else { $(this).addClass('_hide'); $(this).removeClass('_show'); } }); }); }); // 要素がウィンドウに入ったら実行 1回のみ $(function () { $(window).scroll(function () { $('.js_window_in_one').each(function () { var obj_t_pos = $(this).offset().top; var scr_count = $(document).scrollTop() + (window.innerHeight / 1); if (scr_count > obj_t_pos) { $(this).addClass('_show'); } }); }); }); // img ドラッグ・右クリック禁止 // $(function() { // $('img').attr('onmousedown', 'return false'); // $('img').attr('onselectstart', 'return false'); // $('img').attr('oncontextmenu', 'return false'); // }); // toggle nav footer $(function () { if ($(window).width() < 1025) { $('.js_toggle_sp').click(function () { $(this).parent().toggleClass('active'); }) } }) // scrollTop $(function () { $(window).scroll(function () { if ($(this).scrollTop() > 20) { $('.l_header').addClass('fixed'); } else { $('.l_header').removeClass('fixed'); } }) }) //js toggle menu $(function () { $('.js_toggle_menu').click(function () { $('body').toggleClass('on_menu'); }) }) $(function () { $('.js_toggle_child').click(function () { $(this).parent().toggleClass('on_child'); }) }) // animate #a $(function () { $('a[href^="#"]').on('click', function (event) { var target = $($(this).attr('href')); if (target.length) { event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 500); } }) }) // js togle item $(function () { $('.js_toggle_txt_2').click(function () { $(this).toggleClass("active"); $(this).nextAll().toggleClass("active"); }) }) // js question $(function () { $(".js_question").click(function () { $(this).toggleClass("active"); }); }) $(document).ready(function () { $('.show_ttl').click(function (e) { e.preventDefault(); var target = $(this).attr("href"); var height = $(target).offset().top - 70; $("html, body").stop().animate({ scrollTop: height }, "slow"); return false; }); }); // $(window).scroll(function() { // var scrollDistance = $(window).scrollTop(); // $('.page-section').each(function(i) { // if ($(this).position().top <= scrollDistance) { // $('.navigation a.active').removeClass('active'); // $('.navigation a').eq(i).addClass('active'); // } // }); // }).scroll(); function addBanner(thisEl, after) { const url = document.querySelector('#urlScript').dataset.url const addEl = `

まずは状況をお知らせください【24時間365日】

通話料無料 0120-0120-24

` const div = document.createElement('div') div.innerHTML = addEl if (after && url) { thisEl.parentNode.insertBefore(div, thisEl.nextElementSibling) } else { thisEl.parentNode.insertBefore(div, thisEl) } } document.addEventListener('DOMContentLoaded', function () { const tocEl = document.querySelector('#toc_container'); const thirdH3 = document.querySelectorAll('#single_content h3:nth-of-type(3n)') const lastEl = document.querySelector('#single_content').lastChild if (tocEl) { addBanner(tocEl, true) } if (thirdH3) { thirdH3.forEach((el) => { addBanner(el) }) } if (lastEl) { addBanner(lastEl, true) } var contentsList = document.querySelector('.agenda_list'); // 目次を追加する先 (ol要素) var ol = document.createElement('ol'); // 作成する目次のコンテナ要素 // .content_dialogue-info配下のh2、h3要素を全て取得する var matches = document.querySelectorAll('.content_dialogue-info h2'); // 取得した見出しタグ要素の数だけ以下の操作を繰り返す matches.forEach(function (value, i) { // 見出しタグ要素のidを取得し空の場合は内容をidにする var id = value.id; if (id === '') { id = value.textContent; value.id = id; } // 要素がh2タグの場合 if (value.tagName === 'H2') { // var ol = document.createElement('ol'); var li = document.createElement('li'); li.className = 'agenda_item'; var a = document.createElement('a'); // 追加する
  1. タイトル
を準備する a.innerHTML = value.textContent; a.href = '#' + value.id; li.appendChild(a); ol.appendChild(li); // // コンテナ要素である
の中に要素を追加する // div.appendChild(ol); } }); // 最後に画面にレンダリング contentsList.appendChild(ol); });