PageSourceSearch

https://educarealizegroup.jp/wp-content/themes/theme/js/news-popup.js

js educarealizegroup.jp collected 2026-10-07 23:57:19 UTC 2,936 bytes, 68 lines download raw bytes

1$(function(){
2  //×押下でお知らせポップアップを閉じる
3  $('#popup_button').on('click',function(){
4      $('.popup').fadeOut();
5  });
6});
7
8function popupGetCookie(name) {
9  if (typeof Cookies !== 'undefined' && typeof Cookies.get === 'function') {
10    return Cookies.get(name);
11  }
12  var escapedName = name.replace(/([.$?*|{}()\\[\]\/+^])/g, '\\$1');
13  var match = document.cookie.match(new RegExp('(?:^|; )' + escapedName + '=([^;]*)'));
14  return match ? decodeURIComponent(match[1]) : undefined;
15}
16
17function popupSetCookie(name, value) {
18  if (typeof Cookies !== 'undefined' && typeof Cookies.set === 'function') {
19    Cookies.set(name, value);
20    return;
21  }
22  document.cookie = name + '=' + encodeURIComponent(value) + '; path=/';
23}
24
25$(window).on('load', function() {
26  var displayPopupFlg = false;
27  var nowDateTime = new Date();
28  var popupModified = $('#popup_modified').val();
29  var popupModifiedDateTime = new Date(popupModified);
30  var cookiePopupModified = popupGetCookie('_popup_modified');
31  var cookiePopupModifiedDateTime = new Date(cookiePopupModified);
32  var isLoggedIn = $('#popup_is_logged_in').val();
33  if (isLoggedIn == 1) {
34    displayPopupFlg = true;
35  }
35 else if (typeof cookiePopupModified === 'undefined' ||
36      (cookiePopupModifiedDateTime instanceof Date && popupModifiedDateTime instanceof Date && cookiePopupModifiedDateTime < popupModifiedDateTime)) {
37    // ポップアップ更新日時がcookieにないまたは今回取得した更新日時がcookieにあるものより新しい場合、ポップアップを表示する
38    displayPopupFlg = true;
39    // cookieのポップアップ更新日時を更新する
40    popupSetCookie("_popup_modified", popupModifiedDateTime);
41  } else {
42    var cookiePopup = popupGetCookie('_popup');
43    if (typeof cookiePopup !== 'undefined') {
44      // cookieが残っている場合
45      var cookiePopupDateTime = new Date(cookiePopup);
46      if (cookiePopupDateTime instanceof Date && cookiePopupDateTime < nowDateTime) {
47        // cookieに設定した時刻(前回表示時から1時間後)を過ぎている場合、ポップアップを表示する
48        displayPopupFlg = true;
49      }
50    } else {
51      // cookieが残っていない場合、ポップアップを表示する
52      displayPopupFlg = true;
53    }
54  }
55  if (displayPopupFlg) {
56    // Currently, the `display: flex;` in `.popup_show` on the CSS side is overriding the fade-in effect,
57    // so if you want to enable the fade-in effect again in the future, please write it as follows.
58    // $('.popup').addClass('popup_show').hide().fadeIn(1000);
59    $('.popup').addClass('popup_show').fadeIn('slow');
60    if (isLoggedIn != 1) {
61      // cookieを更新して、1時間は再表示されないようにする
62      nowDateTime.setHours(nowDateTime.getHours() + 1);
63      popupSetCookie("_popup", nowDateTime);
64    }
65  } else {
66    $('.popup').remove();
67  }
68});

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.