PageSourceSearch

https://www.someplace-else.com/wp-content/themes/emanon-pro/assets/js/cta.js?ver=4.1.1

js someplace-else.com collected 2026-10-04 22:40:16 UTC 6,355 bytes, 183 lines download raw bytes

1(function ($) {
2
3    /**
4     * 指定されたDOM要素のクラスに基づいてcta_indexの値を返します。
5     *
6     * @param {Object} element - 調査するDOM要素。
7     * @return {string} cta_index - 要素のクラスに基づいて決定されるcta_indexの値。
8     */
9    function getCtaIndex(element) {
10        var cta_index;
11
12        if ($(element).hasClass('cta-index-common')) {
13            cta_index = 'common';
14        } else if ($(element).hasClass('cta-index-potential')) {
15            cta_index = 'potential';
16        } else if ($(element).hasClass('cta-index-eventually')) {
17            cta_index = 'eventually';
18        } else if ($(element).hasClass('cta-index-compare')) {
19            cta_index = 'compare';
20        } else if ($(element).hasClass('cta-index-prospect')) {
21            cta_index = 'prospect';
22        } else if ($(element).hasClass('cta-index-page_ab_test')) {
23            cta_index = 'pageABtest';
24        } else if ($(element).hasClass('cta-index-floating1')) {
25            cta_index = 'floating1';
26        } else if ($(element).hasClass('cta-index-floating2')) {
27            cta_index = 'floating2';
28        } else if ($(element).hasClass('cta-index-popup')) {
29            cta_index = 'popup';
30        }
31        return cta_index;
32    }
33
34    // CTA 表示回数
35    $('[id^="js-cta-inview-"]').on('inview', function (event, isinview) {
36
37        var cta_index = getCtaIndex(this);
38
39        if (isinview) {
40            $.ajax({
41                type: 'post',
42                url: emanonCTA.admin_url,
43                data: {
44                    'action': 'emanon_cta_impression',
45                    'security': emanonCTA.ajax_nonce,
46                    'cta_index': cta_index
47                },
48                success: function (response) {
49                    // 成功時の処理
50                },
51                error: function () {
52                    // エラー時の処理
53                },
54                complete: function () {
55                    // 完了時の処理
56                }
57            });
58        } else {
59            // ビューポート外に表示された場合の処理
60            $('[id^="js-cta-inview-"]').off('inview');
61        }
62    });
63
64    // CTA クリック数
65    $('[id^="js-cta-inview-"]').click(function () {
66
67        var cta_index = getCtaIndex(this);
68
69        $.ajax({
70            type: 'post',
71            url: emanonCTA.admin_url,
72            data: {
73                'action': 'emanon_cta_click',
74                'security': emanonCTA.ajax_nonce,
75                'cta_index': cta_index
76            },
77            success: function (response) {
78                // 成功時の処理
79            },
80            error: function () {
81                // エラー時の処理
82            },
83            complete: function () {
84                // 完了時の処理
85            }
86        });
87    });
88
89    /**
90     * 指定されたDOM要素のクラスに基づいてcta_cvの値を返します。
91     *
92     * @param {Object} element - 調査するDOM要素。
93     * @return {string} cta_cv - 要素のクラスに基づいて決定されるcta_cvの値。
94     */
95    function getCtaCV(element) {
96        var cta_cv;
97
98        if ($(element).hasClass('cta-cv-common')) {
99            cta_cv = 'common';
100        } else if ($(element).hasClass('cta-cv-potential')) {
101            cta_cv = 'potential';
102        } else if ($(element).hasClass('cta-cv-eventually')) {
103            cta_cv = 'eventually';
104        } else if ($(element).hasClass('cta-cv-compare')) {
105            cta_cv = 'compare';
106        } else if ($(element).hasClass('cta-cv-prospect')) {
107            cta_cv = 'prospect';
108        } else if ($(element).hasClass('cta-cv-page_ab_test')) {
109            cta_cv = 'pageABtest';
110        } else if ($(element).hasClass('cta-cv-floating1')) {
111            cta_cv = 'floating1';
112        } else if ($(element).hasClass('cta-cv-floating2')) {
113            cta_cv = 'floating2';
114        } else if ($(element).hasClass('cta-cv-popup')) {
115            cta_cv = 'popup';
116        }
117        return cta_cv;
118    }
119
120    // CTA コンバージョン
121    $('#js-cta-cv').on('inview', function (event, isinview) {
122
123        var cta_cv = getCtaCV(this);
124
125        if (isinview) {
126            $.ajax({
127                type: 'post',
128                url: emanonCTA.admin_url,
129                data: {
130                    'action': 'emanon_cta_cv',
131                    'security': emanonCTA.ajax_nonce,
132                    'cta_index': cta_cv
133                },
134                success: function (response) {
135                    // 成功時の処理
136                },
137                error: function () {
138                    // エラー時の処理
139                },
140                complete: function () {
141                    // 完了時の処理
142                }
143            });
144            // inview をオフにする
145            $('#js-cta-cv').off('inview');
146        }
147    });
148
149    // リセット
150    $('.js-cta-reset').click(function (event) {
151        var table = $(this).parents('#js-cta-table');
152        event.preventDefault();
153
154        if (window.confirm(emanonCTA.confirm_text)) {
155            var cta_index = $(this).data('cta-index');
156            var cta_row = $(this).data('cta-row');
157
158            $.ajax({
159                type: 'post',
160                url: emanonCTA.admin_url,
161                data: {
162                    'action': 'emanon_cta_reset',
163                    'security': emanonCTA.ajax_nonce,
164                    'cta_index': cta_index
165                },
166                success: function (response) {
167                    var ctaTableRow = table.find('.cta-table__row').eq(cta_row);
168                    var metrics = ['impression', 'click', 'ctr', 'cv', 'cvr'];
169
170                    // ループを使用して、各メトリクスの値をリセット
171                    $.each(metrics, function (index, metric) {
172                        var value = metric === 'ctr' || metric === 'cvr' ? '0.0%' : '0';
173                        ctaTableRow.find('.cta-table__' + metric).text(value);
174                    });
175                },
176                error: function () {
177                    alert('データの初期化に失敗しました。再度お試しください。');
178                }
179            });
180        }
181    });
182
183})(window.jQuery);

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.