PageSourceSearch

https://nk-dental-tokyo.com/js/main.js

js nk-dental-tokyo.com collected 2026-10-06 07:29:52 UTC 7,131 bytes, 245 lines download raw bytes

1$(function () {
2  /******************************
3    telリンク処理
4  ******************************/
5  $(function() {
6    var ua = navigator.userAgent.toLowerCase();
7    var isMobile = /iphone/.test(ua)||/android(.+)?mobile/.test(ua);
8
9    if (!isMobile) {
10      $('a[href^="tel:"]').on('click', function(e) {
11        e.preventDefault();
12      });
13    }
14  });
15
16  /******************************
17    pagetop
18  ******************************/
19  var topBtn = $('.pagetop');
20
21  if(window.matchMedia("(min-width:641px)").matches) {
22    topBtn.hide();
23    $(window).scroll(function () {
24      if ($(this).scrollTop() > 100) {
25        topBtn.fadeIn();
26      } else {
27        topBtn.fadeOut();
28      }
29    });
30  }
31
32  //スクロールしてトップ
33  topBtn.click(function () {
34    $('body,html').animate({
35      scrollTop: 0
36    }, 500);
37    return false;
38  });
39
40  /******************************
41    ナビ追従
42  ******************************/
43  var $nav = $('.header_links, .nav_wrap'),
44  navHead = $nav.offset().top;
45  $(window).on("scroll", function () {
46    //scrollTopの値の分スクロールしたらナビに.fixedが追加される。
47    if ($(this).scrollTop() > navHead) {
48      $nav.addClass('fixed');
49    } else {
50      $nav.removeClass('fixed');
51    }
52  });
53});
54
55/******************************
56  ナビ
57******************************/
58$(function () {
59  //グロナビ開閉処理
60  function sp_nav_open() {
61    $('.btn_menu').toggleClass('active');
62    $('body').toggleClass('nav-open');
63  }
64
65  //ハンバーガーボタンorメニュー外orリンクをタップした時にグロナビ閉じる
66  $('.btn_menu, .nav_overlay, .menu_list_wrap a').on('click', sp_nav_open);
67
68  //アコーディオンメニュー展開
69  $('.is_accord .parent_menu, .is_mega .parent_menu').on('click', function () {
70    var parent_menu = $(this);
71    parent_menu.closest(".nav_slidebtm").find(".child_menu").slideToggle(300, function () {
72      if ($(this).is(':hidden')) {
73        parent_menu.closest(".nav_slidebtm").removeClass("active");
74      } else {
75        parent_menu.closest(".nav_slidebtm").addClass("active");
76      }
77    });
78  });
79});
80
81/******************************
82  アンカーリンク
83******************************/
84$(function() {
85  /* SP・PCでheadの高さ切り替え */
86  var mql = window.matchMedia('(min-width: 641px)');
87  var navHeight;
88  var handleMediaQuery = function(mql) {
89    if (mql.matches) {
90      navHeight = 0;
91    } else {
92      navHeight = 54;
93    }
94  };
95  mql.addEventListener("load",handleMediaQuery,false);
96  handleMediaQuery(mql);
97
98  /* ページ移動時 */
99  var urlHash = location.hash;
100  if(urlHash) {
101    $('body,html').stop().scrollTop(0);
102    setTimeout(function() {
103      var target = $(urlHash);
104      var position = target.offset().top - navHeight;
105      $('body,html').stop().animate({scrollTop:position}, 500);
106    }, 200);
107  }
108
109  /* 同ページ(ハッシュのみ) */
110  $('a[href^="#"]').click(function() {
111      var href= $(this).attr("href");
112      var target = $(href == "#" || href == "" ? 'html' : href);
113      var position = target.offset().top - navHeight;
114      $('body,html').stop().animate({scrollTop:position}, 600, "swing");
115  });
116
117  /* 同ページ(ハッシュ以外) */
118  $('.innerNav a').click(function () {
119    var targetLink = $(this).prop('href');
120    var linkHash = targetLink.indexOf('#');
121    if (linkHash) {
122      var targetURL = targetLink.split('#');
123      var nowPageURL = location.href;
124      nowPageURL = nowPageURL.split('#');
125      if (targetURL[0] == nowPageURL[0]) {//a hrefと現ページURLが同じだった場合
126        var position = $('#' + targetURL[1]).offset().top - navHeight;
127        $("html, body").animate({scrollTop:position}, 600, "swing");
128        return false;
129      }
130    }
131  });
132});
133
134/******************************
135target="_blank"のリンクにrel="noreferrer"を付与
136******************************/
137window.addEventListener('DOMContentLoaded', function(){
138// ページにあるa要素から「target=_blank」が設定された要素を取得
139var a_elements = document.querySelectorAll("a[target=_blank]");
140for(var i=0; i<a_elements.length; i++) {
141  // rel属性を設定
142  a_elements[i].setAttribute("rel","noreferrer");
143}
144
145});
146
147/******************************
148Q&A
149******************************/
150$(function () {
151  $('.js-toggle dt').click(function () {
152    $(this).toggleClass('is-open');
153    $(this).next('.js-toggle dd').slideToggle();
154  });
155});
156
157
158/******************************
159タイマー設定
160******************************/
161// 現在日時を取得し、スケジュールを切り替える
162  document.addEventListener("DOMContentLoaded", function() {
163    const now = new Date();
164    const switchTime = new Date("2025-02-01T00:00:00");
165
166    const oldSchedule = document.getElementById("schedule-old");
167    const newSchedule = document.getElementById("schedule-new");
168
169    if (now >= switchTime) {
170      // 新しいスケジュールを表示
171      oldSchedule.style.display = "none";
172      newSchedule.style.display = "block";
173    } else {
174      // 古いスケジュールを表示
175      oldSchedule.style.display = "block";
176      newSchedule.style.display = "none";
177    }
178  });
179
180
181/******************************
182AIチャットバナー
183******************************/
184window.addEventListener('load', () => {
185  const loading = document.querySelector('#loading');
186  const title = document.querySelector('.fade-in-text');
187  const openingVideo = document.querySelector('.top_opening video');
188  const chatVideo = document.querySelector('.chat__video');
189
190  const delayTime = 1000;
191
192  setTimeout(() => {
193    if (loading) {
194      loading.style.opacity = '0';
195      loading.style.visibility = 'hidden';
196    }
197
198    if (title) {
199      title.animate(
200        [{ opacity: 0, transform: 'translateY(20px)' }, { opacity: 1, transform: 'translateY(0)' }],
201        { duration: 800, easing: 'ease-out', fill: 'forwards' }
202      );
203    }
204
205    if (openingVideo) {
206      openingVideo.play().catch(e => console.log(e));
207
208      // --- タイミング調整のロジック ---
209      let isTriggered = false; // 二重発火防止フラグ
210
211      openingVideo.ontimeupdate = () => {
212        // 残り何秒で次を開始するか(例: 0.5秒前)
213        const offset = 2.5; 
214        
215        if (!isTriggered && (openingVideo.duration - openingVideo.currentTime) < offset) {
216          isTriggered = true; // 1回だけ実行するように固定
217          if (chatVideo) {
218            chatVideo.play().catch(e => console.log(e));
219          }
220        }
221      };
222      // ----------------------------
223    }
224
225    if (chatVideo) {
226      chatVideo.onended = () => {
227        chatVideo.currentTime = 0;
228        chatVideo.pause();
229      };
230    }
231
232  }, delayTime);
233});
234
235// ページの中身が完全に準備できてから実行する
236/*document.addEventListener('DOMContentLoaded', () => {
237  const video = document.querySelector('.chat__video');
238
239  if (video) {
240    video.addEventListener('ended', () => {
241      video.currentTime = 0; // 最初に戻す
242      video.pause();         // 止める
243    });
244  }
245});*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.