PageSourceSearch

https://primo-color.jp/wp-content/themes/SumahoDeHoken/js/column.js?ver=1.0.8

js primo-color.jp collected 2026-10-04 03:33:45 UTC 6,416 bytes, 169 lines download raw bytes

1$(document).ready(function() {
2    function updateInsuranceValues(changedSelect) {
3        var selectedValue = $(changedSelect).val();
4        var selectedText = $(changedSelect).find('option:selected').text().trim();
5
6        // selectedValue または selectedText が空の場合、最初の select.insurance から取得
7        if (!selectedValue || !selectedText) {
8            var firstSelect = $('select.insurance').first();
9            selectedValue = selectedValue || firstSelect.val();
10            selectedText = selectedText || firstSelect.find('option:selected').text().trim();
11        }
12
13        // すべての select.insurance の値を統一
14        //$('select.insurance').val(selectedValue);
15
16        // すべての .button .category のテキストを更新(重複防止のためクリア)
17        //$('.button .category').text(selectedText);
18
19        // すべての .simulation-form の action を更新
20        $('.simulation-form').each(function() {
21            var form = $(this);
22            var action = form.attr('action');
23            var newAction = action.replace(/\/cat\/[^\/]+/, '/cat/' + selectedValue);
24            form.attr('action', newAction);
25        });
26    }
27
28    // 目次用のCookieの設定関数 (1日有効)
29    function setCookie(name, value, days) {
30        let date = new Date();
31        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
32        document.cookie = name + "=" + encodeURIComponent(value) + "; expires=" + date.toUTCString() + "; path=/";
33        console.log(getCookie("tocOpen"));
34    }
35
36    console.log(getCookie("tocOpen"));
37
38    // 目次を作成
39    var isOpen = getCookie("tocOpen") === "true";
40    var toc = $('<div class="toc"><h2>この記事の目次</h2><ul></ul></div>').toggleClass('open', isOpen);
41    var tocList = toc.find('ul');
42    var index = 0;
43
44    $('.entry-content h2, .entry-content h3').each(function () {
45        var heading = $(this);
46
47        // 特定クラスを持つ見出しは目次に加えない
48        if (heading.hasClass('category-headline') || heading.hasClass('simulation-headline')) {
49            return;
50        }
51
52        var tagName = heading.prop('tagName').toLowerCase();
53
54        // 既存のIDがあればそれを使い、なければ新しいIDを付与
55        var id = heading.attr('id');
56        if (!id) {
57            id = 'heading-' + index++;
58            heading.attr('id', id);
59        }
60
61        var listItem = $('<li></li>').addClass(tagName);
62        var link = $('<a></a>').attr('href', '#' + id).text(heading.text());
63        listItem.append(link);
64        tocList.append(listItem);
65    });
66
67    var toggleButton = $('<button class="toc-toggle"></button>').text(isOpen ? '目次を閉じる' : '目次を開く');
68    toc.append(toggleButton);
69
70    $(document).on('click', '.toc-toggle', function() {
71        $(".toc").toggleClass("open");
72        var isOpen = $(".toc").hasClass("open");
73        toggleButton.text(isOpen ? '目次を閉じる' : '目次を開く');
74        setCookie("tocOpen", isOpen ? "true" : "false", 1); // 1日保持
75    });
76
77    $('#toc-wrap').append(toc);
78    tocList.removeClass('hidden'); // 初期状態で目次を開いた状態にする
79
80    // 初期ロード時に更新
81    updateInsuranceValues();
82
83    // .insuranceが変更された時に更新
84    $('select.insurance').change(function() {
85        updateInsuranceValues(this); // イベントが発生した select のみを渡す
86    });
87
88    $(".profile.accordion").click(function(){
89        $(this).toggleClass("active");
90        $(this).find(".qualification").slideToggle();
91    });
92
93    $('.tab').on('click', function() {
94        $('.tab').removeClass('active'); // すべてのタブのアクティブクラスを削除
95        $(this).addClass('active'); // クリックしたタブにアクティブクラスを追加
96
97        if ($(this).hasClass('tab-supervision')) {
98            $('.supervision').show();
99            $('.editor').hide();
100        } else if ($(this).hasClass('tab-editor')) {
101            $('.editor').show();
102            $('.supervision').hide();
103        }
104    });
105
106    // 初期状態を設定(監修者を表示、執筆者を非表示)
107    $('.supervision').show();
108    $('.editor').hide();
109    $('.tab-supervision').addClass('active');
110
111    // 料金シュミレーター設定
112    $('.fee-simulation').each(function(index) {
113        var $form = $(this);
114
115        // ラジオボタンとラベルのIDをユニークに変更
116        var manId = 'man_' + index;
117        var womanId = 'woman_' + index;
118
119        $form.find('input[name="sex"][value="man"]').attr('id', manId);
120        $form.find('label[for="man"]').attr('for', manId);
121
122        $form.find('input[name="sex"][value="woman"]').attr('id', womanId
122);
123        $form.find('label[for="woman"]').attr('for', womanId);
124    });
125
126    // ラジオボタンの値変更時にすべてのフォームの値を統一
127    $('input[name="sex"]').on('change', function() {
128        var selectedValue = $(this).val();
129        $('.fee-simulation').each(function() {
130            $(this).find('input[name="sex"][value="' + selectedValue + '"]').prop('checked', true);
131        });
132    });
133
134    // 年齢選択の変更時にすべてのフォームの値を統一
135    $('select[name="age"]').on('change', function() {
136        var selectedAge = $(this).val();
137        $('.fee-simulation select[name="age"]').val(selectedAge);
138    });
139
140    //下部ランキングに詳細情報の開閉機能を追加
141    $(".explanation-link").click(function() {
142        $(this).toggleClass("open");
143        $(this).next(".explanation").toggleClass("open");
144    });
145
146    const tabs = document.querySelectorAll('.profile-tab .img');
147    const contents = document.querySelectorAll('.profile-content');
148
149    tabs.forEach(tab => {
150        tab.addEventListener('click', function () {
151
152          const tabValue = this.getAttribute('data-tab');
153
154          // --- タブ側のactive制御 ---
155          tabs.forEach(t => t.classList.remove('active'));
156          this.classList.add('active');
157
158          // --- コンテンツ側のactive制御 ---
159          contents.forEach(content => {
160            if (content.getAttribute('data-tab-content') === tabValue) {
161              content.classList.add('active');
162            } else {
163              content.classList.remove('active');
164            }
165          });
166
167        });
168    });
169});

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.