PageSourceSearch

https://www.city.nasushiobara.tochigi.jp/theme/base/js/common_lib.js

js city.nasushiobara.tochigi.jp collected 2026-10-02 05:48:40 UTC 53,267 bytes, 1,996 lines download raw bytes

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

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.