PageSourceSearch

https://www.town.moroyama.saitama.jp/theme/base/js/common_lib.js

js town.moroyama.saitama.jp collected 2026-10-02 07:34:31 UTC 52,965 bytes, 1,971 lines download raw bytes

1/**
2 * SMART CMS共通関数
3 * @version 1.1
4 */
5
6/**
7 * ファイルリンクは別窓表示
8 */
9//$.fn.fileBlank = function() {
10//  var target = this;
11//
12//  target.each(function() {
13//    $(this).attr("target", "_blank");
14//  });
15//};
16
17$.fn.fileBlank = function(ext_) {
18
19  var target = this;
20
21  this.addClass(ext_);
22  this.attr("target", "_blank");
23
24
25};
26
27
28
29/**
30 * class名で別窓表示(外部リンク付)
31 */
32$.fn.jsBlankAddText = function() {
33  var target = this;
34
35  target.each(function() {
36    $(this).prepend('(外部リンク)');
37    //$(this).append('&nbsp;<img height="14" width="15" alt="外部サイトへ" src="./img_page/icon_blank.gif">');
38    $(this).click(function(){
39      window.open(this.href,'_blank');
40      return false;
41    });
42  });
43};
44
45/**
46 * class名で別窓表示
47 */
48$.fn.jsBlank = function() {
49  var target = this;
50
51  target.each(function() {
52    $(this).click(function(){
53      window.open(this.href,'_blank');
54      return false;
55    });
56  });
57};
58
59/**
60 * スムーズスクロール
61 * $('a[href*=#].smoothCom').smoothScroll();
62 */
63$.fn.smoothScroll = function() {
64  var target = this;
65
66  target.each(function(){
67    var href = $(this).attr("href");
68
69
70    if(href=='#') {
71      $(this).click(function() {
72        return false;
73      });
74      return true;
75    }
76
77    var hrefAry = href.match(/^([^#]*)#([^#]+)$/,function(whole,$1){ return $1 });
78
79    if(hrefAry) {
80      var j = $( "#" + hrefAry[2] );
81      if(j.size() > 0) {
82
83        jQuery.data($(this).get(0), "pos", j);
84
85        $(this).click(function() {
86
87          $('html,body').animate({scrollTop: jQuery.data($(this).get(0), "pos").offset().top}, 400, "linear", function(){
88            location.hash = hrefAry[2];
89          });
90          return false;
91        });
92      }
93    }
94  });
95};
96
97/**
98 * 現在のカテゴリを_onにする
99 * 
100 *  $("#header-nav .list li > a").categoryOn('^(/[^/]+/).*$');
101 *  $("#header-nav .list li > a").categoryOn('^/[^/]+(/[^/]+/).*$');(特別コンテンツ)
102 *
103 * @param string 判定するパス範囲(正規表現)
104 */
105$.fn.categoryOn = function(path) {
106  var target = this;
107
108  var regPath = new RegExp(path, "i");
109
110  var req = location.pathname;
111  req = req.replace(regPath, '$1');
112
113  target.each(function(idx){
114    var href = $(this).attr("href");
115    // ドメイン付きリンクでも反転できるようにする
116    if(href.indexOf(req) > -1) {
117      var imgJ = $(this).find('img');
118      imgJ.unbind('mouseenter').unbind('mouseleave');
119      imgJ.attr('src', imgJ.attr('src').replace(/_off(\.gif|\.jpg|\.png)/,"_on"+'$1') );
120      return false;
121    }
122  });
123};
124
125/**
126 * ._offの画像をロールオーバー
127 * @param object 設定
128 */
129$.fn.rollOver = function(_cfg) {
130  var target = this;
131
132  target.each(function(){
133    $(this).hover(function () {
134      $(this).attr("src", $(this).attr("src").replace(_cfg.off, _cfg.on));
135    },function () {
136      $(this).attr("src", $(this).attr("src").replace(_cfg.on, _cfg.off));
137    });
138  });
139};
140
141/**
142 * ドメインの表記をIPアドレスに変換
143 * @param object 設定
144 */
145$.fn.urlTranslate = function(_cfg) {
146  var target = this;
147
148  target.each(function(){
149      $(this).attr("href", $(this).attr("href").replace(_cfg.before, _cfg.after));
150  });
151};
152
153/**
154 * 透過ロールオーバー
155 */
156$.fn.rollOverAlpha = function() {
157  var target = this;
158
159  target.hover(function(){
160    $(this).fadeTo(100, 0.7); // マウスオーバーで透明度を60%にする
161  },function(){
162    $(this).fadeTo(100, 1.0); // マウスアウトで透明度を100%に戻す
163  });
164};
165
166/**
167 * 文字サイズ変更(標準 or 大きくする)背景色変更
168 * $.fn.styleCatcherUpNormal({btnCls: "scsize",cssID: "scsize",prAry: ['size_default.css', 'size_up.css', 'size_up2.css', 'size_up3.css'],cssPath: '/theme/base/css/',def: 0});
169 *
170 * @param object 設定
171 */
172$.fn.styleCatcherUpNormal = function(config) {
173  config = $.extend({
174    btnCls: "scsize",
175    cssID: "scsize",
176    prAry: ['0.css', '1.css', '2.css', '3.css'],
177    cssPath: '/theme/base/css/',
178    def: 0,
179    imgCls: ['.normal-on', '.normal-off', '.big-on', '.big-off']
180  },config);
181
182  var cssTag = $('<link rel="stylesheet" />');
183  cssTag.attr('id', config.cssID);
184  $("body").append(cssTag);
185
186  //parameter number
187  var prNum;
188  if($.cookie(config.cssID)) {
189    prNum = Number($.cookie(config.cssID));
190  } else {
191    prNum = Number(config.def);
192  }
193
194  function offRollOver() {
195    $('.' + config.btnCls).each(function(){
196      var img = $(this).find("img");
197      img.unbind();
198    });
199  }
200  offRollOver();
201
202  $('.' + config.btnCls).css("cursor", "pointer").css("cursor", "hand");
203  
204  $('.' + config.btnCls).click(function(){
205    var j = $(this);
206    var img = j.find("img");
207    var cl = j.attr("class");
208
209    if(cl.indexOf("up") != -1) {
210      prNum++;
211      if(config.prAry.length-1 <= prNum) {
212        prNum = config.prAry.length-1;
213        $(config.imgCls[0] + ',' + config.imgCls[3]).addClass('hide');
214        $(config.imgCls[1] + ',' + config.imgCls[2]).removeClass('hide');
215      } else {
216        $(config.imgCls[0] + ',' + config.imgCls[2]).addClass('hide');
217        $(config.imgCls[1] + ',' + config.imgCls[3]).removeClass('hide');
218      }
219
220    } else if(cl.indexOf("normal") != -1) {
221      prNum = 0;
222      $(config.imgCls[1] + ',' + config.imgCls[2]).addClass('hide');
223      $(config.imgCls[0] + ',' + config.imgCls[3]).removeClass('hide');
224    }
225
226    $('#' + config.cssID).attr("href", config.cssPath + config.prAry[prNum]);
227
228    //prNumを保存
229    $.cookie(config.cssID, prNum, {path:'/'});
230
231    return false;
232  });
233
234  $('#' + config.cssID).attr("href", config.cssPath + config.prAry[prNum]);
235};
236
237/**
238 * 文字サイズ(小、中、大)背景色変更
239 * $.fn.styleCatcher({btnCls: "scColor",cssID: "scColor", cssPath:'/theme/base/css/',def: 2});
240 *
241 * @param object 設定
242 */
243$.fn.styleCatcher = function (config) {
244  config = $.extend({
245    attr: 'id',
246    btnCls: 'scsize',
247    cssID: 'scsize',
248    cssPath: '/theme/base/css/',
249    def: 0
250  }, config);
251  var cssTag = $('<link rel="stylesheet">');
252  cssTag.attr('id', config.cssID);
253  $('body').append(cssTag);
254 
255  function offRollAndOn(_id) {
256    $('.' + config.btnCls).each(function (idx) {
257      var id = $(this).attr(config.attr);
258      var img = $(this).find('img');
259      img.unbind();
260      if (_id == id) {
261        img.attr('src', img.attr('src').replace('_off.', '_on.'));
262      } else {
263        img.attr('src', img.attr('src').replace('_on.', '_off.'));
264        img.hover(function () {
265          $(this).attr('src', $(this).attr('src').replace('_off.', '_on.'));
266        }, function () {
267          $(this).attr('src', $(this).attr('src').replace('_on.', '_off.'));
268        });
269      }
270    });
271  }
272  $('.' + config.btnCls).attr('href', '#');
273  $('.' + config.btnCls).click(function () {
274    var id = $(this).attr(config.attr);
275    var img = $(this).find('img');
276    offRollAndOn(id);
277    $('#' + config.cssID).attr('href', config.cssPath + id + '.css');
278    $.cookie(config.cssID, id, {
279      path: '/'
280    });
281    return false;
282  });
283  var fileName;
284  if ($.cookie(config.cssID)) {
285    fileName = $.cookie(config.cssID);
286  } else {
287    fileName = $($('.' + config.btnCls).get(config.def)).attr(config.attr);
288  }
289  offRollAndOn(fileName);
290  $('#' + config.cssID).attr('href', config.cssPath + fileName + '.css');
291};
292
293/**
294 * XPのIE7と他のOSにメイリオのフォント指定
295 */
296$.fn.fontMeiryo = function() {
297  function getUserAgent() {
298    var obj = {};
299    obj['userAgent'] = navigator.userAgent;
300    obj['os'] = null;
301    obj['osVersion'] = null;
302    obj['browser'] = null;
303    obj['browserVersion'] = null;
304
305    if(obj['userAgent'].match(/Win/)) {
306      obj['os']='win';
307    }
308
309    if(obj['userAgent'].match(/Win(dows)?[ ]*(NT[ ]*5\.1|XP)/)) {
310      obj['osVersion']='xp';
311    }
312
313    if(obj['userAgent'].match(/MSIE/)) {
314      obj['browser']='ie';
315      var ary = obj['userAgent'].match(/MSIE[ ]*([0-9]+)/);
316      if(ary != null) {
317        obj['browserVersion']=Number(ary[1]);
318      }
319    }
320
321    return obj;
322  }
323
324  var userAgent = getUserAgent();
325  if(  (userAgent['osVersion'] == 'xp' && userAgent['browserVersion'] == '7') || userAgent['osVersion'] != 'xp'  ) {
326    $("body").append('<style>body {font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif !important;} </style>');
327
328  }
329};
330
331/**
332 * 段組の個々に高さを設定する
333 * ※文字の高さなどが変わるためフォントを変更してから実行すること
334 * $(".level1Row2Mod").eqGroupHeight(2);
335 *
336 * @param integer 段組数
337 */
338$.fn.eqGroupHeight = function(turn_) {
339  var target = this;
340  target.each(function(){
341    //揃えたい分確保した後、高さ揃える…ループ
342    var ary = new Array();
343
344    //一旦、高さをリセット
345    $(this).find("> *").css('height', 'auto');
346
347    $(this).find("> *").each(function(idx2_){
348      ary.push($(this));
349      if(ary.length >= turn_) {
350        var max = 0;
351        for (var i=0; i < ary.length; i++){
352          max = Math.max(ary[i].height(), max);
353        }
354        for (var j=0; j < ary.length; j++){
355          ary[j].height(max);
356        }
357        ary[0].addClass("first-left");//最初の要素にだけClassを振る
358        ary = new Array();
359      }
360    });
361    //未だ配列に残っている分を高さ揃える
362    if(ary.length > 0) {
363      var max = 0;
364      for (var i=0; i < ary.length; i++){
365        max = Math.max(ary[i].height(), max);
366      }
367      for (var j=0; j < ary.length; j++){
368        ary[j].height(max);
369      }
370      ary[0].addClass("first-left");//最初の要素にだけClassを振る
371    }
372  });
373};
374
375/**
376 * 2階層1列
377 * $(".level2Row1Mod").level2Row1();
378 */
379$.fn.level2Col1 = function(config) {
380  config = $.extend({
381    boxClass1: ".box",
382    boxClass2: ".box2",
383  },config);
384
385  var targetsJ = this;
386  var getUl = function(boxJ) {
387    return boxJ.find('ul');
388  }
389  var getLi = function(boxJ) {
390    return boxJ.find('li');
391  }
392
393  // box2のグループは一つにまとめる(ページ一覧)
394  targetsJ.each(function(){
395    var targetJ = $(this);
396    var boxes = targetJ.find('> ' + config.boxClass1 + ',> ' + config.boxClass2);
397
398    var tmpIsBox2 = false;
399    var tmpBox2;
400    boxes.each(function(idx_){
401      var boxJ = $(this);
402
403      var isBox2 = boxJ.is(config.boxClass2);
404      if(!isBox2) {
405        tmpIsBox2 = false;
406      }
407
408      if(tmpIsBox2 && isBox2) {
409        tmpBox2.append(getLi(boxJ));
410        boxJ.remove();
411      }
412
413      if(!tmpIsBox2 && isBox2) {
414        tmpBox2 = getUl(boxJ);
415        tmpIsBox2 = true;
416      }
417    });
418  });
419
420  // box2の上下にボーダーを入れる
421  targetsJ.each(function(){
422    var targetJ = $(this);
423    var boxes = targetJ.find('> ' + config.boxClass2);
424
425    boxes.each(function(idx_){
426      var boxJ = $(this);
427
428      // 上か下にボーダーを入れる
429      if(boxJ.prev().is(config.boxClass + ',' + config.boxClass2)) {boxJ.addClass('borderTopCom');}
430      if(boxJ.next().is(config.boxClass + ',' + config.boxClass2)) {boxJ.addClass('borderBtmCom');}
431    });
432  });
433
434}
435
436/**
437 * 2階層2列
438 * $(".level2Row2Mod").level2Col2();
439 */
440$.fn.level2Col2 = function(config){
441  config = $.extend({
442    boxClass1: ".box",
443    boxClass2: ".box2",
444    floatClassL: "left-col",
445    floatClassR: "right-col"
446  },config);
447
448  var targetsJ = this;
449
450  targetsJ.each(function(){
451    var parent = $(this);
452
453    var boxes = parent.find('> ' + config.boxClass1);
454    var col;
455
456    // 挿入目印を置く
457    var marker = $('<div />');
458    boxes.filter(':last').after(marker);
459
460    boxes.each(function(idx_){
461      var box = $(this);
462      var parent = box.parent();
463
464      if(idx_ % 2 == 0) {
465        col = $('<div class="col" />');
466        marker.before(col);
467        box.addClass(config.floatClassL);
468        col.append(box);
469      }
470      if(idx_ % 2 == 1) {
471        box.addClass(config.floatClassR);
472        col.append(box);
473      }
474    });
475
476    // 挿入目印を削除
477    marker.remove();
478  });
479
480  // box2の上下にボーダーを入れる
481  targetsJ.each(function(){
482    var targetJ = $(this);
483    var boxes = targetJ.find('> ' + config.boxClass1);
484
485    boxes.each(function(idx_){
486      var boxJ = $(this);
487
488      // 上か下にボーダーを入れる
489      if(boxJ.prev().is('.col')) {boxJ.addClass('border-top-com');}
490      if(boxJ.next().is('.col')) {boxJ.addClass('border-btm-com');}
491    });
492  });
493
494};
495
496/**
497 * 文字サイズ変更監視
498 * $.fn.fontSizeChange({func:function(){
499 *  $(".level1Row2Mod").eqGroupHeight(2);
500 *  $(".level2Row1Mod .list").eqGroupHeight(2);
501 *  $("#wrapper").show();
502 * }});
503 *
504 * @param object 設定
505 */
506$.fn.fontSizeChange = function(cfg_) {
507  function setFontSizeListener(func_) {
508    var s = $("<span />")
509      .text(" ")
510      .hide()
511      .appendTo("body");
512    s.data("size", s.css("font-size"));
513    s.data("timer", setInterval(function(){
514      if(s.css("font-size") != s.data("size")) {
515        s.data("size", s.css("font-size"));
516        func_();
517      }
518    }, 1000));
519
520  };
521
522  cfg_.func();
523  setFontSizeListener(cfg_.func);
524};
525
526/**
527 * 横並び画像※ie6 zoom:0.97で画像が落ちる現象を解消、下のキャプションが折り返すため
528 */
529$.fn.colImgSetWidth = function() {
530
531    var target = this;
532    var windowWidth = $(window).innerWidth();
533    var windowSm = 768;//ブレークポイント 
534
535    target.each(function(){
536
537        var L = $(this).find(".left-col");
538        var R = $(this).find(".right-col");
539
540        var LImg = L.find("img");
541        var RImg = R.find("img");
542
543      if (!$.browser.msie && windowSm <= windowWidth || $.browser.msie && $.browser.version < 9) {
544
545        L.width(LImg.width());
546        R.width(RImg.width());
547        
548      }else{
549
550        L.removeAttr('style');;
551        R.removeAttr('style');;
552
553      }
554
555    });
556
557};
558
559/**
560 * 市長の予定表の土日祝に色づけ
561 */
562$.fn.shichoDonichi = function() {
563  var target = this;
564
565  target.each(function(){
566    var day = $(this).find("td:eq(1)").text();
567
568    if(day.indexOf("土") > -1) {
569      $(this).addClass("sat");
570    }
571    if(day.indexOf("祝") > -1 || day.indexOf("日") > -1) {
572      $(this).addClass("sun");
573    }
574  });
575};
576
577/**
578 * tableのalign属性削除
579 */
580$.fn.tableDeleteAlign = function() {
581  $("table").removeAttr("align");
582};
583
584/**
585 * スマートフォンへのリンク
586 * $.fn.smartphoneLink({smphDir:'i', img:'<img src="/theme/base/img_pc_common/smartphone.png" width="960" height="114" alt="スマートフォン専用サイトへ" />'});
587 *
588 * @param object 設定
589 */
590$.fn.smartphoneLink = function(cfg_) {
591  if ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) ||
592    navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0) {
593    if(location.pathname.match(/^\/i\//) == null) {
594      $("body").prepend('<p id="smartphone"><a href="/' + cfg_.smphDir + location.pathname + '">' + cfg_.img + '</a></p>');
595    }
596  }
597};
598
599/**
600 * スマートフォンへリダイレクト
601 * $.fn.smartphoneRedirect({smphDir:'i', img:'<img src="/theme/base/img_pc_common/smartphone.png" width="960" height="114" alt="スマートフォン専用サイトへ" />'});
602 *
603 * @param object 設定
604 */
605$.fn.smartphoneRedirect = function(cfg_) {
606  if ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) ||
607    navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0) {
608    if(location.pathname.match(/^\/i\//) == null) {
609      if($.cookie('pclink') != null) {
610        $('body').prepend('<p id="smartphone"><a href="/' + cfg_.smphDir + location.pathname + '">' + cfg_.img + '</a></p>');
611        $('#smartphone a').on('click', function() {
612          $.cookie('pclink', null);
613          return true;
614        });
615        return;
616      }
617      location.pathname = '/' + cfg_.smphDir + location.pathname;
618    }
619  }
620};
621
622/**
623 * スマホからPCに戻るリンク
624 * $('.smph2PcCom').smph2Pc({
625 *  cookie: false
626 * });
627 *
628 * @param object 設定
629 */
630$.fn.smph2Pc = function(config_) {
631  config_ = $.extend({
632    // クリックしたことを保持する
633    cookie: false
634  },config_);
635
636  var targetsJ = this;
637  targetsJ.attr('href', location.pathname.replace(/^\/i/,""));
638  targetsJ.on('click', function() {
639    if(config_.cookie) {
640      $.cookie('pclink', '1', { path: '/'});
641    }
642    return true;
643  });
644}
645
646/**
647 * 画像タブ
648 * ※classHideは設定してください、tabsとpagesは一つだけ存在するmodを指定してください(id指定が最適)
649 * $.fn.imgTab({defaultSelect:0,cookie:'topTab',tabs:$("#topTab .list li"),pages:$("#topTab .box")});
650 *
651 * @param object 設定
652 */
653$.fn.imgTab = function(config) {
654  var targetJ = this;
655
656  config = $.extend({
657    tabs: null,
658    pages: null,
659    defaultSelect: 0,
660    cookie: 'tab',
661    off: '_off.',
662    on: '_on.',
663    classHide: 'hide'
664  }, config);
665
666  if (config.tabs == null || config.pages == null) {
667    return;
668  }
669
670  var ClassTab = function() {}
671
672  ClassTab.prototype = {
673
674    rollOver: function(select) {
675      var lis = config.tabs;
676      lis.each(function(idx){
677        var index = lis.index(this);
678        var img = $(this).find("img");
679        img.unbind("mouseenter").unbind("mouseleave"); //img.unbind('hover');ではできないらしい
680
681        var replaceOn = function(j) {
682          j.each(function(){
683            $(this).attr("src", $(this).attr("src").replace(config.off, config.on));
684          });
685          
686        };
687        var replaceOff = function(j) {
688          j.each(function(){
689            $(this).attr("src", $(this).attr("src").replace(config.on, config.off));
690          });
691        };
692        replaceOff(img);
693        if (select == idx) {
694          replaceOn(img);
695        } else {
696          img.hover(function() {
697            replaceOn(img);
698          }, function() {
699            replaceOff(img);
700          });
701        }
702      });
703    },
704    showpage: function(select) {
705      config.pages.each(function(idx) {
706        if (idx == select) {
707          $(this).removeClass(config.classHide);
708        } else {
709          $(this).addClass(config.classHide);
710        }
711      });
712    },
713    init: function() {
714
715      var cls = this;
716
717      config.pages.each(function(idx) {
718        if (idx == config.defaultSelect) {
719          $(this).removeClass(config.classHide);
720        } else {
721          $(this).addClass(config.classHide);
722        }
723      });
724
725      config.tabs.click(function() {
726        var idx = config.tabs.index(this);
727        cls.rollOver(idx);
728        cls.showpage(idx);
729        // アクセシブル対応
730        ariaTab(config.tabs, config.pages, idx);
731        //選択されたタブの番号をクッキーに保存
732        $.cookie(config.cookie, idx, {path: '/', expires: 30 });
733        return false;
734      });
735
736      cls.rollOver(config.defaultSelect);
737      // アクセシブル対応
738      ariaTab(config.tabs, config.pages, config.defaultSelect);
739    }
740  };
741
742
743  // 前回選択タブ復元
744  if ($.cookie(config.cookie)) {
745    config.defaultSelect = $.cookie(config.cookie);
746  }
747  // タブ作成
748  var tab = new ClassTab();
749  tab.init();
750
751};
752
753/**
754 * テキストタブ
755 * ※classHideは設定してください、tabsとpagesは一つだけ存在するmodを指定してください(id指定が最適)
756 * $.fn.textTab({defaultSelect:0,cookie:'topTab',tabs:$("#topTab .titleList li"),pages:$("#topTab .box")});
757 *
758 * @param object 設定
759 */
760$.fn.textTab = function(config) {
761  var targetJ = this;
762
763  config = $.extend({
764    tabs: null,
765    pages: null,
766    defaultSelect: 0,
767    cookie: 'tab',
768    classHover: 'hover',
769    classHide: 'hide'
770  }, config);
771
772  if (config.tabs == null || config.pages == null) {
773    return;
774  }
775
776  var ClassTab = function() {}
777  ClassTab.prototype = {
778    rollOver: function(select) {
779      config.tabs.unbind("mouseenter").unbind("mouseleave"); //img.unbind('hover');ではできない
780      config.tabs.removeClass(config.classHover);
781      config.tabs.each(function(idx) {
782        var tabJ = $(this);
783
784        if (select == idx) {
785          tabJ.addClass(config.classHover);
786        } else {
787          tabJ.hover(function() {
788            tabJ.addClass(config.classHover);
789          }, function() {
790            tabJ.removeClass(config.classHover);
791          });
792        }
793      });
794    },
795    showpage: function(select) {
796
797      config.pages.each(function(idx) {
798        if (idx == select) {
799          $(this).removeClass(config.classHide);
800        } else {
801          $(this).addClass(config.classHide);
802        }
803      });
804    },
805    init: function() {
806      var cls = this;
807
808      config.pages.each(function(idx) {
809        if (idx == config.defaultSelect) {
810          $(this).removeClass(config.classHide);
811        } else {
812          $(this).addClass(config.classHide);
813        }
814      });
815
816      config.tabs.click(function() {
817        var idx = config.tabs.index(this);
818        cls.rollOver(idx);
819        cls.showpage(idx);
820        // アクセシブル対応
821        ariaTab(config.tabs, config.pages, idx);
822        //選択されたタブの番号をクッキーに保存
823        $.cookie(config.cookie, idx, {path: '/', expires: 30 });
824        return false;
825      });
826
827      config.tabs.keydown(function(e) {
828        var type = 'keydown';
829        var $prev = $(this).prev('[role="tab"]');
830        var $next = $(this).next('[role="tab"]');
831        var $target;
832        switch (e.keyCode) {
833          case 37: //左矢印(←)
834            $target = $prev;
835            break;
836          case 39: //右矢印(→)
837            $target = $next;
838            break;
839          default:
840            $target = false;
841            break;
842        }
843        if ($target.length) {
844          var idx = config.tabs.index($target);
845          cls.rollOver(idx);
846          cls.showpage(idx);
847          // アクセシブル対応
848          ariaTab(config.tabs, config.pages, idx, type);
849          //選択されたタブの番号をクッキーに保存
850          $.cookie(config.cookie, idx, {path: '/', expires: 30 });
851          return false;
852        }
853      });
854
855      cls.rollOver(config.defaultSelect);
856      // アクセシブル対応
857      ariaTab(config.tabs, config.pages, config.defaultSelect);
858    }
859  };
860
861  // 前回選択タブ復元
862  if ($.cookie(config.cookie)) {
863    config.defaultSelect = $.cookie(config.cookie);
864  }
865  // タブ作成
866  var tab = new ClassTab();
867  tab.init();
868
869};
870
871
872// タブのアクセシビリティ対応
873function ariaTab(tabList, tabPanel, defaultSelect, actionType) {
874
875  // 切替タブへrole、aria-controls、aria-selectedの追加
876  var tabListParent = $(tabList).parent();
877  $(tabListParent).attr('role', 'tablist');
878  tabList.attr('role', 'tab');
879
880  tabList.each(function(idx) {
881    if ($('a', this).attr('href')) {
882      if (idx == defaultSelect) {
883        $(this).attr({
884          'aria-controls': $(this).find('a').attr('href').substr(1),
885          'aria-selected': 'true'
886        });
887        $('a',this).removeAttr('tabindex');
888        if( actionType == "keydown") {
889          $('a',this).focus();
890        }
891      } else {
892        $(this).attr({
893          'aria-controls': $(this).find('a').attr('href').substr(1),
894          'aria-selected': 'false'
895        });
896        $('a',this).attr('tabindex','-1');
897      }
898    }
899  });
900
901  // タブパネルのrole、aria-hiddenの追加
902  tabPanel.each(function(idx){
903    $(this).attr({"role":"tabpanel"});
904    if (idx == defaultSelect) {
905      $(this).attr("aria-hidden","false");
906    }
907    else{
908      $(this).attr("aria-hidden","true");
909    }
910  });
911}
912
913
914
915
916/**
917 * シーズンの画像差し替え
918 * //             1  2  3  4  5  6  7  8  9  10 11 12
919 * var seasons = [3, 3, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3];
920 * $('#headerGraphic').seasonClass({
921 *  seasons:seasons
922 * });
923 * ex.otsu
924 *
925 * @param object 設定
926 */
927$.fn.seasonClass = function(config) {
928  config = $.extend({
929    //        1  2  3  4  5  6  7  8  9  10 11 12
930    seasons: [3, 3, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3]
931    ,imgs: ['springCom', 'summerCom', 'autumnCom', 'winterCom']
932  },config);
933
934  // 季節の画像取得
935  var month = (new Date()).getMonth();
936  var seasonNum = config.seasons[month];
937  var newImg = config.imgs[seasonNum];
938
939  var targetsJ = this;
940
941  targetsJ.each(function() {
942    var targetJ = $(this);
943    targetJ.addClass(newImg);
944  });
945};
946
947/**
948 * アコーディオン
949 * $('.accordionMod > li').accordion({
950 *  classHead:'.title',
951 *  classBody:'.childs',
952 *  classToggle:'on'
953 * });
954 * ex.fujii sp
955 *
956 * @param object 設定
957 */
958$.fn.svAccordion = function(config) {
959  var targetsJ = this;
960
961  config = $.extend({
962    classHead: '.head',
963    classBody: '.body',
964    classToggle: 'minus'
965  },config);
966
967  var applyAccordion = function(targetJ) {
968
969    var headJ = targetJ.find(config.classHead);
970    var bodyJ = targetJ.find(config.classBody);
971
972    // 元々開いているかチェック
973    if(!headJ.hasClass(config.classToggle)) {
974      bodyJ.hide();
975    }
976
977    headJ.click(function() {
978      if(bodyJ.is(':animated')) {
979        return false;
980      }
981
982      bodyJ.slideToggle("normal",function(){
983        if(bodyJ.is(':visible')) {
984          headJ.addClass(config.classToggle);
985        } else {
986          headJ.removeClass(config.classToggle);
987        }
988      });
989
990      return false;
991    });
992  }
993
994  targetsJ.each(function(){
995    applyAccordion($(this));
996  });
997};
998
999/**
1000 * フェード スライダー
1001 * $('#slider').smartSlider2({
1002 *  slider: '.list',
1003 *  nav: '.navs',
1004 *  play: '.ichiji',
1005 *  playHTML: '<img width="21" height="20" alt="画像を開始する" src="/theme/base/img_pc_top/slider_play.png"/>',
1006 *  stopHTML: '<img width="21" height="20" alt="画像を停止する" src="/theme/base/img_pc_top/slider_ichiji.png"/>',
1007 *  interval: 8000,
1008 *  duration: 1000
1009 * });
1010 * ex.odai
1011 *
1012 * @param object 設定
1013 */
1014$.fn.fadeSlider = function (config) {
1015  var target = this;
1016  config = jQuery.extend({
1017    slider: null,
1018    nav: null,
1019    play: null,
1020    playHTML:'スライドする',
1021    stopHTML:'一時停止',
1022    interval:8000,
1023    duration:1000
1024  },config);
1025
1026  var sliderJ = target.find(config.slider);
1027  var sliderNum = 0;//slideしていく番号
1028  var sliderMax = sliderJ.find('li').size();
1029  var navJ = target.find(config.nav);
1030  var playJ = target.find(config.play);
1031
1032  // 自動切換え
1033  var autoPlayID;
1034  var autoPlay = function () {
1035    clearInterval(autoPlayID);
1036    autoPlayID = setInterval(function () {
1037      nextSlide();
1038    }, config.interval);
1039  };
1040  autoPlay();
1041
1042  // 自動切換え停止
1043  var autoStop = function () {
1044    clearInterval(autoPlayID);
1045  };
1046
1047  // 現在位置ナビ作成
1048  var createNav = function() {
1049    sliderJ.find('li').each(function() {
1050      navJ.append('<span />');
1051    });
1052    navJ.find('span').each(function() {
1053      var li = $(this);
1054      li.hover(function() {
1055        sliderNum = $(this).index();
1056        slide();
1057        autoStop();
1058      },
1059      function() {
1060        if(autoPlayState) {
1061          autoPlay();
1062        }
1063
1064
1065      });
1066    });
1067  };
1068  createNav();
1069
1070  // 一時停止
1071  var autoPlayState = true;
1072  var applyPlay = function() {
1073    if(autoPlayState) {
1074      playJ.html(config.stopHTML);
1075    } else {
1076      playJ.html(config.playHTML);
1077    }
1078  };
1079  var settingPlay = function() {
1080    playJ.click(function() {
1081      autoPlayState = !autoPlayState;
1082      if(autoPlayState) {
1083        autoPlay();
1084      } else {
1085        autoStop();
1086      }
1087      applyPlay();
1088    });
1089    applyPlay();
1090  };
1091  settingPlay();
1092
1093  // スライダ初期化
1094  var initSlide = function() {
1095    var liJ = sliderJ.find('li').eq(sliderNum);
1096    sliderJ.find('li:visible').hide();
1097    //sliderJ.find('li').eq(sliderNum).show();;
1098    navJ.find('span').eq(sliderNum).addClass('active');
1099    liJ.show();
1100
1101  };
1102  initSlide();
1103
1104  // 高さ適用
1105  var apllyImgH = function() {
1106    var liJ = sliderJ.find('li').eq(sliderNum);
1107    var ulJ = liJ.parent();
1108    ulJ.height(liJ.height());
1109  }
1110  apllyImgH();
1111
1112  // アクティブな画像にスライド
1113  var slide = function() {
1114    var liJ = sliderJ.find('li').eq(sliderNum);
1115    var ulJ = liJ.parent();
1116    ulJ.stop(true,true).animate({height:liJ.height()+'px'}, config.duration);
1117
1118    sliderJ.find('li:visible').stop(true,true).animate({ opacity: 'hide'}, config.duration);
1119    //sliderJ.find('li').eq(sliderNum).stop(true,true).animate({ opacity: 'show'}, config.duration);
1120    liJ.stop(true,true).animate({ opacity: 'show'}, config.duration);
1121
1122    navJ.find('span').removeClass('active');
1123    navJ.find('span').eq(sliderNum).addClass('active');
1124
1125  };
1126
1127  // 次のスライド画像へ
1128  var nextSlide = function() {
1129    //alert('test');
1130    sliderNum++;
1131    if(sliderNum >= sliderMax) {
1132      sliderNum = 0;
1133    }
1134    slide();
1135  };
1136}
1137
1138/**
1139 * フェード スライダー
1140 * $('#slider').simpleLoopSlider({autoSlide : true,interval : 8000,easing : 'easeInOutExpo',duration : 1500});
1141 * ex.honjo
1142 *
1143 * @param object 設定
1144 */
1145$.fn.slideSlider = function (options) {
1146  var self = $(this);
1147  var li = self.find("li");
1148  if(li.size() <= 1) {
1149    options.controller = false;
1150    options.pagination = false;
1151  }
1152
1153  var defaults = {
1154    controller: true,
1155    pagination: true,
1156    interval  : 3000,
1157    duration  : 300,
1158    easing    : 'linear'
1159  };
1160
1161  var o = $.extend(defaults, options);
1162
1163  var ichiji = false;
1164  var over = false;
1165
1166  this.each(function () {
1167
1168    var $slider   = $(this),
1169      $prev   = $slider.find('.slL'),
1170      $next   = $slider.find('.slR'),
1171      $view   = $slider.find('.box'),
1172      $container  = $view.find('.list'),
1173      $contents = $container.find('li'),
1174      $firstChild = $contents.filter(':first-child'),
1175      $lastChild  = $contents.filter(':last-child'),
1176      $stop   = $slider.find('.ichiji a');
1177
1178    var size = {
1179      width : $view.width(),
1180      height: $view.height()
1181    };
1182
1183    var count = {
1184      min  : 0,
1185      max  : $contents.length,
1186      current: 0
1187    };
1188
1189    $container.css({
1190      width    :  size.width * ($contents.length + 2)
1191    });
1192
1193    // slider
1194    var distance;
1195
1196    // 連打されたときにアニメーション終わりの補正が走らず次が走って表示がおかしくなる現象回避
1197    var apllyBefore = function() {
1198      if(count.current == 0) {
1199        $firstChild.css('left', 0);
1200        $container.css('left', 0);
1201      }
1202      if(count.current == (count.max -1)) {
1203          $lastChild.css('left', '');
1204          $container.css('left', -(size.width * ($contents.length - 1)));
1205      }
1206    };
1207
1208    var apply = function() {
1209      distance = size.width * count.current;
1210
1211      if((count.current >= count.min) && (count.current < count.max)) {
1212        $container.stop(true, false).animate({left: -distance}, o.duration, o.easing);
1213      }
1214      else {
1215        if(count.current < count.min) {
1216          $lastChild.css('left', -(size.width * $contents.length));
1217          $container.stop(true, false).animate({left: -distance}, o.duration, o.easing,function () {
1218            $lastChild.css('left', '');
1219            $container.css('left', -(size.width * ($contents.length - 1)));
1220          });
1221          count.current = count.max -1 ;
1222
1223        }
1224        else if(count.current >= count.max) {
1225          $firstChild.css('left', size.width * $contents.length);
1226          $container.stop(true, false).animate({left: -distance}, o.duration, o.easing,function () {
1227            $firstChild.css('left', 0);
1228            $container.css('left', 0);
1229          });
1230          count.current = 0;
1231        }
1232      }
1233
1234      $pagination.children('a').removeClass('current');
1235      $pagination.children('a:eq(' + count.current + ')').addClass('current');
1236    }
1237
1238    var next = function () {
1239      apllyBefore();
1240      count.current++;
1241      apply();
1242    };
1243
1244    var index = function (index) {
1245      apllyBefore();
1246      count.current = index;
1247      apply();
1248    };
1249
1250    var prev = function () {
1251      apllyBefore();
1252      count.current--;
1253      apply();
1254    };
1255
1256    var $pagination = $slider.find('.navs');
1257    $contents.each(function (i) {
1258      $('<a/>').attr('href', '#')
1259      .text(i + 1)
1260      .appendTo($pagination)
1261      .click(function (e) {
1262        e.preventDefault();
1263        index(i);
1264        ichiji = false;
1265        play();
1266        setItiji();
1267      });
1268    });
1269
1270    $pagination.find('a:first-child').addClass('current');
1271
1272    // 繰り返しをリセットしてスタート
1273    var timerID;
1274    var play = function () {
1275      clearInterval(timerID);
1276      timerID = setInterval(function () {
1277        if(ichiji) {
1278          return;
1279        }
1280        if(over) {
1281          return;
1282        }
1283        next();
1284      }, o.interval);
1285    };
1286
1287    $prev.click(function () {
1288      prev();
1289      ichiji = false;
1290      play();
1291      setItiji();
1292      return false;
1293    });
1294    $next.click(function () {
1295      next();
1296      ichiji = false;
1297      play();
1298      setItiji();
1299      return false;
1300    });
1301
1302    $stop.click(function () {
1303      if(ichiji) {
1304        ichiji = false;
1305        play();
1306        setItiji();
1307      }
1308      else {
1309        ichiji = true;
1310        setItiji2();
1311      }
1312      return false;
1313    });
1314
1315    var setItiji = function() {
1316      var img = $stop.find('img');
1317      var src = img.attr('src');
1318      src = src.replace('itiji2.', 'itiji.');
1319      img.attr('src', src);
1320    };
1321
1322    var setItiji2 = function() {
1323      var img = $stop.find('img');
1324      var src = img.attr('src');
1325      src = src.replace('itiji.', 'itiji2.');
1326      img.attr('src', src);
1327    };
1328
1329    $contents.hover(
1330      function () {
1331        over = true;
1332      },
1333      function () {
1334        over = false;
1335        play();
1336      }
1337    );
1338    play();
1339  });
1340};
1341
1342
1343
1344
1345/**
1346 * スマホ向けライトボックス
1347 *
1348 * @param object 設定
1349 */
1350$.fn.lightbox = function(config) {
1351  var targetJ = this;
1352
1353  config = $.extend({
1354    modalBg:null,
1355    modal:null,
1356    close:null,
1357    scrollID:'sWrapper',
1358    lightSpot:null
1359  },config);
1360
1361  if(config.modalBg == null || config.modal == null) {
1362    return;
1363  }
1364
1365  // 簡易スクロール
1366  var anchorScroll = function(id){
1367    var j = $( "#" + id);
1368    if(j.size() == 0) {
1369      return;
1370    }
1371    $('html,body').animate({scrollTop: j.offset().top}, 200, "linear");
1372  }
1373
1374
1375  var applyModal = function(targetJ) {
1376
1377
1378    var showModal = function() {
1379      var docH = $(document).height();
1380      config.modalBg.height(docH);
1381      config.modalBg.fadeIn(200);
1382      config.modal.fadeIn(200);
1383      config.lightSpot.css({'z-index': '99'});
1384    };
1385
1386    var hideModal = function() {
1387      config.modalBg.hide();
1388      config.modal.hide();
1389      anchorScroll(config.scrollID);
1390      config.lightSpot.css({'z-index': 'auto'});
1391    };
1392
1393
1394
1395    targetJ.click(function() {
1396      showModal();
1397      return false;
1398    });
1399    config.close.click(function() {
1400      hideModal();
1401      return false;
1402    });
1403    config.modalBg.click(function() {
1404      hideModal();
1405      return false;
1406    });
1407
1408
1409  }
1410
1411  applyModal(targetJ);
1412};
1413
1414/**
1415 * バナークリック数カウント
1416 * $('.kokokuMod .list a').bannerClick({
1417 *  title:'広告クリック数'
1418 * });
1419 *
1420 * @param object 設定
1421 */
1422$.fn.bannerClick = function(config_) {
1423  var targetJ = this;
1424
1425  config_ = $.extend({
1426    title:'広告クリック数'
1427  },config_);
1428
1429  targetJ.click(function(){
1430    //_gaq.push(['_trackEvent', config_.title, $(this).find("img").attr('alt'), $(this).attr('href')]);// old(旧)
1431    if(typeof ga == 'function'){
1432      ga('send', 'event', config_.title, 'click', $(this).find("img").attr('alt') + ':' + $(this).attr('href'));// new(ユニバーサル)
1433    }
1434  });
1435};
1436
1437/**
1438 * バナークリック数カウント(GA4用)
1439 * $('.kokokuMod .list a').bannerClick2({
1440 *  category:'広告クリック数'
1441 * });
1442 *
1443 * @param object 設定
1444 */
1445$.fn.bannerClick2 = function(config_) {
1446  var targetJ = this;
1447
1448  config_ = $.extend({
1449    action:'sv_banner_click',
1450    category:'広告クリック数',
1451    label:'',
1452    value: 1
1453  },config_);
1454
1455  targetJ.click(function(){
1456    //GA4用
1457    if(typeof gtag == 'function'){
1458      gtag('event', config_.action, {
1459        'event_category': config_.category,
1460        'event_label': $(this).find("img").attr('alt') + ':' + $(this).attr('href'),
1461        'value': config_.value
1462      });
1463    }
1464  });
1465};
1466
1467
1468
1469/**
1470 * snsボタン
1471 * $("body").snsConstraction();
1472 *
1473 */
1474
1475$.fn.snsConstraction = function() {
1476    //opacityはie9以降からさポートしているので
1477  if(jQuery.support.opacity){
1478    //IE8未満は出さない
1479    var socialJ = $('#social');
1480    // twitter
1481    var twitterJ = socialJ.find('#twitter');
1482
1483    if (twitterJ.size() > 0) {
1484      twitterJ.socialbutton('twitter', {
1485        button: 'horizontal'
1486      });
1487    }
1488
1489    // google
1490    var google_plusoneJ = socialJ.find('#google_plusone');
1491
1492    if (google_plusoneJ.size() > 0) {
1493      google_plusoneJ.socialbutton('google_plusone', {
1494        lang: 'ja',
1495        size: 'medium'
1496      });
1497    }
1498
1499    // facebook_like
1500    var facebook_likeJ = socialJ.find('#facebook_like');
1501
1502    if (facebook_likeJ.size() > 0) {
1503      facebook_likeJ.socialbutton('facebook_like', {
1504        button: 'button_count'
1505      });
1506    }
1507  }
1508};
1509
1510
1511
1512
1513
1514/**
1515 * イベントスライダー
1516 * $("body").snsConstraction();
1517 *
1518 */
1519$.fn.eventSlider = function() {
1520
1521//関連イベントスライダー(device width で枚数切り替え。)
1522
1523  (function(){
1524
1525    var sliderOption = function(){
1526
1527      //device width別に枚数を決める
1528      var windowWidth = $(window).innerWidth();
1529      var windowSm = 768;//ブレークポイント
1530      var optionArry;
1531
1532      //[maxSlidesとminSlides,slideMargin]
1533      if ($.browser.msie && $.browser.version < 9) {
1534        optionArry = [2,15];
1535      }else if(windowWidth <= windowSm){
1536        optionArry = [1,0];
1537      }else{
1538        optionArry = [2,15];
1539      }
1540      return optionArry;
1541    }
1542
1543    var optionValue = sliderOption();
1544
1545    //bxスライダー動かすときのオプション
1546    var sliderPageMove = {
1547      auto: true
1548      ,autoControls: true
1549      ,speed:1000
1550      ,pause:5000
1551      ,slideWidth: 638
1552      ,maxSlides: optionValue[0]
1553      ,minSlides: optionValue[0]
1554      ,slideMargin: optionValue[1]
1555      ,pager:false
1556      ,moveSlides:1
1557      ,responsive: true
1558    }
1559
1560    var sliderTarget =  $('#event-page-slider .bxslider .list,#slider-parts .bxslider .list');
1561    var slider1 = sliderTarget.bxSlider(sliderPageMove); 
1562
1563
1564    //リサイズしたら、device width別に枚数を決め直して、リロードする
1565    $(window).on('resize',function(e){
1566
1567      if(sliderTarget.length){
1568        e.preventDefault();
1569
1570        //スライダーが動いてないと、reloadSliderメソッドが使えないので、再びスライダーを実行。
1571        optionValue = sliderOption();
1572
1573        //bxスライダー動かすときのオプションを設定し直す
1574        sliderPageMove['maxSlides'] = optionValue[0];
1575        sliderPageMove['minSlides'] = optionValue[0];
1576        sliderPageMove['slideMargin'] = optionValue[1];
1577
1578        //リロード
1579        slider1.reloadSlider(sliderPageMove);
1580      }
1581
1582    });
1583
1584  })();
1585
1586
1587  (function(){
1588
1589    //イベント目次スライダー
1590    var sliderListMove = {
1591
1592      auto: true
1593      ,autoControls: true
1594      ,speed:1000
1595      ,pause:5000
1596      ,maxSlides: 1
1597      ,minSlides: 1
1598      ,pager:false
1599      ,moveSlides:1
1600      ,responsive: true
1601
1602    }
1603
1604    var slider2 = $('.event-pickup-area .bxslider .list').bxSlider(sliderListMove);  
1605    var slider3 = $('.event-today-area .bxslider .list').bxSlider(sliderListMove); 
1606
1607  })();
1608
1609}; 
1610
1611
1612/**
1613 * Jalert 取得表示
1614 * @param ...
1615 * @version 0.1
1616 * @return ... Returns {@ code}
1617 */
1618 $.fn.jAlertListView = function(config){
1619    config = $.extend({
1620      rssPath:'',
1621      historyPath:'',
1622      historyClass:'.more',
1623      listClass:'.list',
1624      limit:'5',
1625      type:'1',
1626      html:''
1627    },config);
1628
1629    $.ajax({
1630      url:config.rssPath,
1631      timeout: 10000,
1632      dataType: "json",
1633      context:this,
1634      success:function(json){
1635      if(json.success) {
1636        //取得成功
1637
1638        //デフォルトのJalert
1639        var defalt_html = '<div class="jalert-area"><dl><dt class="title"><span class="bg"><span class="bg2">J-ALERT(全国瞬時警報システム)</span></span></dt><dd class="in"><ul class="list"></ul><p class="more"></p></dd></dl></div>';
1640
1641        //xml配列を変数に格納
1642        var itemList = json.data; 
1643        //発布されていなければなにもしない
1644        if(itemList.length == 0){
1645          return;
1646        }
1647
1648        //カスタムされたJalertHTMLを確認
1649          var $parentBox = $(this);
1650          var $jAlertBox = function(){
1651              //htmlが無ければデフォルト出す
1652              var $jalert_html = $(defalt_html);
1653              if(config.html==''){
1654                return $jalert_html;
1655              }else{
1656                return config.html;
1657              }
1658          };
1659          //JAlertのボックス生成
1660          $parentBox.append($jAlertBox);
1661          //履歴リンク設置
1662          var $historyLink = $($parentBox).find(config.historyClass);
1663          var $historyA = $('<a href="#">過去の配信履歴を見る</a>')
1664          $historyA.attr('href',config.historyPath);
1665          $historyLink.append($historyA);
1666
1667          //発布されたJAlertリストの格納ボックスを定義
1668         var $jalertListBox = $($parentBox).find(config.listClass);
1669
1670          //xmlデータをまわす
1671          $(itemList).each(function(idx){
1672
1673
1674              if(config.limit!='0'){
1675                if(idx >= config.limit){
1676                  return false;//break
1677                }
1678              }
1679
1680              var jalertTitle = this.title;
1681              var jalertLink = this.link;
1682              var jalertDate = this.pubDate;
1683              var date = new Date(jalertDate);
1684              var dateText = '(配信日:' + date.getFullYear() + '年' + (date.getMonth() + 1) + '月' + date.getDate() + '日)';
1685              //リスト生成
1686              var $li = $('<li><a href="#"></a></li>');
1687              //リンク生成
1688              var $liA = $li.find('a');
1689              $liA.attr('href', jalertLink);
1690              $liA.html(jalertTitle + dateText);
1691              $jalertListBox.append($li);
1692
1693          });
1694           }
1695        }
1696      });};
1697
1698
1699/**
1700 * SmartAlert
1701 * @param ...
1702 * @return ... Returns {@ code}
1703*/
1704$.fn.smartAlertListView = function(config){
1705
1706  // 初期値
1707  config = $.extend({
1708    rssPath: site_domain + '/cgi-bin/smart_alert.php/1',
1709    historyPath: site_domain + '/cgi-bin/smart_alert.php/1/list',
1710    historyClass: '.more',
1711    ulClass: '.list',
1712    textClass: '.text',
1713    dateClass: '.date',
1714    limit: 3,
1715    dateformat: 'YYYY年MM月DD日(WW) hh時mm分ss秒',
1716    noDataView: 1,
1717  },config);
1718
1719  // パラメーターのエラー判定
1720  var errorMsg = '';
1721  for(key in config) {
1722    var value = config[key];
1723    // 空文字の判定
1724    if(value === '') {
1725      errorMsg += 'エラー:' + key + 'に空文字が入っています\n';
1726    } else {
1727      // 数値かどうかの判定
1728      if(key === 'limit' || key === 'noDataView') {
1729        if($.type(value) !== 'number'){
1730          errorMsg += 'エラー:' + key + 'に文字列が入っています\n';
1731        }
1732      // 文字列かどうかの判定
1733      } else {
1734        if($.type(value) !== 'string') {
1735          errorMsg += 'エラー:' + key + 'に数値が入っています\n';
1736        }
1737      }
1738    }
1739  }
1740  // エラーあれば実行しない
1741  if(errorMsg) {
1742    console.error(errorMsg);
1743  // エラーなければ実行
1744  } else {
1745    $.ajax({
1746      url:config.rssPath,
1747      timeout: 10000,
1748      dataType: 'json',
1749      context:this,
1750      success:function(json){
1751        var itemList = json.data; //xml配列を変数に格納
1752        var $parentBox = this; //表示エリアを選択
1753        var $smartAlertUlBox = $parentBox.find(config.ulClass); //ulタグを選択
1754        var $li = $smartAlertUlBox.find('li:first'); //liタグを選択
1755        var litags = '';
1756        // --------------------------------------------
1757        //アラートがあれば
1758        if(itemList.length){
1759          //一覧ページへのリンク先設定
1760          $($parentBox).find(config.historyClass + ' a').attr('href', config.historyPath);
1761          //xmlデータをまわす
1762          $(itemList).each(function(idx){
1763            if(idx >= config.limit){
1764              return false;
1765            }
1766            //アラート内容の作成
1767            var smartAlertTitle = this.title;
1768            var smartAlertLink = this.link;
1769            //アラート日付の作成
1770            var date = new Date(this.pubDate);
1771            var weekday = ['日', '月', '火', '水', '木', '金', '土'];
1772            var dateText = config.dateformat;
1773            dateText = dateText.replace(/YYYY/, date.getFullYear());
1774            dateText = dateText.replace(/MM/, ('0' + (date.getMonth() + 1)).slice(-2));
1775            dateText = dateText.replace(/DD/, ('0' + date.getDate()).slice(-2));
1776            dateText = dateText.replace(/WW/, weekday[date.getDay()]);
1777            dateText = dateText.replace(/hh/, ('0' + date.getHours()).slice(-2));
1778            dateText = dateText.replace(/mm/, ('0' + date.getMinutes()).slice(-2));
1779            dateText = dateText.replace(/ss/, ('0' + date.getSeconds()).slice(-2));
1780            dateText = dateText.replace(/M/, date.getMonth() + 1);
1781            dateText = dateText.replace(/D/, date.getDate());
1782            dateText = dateText.replace(/h/, date.getHours());
1783            dateText = dateText.replace(/m/, date.getMinutes());
1784            dateText = dateText.replace(/s/, date.getSeconds());
1785            //リンクの挿入
1786            if($li.find('a').length) {
1787              $li.find('a').attr('href', smartAlertLink);
1788            }
1789            //アラート内容の挿入
1790            if($li.find(config.textClass).length) {
1791              $li.find(config.textClass).text(smartAlertTitle);
1792            }
1793            //アラート日付の挿入
1794            if($li.find(config.dateClass).length) {
1795              $li.find(config.dateClass).text(dateText);
1796            }
1797            litags += $li.prop('outerHTML');
1798          });
1799          //追加
1800          $smartAlertUlBox.html(litags);
1801          // エリアの表示
1802          $parentBox.css('display', 'block');
1803
1804        // --------------------------------------------
1805        //アラートがなければ
1806        // --------------------------------------------
1807        } else {
1808          if(config.noDataView) {
1809            $parentBox.css('display', 'block');
1810            $li = config.noDataClass ? $(config.noDataClass) : '<li>データがありません</li>';
1811            $smartAlertUlBox.html($li);
1812            $parentBox.find(config.historyClass).remove(); //一覧ページへのボタンを削除
1813          } else {
1814            $parentBox.remove(); //エリアごと削除
1815          }
1816        }
1817      }
1818    });
1819  }
1820  return this;
1821};
1822
1823
1824
1825 /**
1826 * ajax通信
1827 * url: ajax通信するURL
1828 * param: パラメータ(オブジェクトで指定)
1829 * successHandler: 成功ハンドラ
1830 * errorHandler: 失敗ハンドラ
1831 * completeHandler: 完了ハンドラ
1832 * contextObj: コールバック関数のthisとして受け取る
1833 **/
1834function ajax(url, param, successHandler, errorHandler, completeHandler, contextObj) {
1835    $.ajax({
1836        type: 'get',
1837        url: url,
1838        data: param,
1839        dataType: 'json',
1840        context:contextObj,
1841        success: function(data) {
1842            if(successHandler != undefined && successHandler != null) {
1843                successHandler(data);
1844            }
1845        },
1846        error: function(data) {
1847            if(errorHandler != undefined && errorHandler != null) {
1848                errorHandler(data);
1849            }
1850        },
1851        complete: function(data) {
1852            if(completeHandler != undefined && completeHandler != null) {
1853                completeHandler(data);
1854            }
1855        }
1856    });
1857}
1858
1859/**
1860 * GoogleAnalyticsページランキング(GA4対応済)
1861 * @version 1.1
1862 * @param num viewNo,num limit,string element
1863 */
1864
1865$.fn.gaRanking = function(config){
1866
1867  config = $.extend({
1868    titleName:"よく見られるページ",
1869    profileNo: "",
1870    limit:5,
1871    printError:"",
1872    replaceStr:""
1873  },config);
1874
1875  var target = this;
1876
1877  var errorMessageTarget;
1878  if(config.printError !=""){
1879    errorMessageTarget = $(config.printError);
1880  }else{
1881    errorMessageTarget = $(this).find('.in');
1882  }
1883
1884  var hostName;
1885  if(site_domain.length > 0){
1886    hostName=site_domain;
1887  }else{
1888    hostName='http://'+location.hostname;
1889  }
1890
1891  if(config.profileNo != ""){
1892    //プロファイルNoが指定されていなければ動かさない
1893    var JSON_PATH = hostName + '/ga_ranking.' + config.profileNo + '.json';
1894
1895      //Ajax通信開始
1896      ajax(JSON_PATH,{},function(entry){
1897
1898      var $ul = $(target).find('.list');
1899      $ul.html('');
1900
1901      if(entry.success){
1902
1903        if(entry.data.length > 0){
1904
1905          for(var i in entry.data){
1906
1907            if(config.limit!=0){
1908              if(i >= config.limit) {
1909                return false;// break
1910              }
1911            }
1912
1913            var gaList = entry.data[i];
1914            var keyArray = Object.keys(gaList);
1915            var gaUrl,gaTitle;
1916
1917            if (keyArray[0]==="screenPageViews"){
1918              // GA4用
1919              gaUrl = entry.data[i]['pagePath'];
1920              gaTitle = entry.data[i]['pageTitle'];
1921            } else {
1922              // UA用
1923              gaUrl = entry.data[i]['ga:pagePath'];
1924              gaTitle = entry.data[i]['ga:pageTitle'];
1925            }
1926
1927            //削除したい文言があれば削除
1928            if(config.replaceStr!=""){
1929              gaTitle = gaTitle.replace(new RegExp(config.replaceStr,'g'),"");
1930            }
1931
1932            //DOMを生成して内容を出力
1933            var $li = $('<li><a href="#"></a></li>');
1934            $liA = $li.find('a');
1935            $liA.attr('href',gaUrl);
1936            $liA.html(gaTitle);
1937            $ul.append($li);
1938
1939          }
1940        }else{
1941          //取得件数0
1942          showErrorMessage(errorMessageTarget, '<p>現在、' + config.titleName + 'はございません</p>');
1943        }
1944
1945      }else{
1946        //取得失敗
1947        showErrorMessage(errorMessageTarget, '<p>'+ config.titleName + 'を取得できませんでした。<br>再読み込みしてください。</p>');
1948      }
1949
1950    },function(error){
1951      //通信失敗
1952      showErrorMessage(errorMessageTarget, '<p>' + config.titleName + 'を取得できませんでした。<br>再読み込みしてください。</p>');
1953    },function(success){},target);
1954
1955
1956  }
1957
1958};
1959
1960
1961// エラーメッセージ表示関数
1962function showErrorMessage(target, message){
1963    $(target).hide();
1964    $(target).html(message);
1965    $(target).show();
1966}
1967
1968// jqueryプラグインの存在チェック
1969function pluginExists( pluginName ){
1970     return [pluginName] || $.fn[pluginName] ? true : false;
1971}

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.