PageSourceSearch

https://www.kuriharacity.jp/core/js/new_head.js

js kuriharacity.jp collected 2026-10-02 07:13:35 UTC 5,145 bytes, 188 lines download raw bytes

1document.addEventListener("DOMContentLoaded", () => {
2
3  function updateIsOpen(){
4    const body = document.body;
5
6    if(
7      body.classList.contains("globalmenu-open") ||
8      body.classList.contains("searchmenu-open") ||
9      body.classList.contains("gnavmenu-open")
10    ){
11      body.classList.add("is-open");
12    } else {
13      body.classList.remove("is-open");
14    }
15  }
16
17  function setupToggle(btnId, className, otherClassNames = []){
18    const btn = document.getElementById(btnId);
19
20    if(btn){
21      btn.addEventListener("click", function(e){
22        e.preventDefault();
23        e.stopImmediatePropagation();
24
25        const body = document.body;
26
27        otherClassNames.forEach(name => {
28          body.classList.remove(name);
29        });
30
31        body.classList.toggle(className);
32        updateIsOpen();
33
34      }, true); 
35    }
36  }
37
38  setupToggle("menuopen","globalmenu-open",["searchmenu-open","gnavmenu-open"]);
39  setupToggle("searchopen","searchmenu-open",["globalmenu-open","gnavmenu-open"]);
40  setupToggle("gnavopen","gnavmenu-open",["globalmenu-open","searchmenu-open"]);
41
42  const closeBtns = document.querySelectorAll("#menuclose");
43
44  closeBtns.forEach(btn => {
45    btn.addEventListener("click", () => {
46      const body = document.body;
47
48      body.classList.remove("globalmenu-open");
49      body.classList.remove("searchmenu-open");
50      body.classList.remove("gnavmenu-open");
51      body.classList.remove("is-open");
52    });
53  });
54
55});
56
57
58document.addEventListener('DOMContentLoaded', function () {
59
60  // ===== 追加関数群 =====
61
62  function insertGlobalNav() {
63    const source = document.querySelector('.page_control_wrap .global-nav .navlist');
64    const target = document.querySelector('.page_control_wrap2 .global-nav');
65
66    if (source && target) {
67      target.innerHTML = source.outerHTML;
68    }
69  }
70
71  function insertEasySearch() {
72    const source = document.querySelector('.global-easysearch');
73    const target = document.querySelector('.easysearch');
74
75    if (source && target) {
76      target.innerHTML = source.outerHTML;
77    }
78  }
79
80  // ★ここだけ修正
81  function insertSearchKeywords() {
82    const source = document.querySelector('.page_control_wrap .search-keywords');
83    const targetForm = document.querySelector('.page_control_wrap2 #searchForm');
84
85    if (source && targetForm) {
86      targetForm.insertAdjacentHTML('beforeend', source.outerHTML);
87    }
88  }
89
90  document.addEventListener('mousedown', function (e) {
91
92    const target = e.target.closest('#gnavopen');
93    if (!target) return;
94
95    e.preventDefault();
96    e.stopImmediatePropagation();
97
98    const body = document.body;
99
100    if (body.classList.contains('is-open')) {
101      body.classList.remove('is-open');
102    } else {
103      body.classList.add('is-open');
104    }
105
106    let wrap = document.querySelector('.page_control_wrap2');
107
108    if (!wrap) {
109
110      const html = `
111<div class="page_control_wrap2" aria-hidden="true">
112
113  <nav class="global-nav"></nav>
114
115  <div class="nav-search"> 
116    <div class="easysearch"></div>
117
118    <form id="searchForm" class="search" action="/sitesearch.html" method="get">
119      <p class="help">
120        <a href="/w009/050/050/PAGE000000000000010661.html">検索方法</a> 
121      </p> 
122      <div class="search-bar"> 
123        <label class="search_txt" for="search_txt"> 
124          <span>サイト内検索</span>
125        </label> 
126        <input id="search_txt" class="search_txt" name="q" type="text" placeholder="キーワードを入力">
127        <input id="searchButton" class="search_bt" name="btnG" value="検索" type="submit">
128        <input id="searchStart" name="start" value="0" type="hidden">
129        <input id="searchNum" name="num" value="20" type="hidden">
130      </div>
131
132      <span>よく検索されるキーワード</span>
133
134    </form>
135  </div>
136</div>
137`;
138
139      const header = document.querySelector('header');
140
141      if (header) {
142        header.insertAdjacentHTML('afterbegin', html);
143      } else {
144        document.body.insertAdjacentHTML('afterbegin', html);
145      }
146
147      wrap = document.querySelector('.page_control_wrap2');
148
149      // ===== CMS生成HTMLコピー =====
150      insertGlobalNav();
151      insertEasySearch();
152      insertSearchKeywords();
153
154      setTimeout(() => {
155        wrap.classList.add('is-active');
156        wrap.setAttribute('aria-hidden', 'false');
157      }, 10);
158
159      return;
160    }
161
162    if (wrap.classList.contains('is-active')) {
163      wrap.classList.remove('is-active');
164      wrap.setAttribute('aria-hidden', 'true');
165    } else {
166      wrap.classList.add('is-active');
167      wrap.setAttribute('aria-hidden', 'false');
168    }
169
170  }, true);
171
172
173  function removeGnavMenu() {
174    const wrap = document.querySelector('.page_control_wrap2');
175    if (wrap) wrap.remove();
176  }
177
178  if (window.innerWidth <= 1200) {
179    removeGnavMenu();
180  }
181
182  window.addEventListener('resize', function () {
183    if (window.innerWidth <= 1200) {
184      removeGnavMenu();
185    }
186  });
187
188});

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.