PageSourceSearch

https://www.town.kanna.gunma.jp/theme/base/js/common.js

js town.kanna.gunma.jp collected 2026-10-02 07:08:15 UTC 9,478 bytes, 285 lines download raw bytes

1/**
2 * 全デザインサイト共通JS
3 * @author nagai
4 * @version 1.0
5 */
6$(function(){
7
8  // 翻訳プルダウン
9  $('.js-btn-lang-select').on('click', function() {
10    var lang = $(this).parent().find('select[name=translate]').val();
11    window.location.href = lang;
12  });
13  
14  //スムーズスクロール
15  $("a[href*='#'].scroll").smoothScroll();
16
17  //ファイルリンクは別窓表示
18  //$("a[href*='.*']").fileBlank('*') セレクタで拡張子指定 fileBlankの引数にクラス指定;
19  $("a[href*='.pdf']").fileBlank('pdf');
20  $("a[href*='.doc']").fileBlank('word');
21  $("a[href*='.xls']").fileBlank('excel');
22
23  // ファイルリンクのクリックイベント計測
24  $('.file-link-item a').on('click',function(){
25    var targetUrl = $(this).attr('href');
26    var targetLabel = $(this).text();
27    // ga未定義の場合は実行しない
28    if(typeof ga == 'function'){
29      ga('send', 'event', targetUrl, 'download', targetLabel);
30    }
31    // gtag未定義の場合は実行しない(GA4)
32    if(typeof gtag == 'function'){
33      gtag('event', 'sv_file_link_click', {
34        'event_category': 'file_download_category',
35        'event_label': targetLabel + ':' + targetUrl,
36        'value': 1
37      });
38    }
39  });
40
41  //ロールオーバー画像
42  $("img[src*='_off.']").rollOver({off:'_off.',on:'_on.'});
43
44
45  //tableのalign属性削除
46  $.fn.tableDeleteAlign();
47
48
49  // 元のページに戻るリファラーを自動でつける
50  $("a[href*=inquiryId]").each(function() {
51    var a = $(this);
52    var url = a.attr("href");
53    var locaUrl = location.pathname;
54    a.attr("href", url.replace(/(Init\.do\?inquiryId=[0-9]+)/, '$1&ref=www.xxxx.xxxx.xxxx.jp' + locaUrl) );
55  });
56
57
58  var location_href = location.href;
59  var now_site_domain;
60
61  if(location_href.indexOf('http://') != -1 || location_href.indexOf('https://') != -1){
62    var replace_site_domain = site_domain + '/';
63    var now_site_domain = replace_site_domain.replace( /http:/g , "" ).replace( /https:/g , "" );
64  }else{
65    now_site_domain = '';
66  }
67
68  //文字サイズ変更
69  if ($('.scsize').length) {
70    $.fn.fontSizeSwitch();
71  }
72
73  //背景色変更
74  if ($('.sccolor').length) {
75    $.fn.bgColorSwitch();
76  }
77
78  // ヘッダーナビのドロップメニュ
79  if (typeof $.fn.dropMenu != 'undefined') {
80    $("#header-nav").dropMenu();
81  }
82
83  // 文字サイズ変更監視
84  $.fn.fontSizeChange({func:function(){
85    //$("#header-nav .list2").eqGroupHeight(3);
86    $("#wrapper").show();
87  }});
88
89
90  //モーダル(検索)
91  $('.menu-btn-search').lightbox({
92    modalBg:$('.modal-search-bg'),
93    modal:$('.modal-search'),
94    close:$('.modal-menu-close'),
95    scrollID:'sWrapper',
96    lightSpot:$('.menu-btn-search')
97  });
98
99
100  //モーダル(メニュー)
101  $('.menu-btn-menu').lightbox({
102    modalBg:$('.modal-menu-bg'),
103    modal:$('.modal-menu, .menu-btn-menu-close'),
104    close:$('.modal-menu-close, .menu-btn-menu-close'),
105    scrollID:'sWrapper',
106    lightSpot:$('.menu-btn-menu, .menu-btn-menu-close')
107  });
108
109
110  // スマホメニュー内のアコーディオン
111  $('.sp-nav .box button').on('click', function() {
112    $(this).parent('.title').parent('li').find('.bloc').slideToggle();
113    var btn_name = $(this).find('span').text();
114    if($(this).attr('class') === 'mynus') {
115      $(this).attr('class', 'plus');
116      $(this).find('span').text(btn_name.replace('閉じる', '開く'));
117      $(this).attr('aria-selected', false);
118      $(this).attr('aria-expanded', false);
119      $(this).parent('.title').parent('li').find('.bloc').attr('aria-hidden', true);
120    } else {
121      $(this).attr('class', 'mynus');
122      $(this).find('span').text(btn_name.replace('開く', '閉じる'));
123      $(this).attr('aria-selected', true);
124      $(this).attr('aria-expanded', true);
125      $(this).parent('.title').parent('li').find('.bloc').attr('aria-hidden', false);
126    }
127  });
128
129  // アコーディオン(よくある質問用)
130  $('.faq-block').svAccordion({
131    classHead:'.title',
132    classBody:'.childs',
133    classToggle:'on'
134  });
135
136  //アコーディオン(分野別で探す)
137  $('.joho-tab #tab-6 .in2').svAccordion({
138    classHead:'.title',
139    classBody:'.links',
140    classToggle:'on'
141  });
142
143  //スマホプレビューに対応
144  $('.no-escape').each(function(){
145    $(this).html($(this).text());
146  });
147
148  
149  // -----------------------------------------------------
150  // wysiwygの中にtableがあれば、wrapperクラスを付与する
151  // (100%を超えたときにwrapper内でスクロールさせるため)
152  // -----------------------------------------------------
153  if ($('.wysiwyg table').length){
154    $('.wysiwyg table').wrap('<div class="table-wrapper"></div>');
155  }
156
157  /**
158   IE8,9でXMLHttpRequestの代わりにXDomainRequestを使う
159   このセクションは消さないでください。
160   */
161  if ( window.XDomainRequest ) {
162      jQuery.ajaxTransport(function( s ) {
163          if ( s.crossDomain && s.async ) {
164              if ( s.timeout ) {
165                  s.xdrTimeout = s.timeout;
166                  delete s.timeout;
167              }
168              var xdr;
169              return {
170                  send: function( _, complete ) {
171                      function callback( status, statusText, responses, responseHeaders ) {
172                          xdr.onload = xdr.onerror = xdr.ontimeout = xdr.onprogress = jQuery.noop;
173                          xdr = undefined;
174                          complete( status, statusText, responses, responseHeaders );
175                      }
176                      xdr = new XDomainRequest();
177                      xdr.open( s.type, s.url );
178                      xdr.onload = function() {
179                          callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
180                      };
181                      xdr.onerror = function() {
182                          callback( 404, "Not Found" );
183                      };
184                      xdr.onprogress = function() {};
185                      if ( s.xdrTimeout ) {
186                          xdr.ontimeout = function() {
187                              callback( 0, "timeout" );
188                          };
189                          xdr.timeout = s.xdrTimeout;
190                      }
191                      xdr.send( ( s.hasContent && s.data ) || null );
192                  },
193                  abort: function() {
194                      if ( xdr ) {
195                          xdr.onerror = jQuery.noop();
196                          xdr.abort();
197                      }
198                  }
199              };
200          }
201      });
202  }
203
204  //PC・スマホ切り替え(レスポンシブ)
205  if( typeof MutualSwitching !== 'undefined') {
206    MutualSwitching.config.setPathSettings({
207      "/": {
208      "pc_width": 1024,
209      "sp_width": 750,
210      "layout_type": 0
211      }
212    });
213    MutualSwitching.run.ready();
214  }
215
216});
217
218//Page Id search
219$(function(){
220  $('.page-number-search').each(function(){
221    var $this = $(this);
222
223    $(window).load(function() {
224      $this.find('.number-search-submit').click(function() {
225        getPageURL();
226      });
227      $this.find('.number-search-input').keypress(function(ev) {
228        if ((ev.which && ev.which === 13) || (ev.keyCode && ev.keyCode === 13)) {//Enterキー無効
229          getPageURL();
230        } else {
231          return true;
232        }
233      });
234    });
235
236    function getPageURL() {
237      var errorFlag = false;
238      var inputText = $this.find('.number-search-input').val(); // 検索するID取得
239      var errorMessage = '';
240      //エラーチェック
241      //数値チェック
242      if(inputText.match(/[^0-9]+/)) {
243        errorFlag = true;
244        errorMessage = 'ID番号は半角数字で入力してください。';
245      } else if(inputText == '') {
246        errorFlag = true;
247        errorMessage = 'ID番号を入力してください。';
248      }
249
250      if(errorFlag) {
251        //エラーメッセージ表示
252        $('.error-message').remove();
253        $this.find('.number-search-container').append('<p class="error-message">' + errorMessage + '</p>');
254      } else {
255        /*検索ID取得*/
256        $.ajax({
257          type: 'get',
258          url: '//' + cms_api_domain + '/v1/page/get_page_contents.json',
259          data: {
260            app_version: cms_app_version,
261            app_id: cms_app_id,
262            token: cms_api_token,
263            page_no: inputText
264          },
265          dataType : 'json',
266          success: function(data) {
267            if(data.success && data.data)
268              location.href = data.data.page_path;//画面遷移
269            else {
270              //エラーメッセージ表示
271              $('.error-message').remove();
272              $this.find('.number-search-container').append('<p class="error-message">該当のページはございません</p>');
273            }
274          },
275          error: function(data) {
276            //エラーメッセージ表示
277            $('.error-message').remove();
278            $this.find('.number-search-container').append('<p class="error-message">ページを取得できませんでした。</p>');
279          }
280        });
281      }
282    }
283
284  });
285});

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.