PageSourceSearch

https://p-ch.jp/wp-content/themes/pch/resources/js/index.js?ver=20180631

js p-ch.jp collected 2026-10-02 07:39:31 UTC 12,997 bytes, 360 lines download raw bytes

1(function ($) {
2    var $window = $(window),
3        $toTop = $('a.page-top-btn'),
4        windowWidth = $window.width();
5    var homeUrl =  $('#home_url').val();
6
7    $.ajax({
8        // url: homeUrl + 'get_main_visual.php',
9        url: '/wp-content/main_visual.json',
10        dataType: 'json',
11        success: function (data) {
12            var cls = 'slide ',
13                $topVisual = $('.top-visual'),
14                $topVisualHeight = $('.top-visual-height'),
15                $topTwitter = $('.top-calendar'),
16                $topBnr = $('.top-bnr'),
17                html = html = ['<a href="' + data[0].url + '" class="' + cls + '">'];
18
19            if (data[0].bg) {
20                $('body').css('background', data[0].bg);
21            }
22            const mediaQuery = window.matchMedia('(max-width: 640px)')
23
24            if (data[0].pc_main_visual) {
25                var path = data[0].pc_main_visual;
26
27                var element = new Image() ;
28                element.src = path ;
29
30                element.onload = function () {
31                    var width = element.naturalWidth ;
32                    var height = element.naturalHeight ;
33
34                    // var margin = (width - 1024) / 2;
35                    // if (margin > 0) {
36                    //     $('.main-visual-pc').css('margin-left', -margin);
37                    // }
38
39                    // if (!mediaQuery.matches && data[0].display_all) {
40                    //     $topVisual.css('margin-top', 15);
41                    //     $topTwitter.css('margin-top', height - 20);
42                    //
43                    //     if(!$topTwitter.length){
44                    //         $('.content-background').css('margin-top', height - 650);
45                    //         $topVisual.css('margin-top', 30);
46                    //         $topVisual.css('margin-left', 112);
47                    //         $topVisual.css('width', 800);
48                    //     }
49                    // }
50                };
51
52                html.push('<img src="' + data[0].pc_main_visual + '" class="main-visual-pc v-pc" width="100%">');
53            }
54
55            if (data[0].sp_main_visual) {
56                if (mediaQuery.matches && data[0].display_all) {
57                    var element = new Image();
58                    element.src = data[0].sp_main_visual;
59
60                    element.onload = function() {
61                        var height = element.naturalHeight;
62                        $topVisual.css('margin-top', 50);
63                        $topTwitter.css('margin-top', height + 30);
64
65                        if(!$topTwitter.length){
66                            $topVisual.css('margin-top', 10);
67                            $('.content-background').css('margin-top', height - 460);
68                        }
69                    };
70                }
71                html.push('<img src="' + data[0].sp_main_visual + '" class="v-sp" width="100%">');
72            }
73
74            html.push('</a>');
75
76            $topVisual.html(html.join(''));
77            $topVisualHeight.html(html.join(''));
78            if (data[0].youtube_live_url) {
79                var ytWrapper = document.createElement('div');
80                var $tvContainer = $('.tv-container');
81                ytWrapper.className = 'youtube-wrapper';
82                html = ['<div class="youtube-bg"></div>'];
83
84                $tvContainer.addClass('live');
85                if (data[0].live_flg && data[0].url) {
86                    $tvContainer.addClass('disp-yt-btn');
87                }
88
89                if (data[0].youtube_text) {
90                    $tvContainer.addClass('disp-yt-text');
91                }
92
93                $('.content-background').css('margin-top', '0');
94
95                if (data[0].live_flg) {
96                    html.push('<div class="live-logo"></div>');
97                }
98
99                html.push('<p class="youtube-title" data-row-cnt="1">' + data[0].youtube_title + '</p>');
100                if (data[0].live_flg && data[0].url) {
101                    html.push('<a href="' + data[0].url + '" target="_blank" class="youtube-btn v-pc">番組の視聴ページへ</a>');
102                }
103
104                if (data[0].youtube_live_url) {
105                    html.push(data[0].youtube_live_url);
106                }
107
108                if (data[0].youtube_text) {
109                    html.push('<div class="youtube-text">' + data[0].youtube_text + '</div>');
110                }
111
112                if (data[0].live_flg && data[0].url) {
113                    html.push('<a href="' + data[0].url + '" target="_blank" class="youtube-btn v-sp">番組の視聴ページへ</a>');
114                }
115
116                ytWrapper.innerHTML = html.join('');
117                $topVisual.append(ytWrapper);
118            }
119        }
120    });
121
122    //totopの表示
123    $(window).on('load scroll', function () {
124        var s = $(this).scrollTop(),
125            m = 300;
126        if (s > m) {
127            $toTop.fadeIn('slow');
128        } else if (s < m) {
129            $toTop.fadeOut('fast');
130            //return false;
131        }
132    });
133
134    // footer付近までスクロールしたら定位置に固定
135    $('footer').waypoint({
136        handler: setAbsToTop,
137        offset: '100%',
138    });
139
140    function setAbsToTop(direction) {
141        if (direction == 'down') {
142            $toTop.addClass('absolute');
143        } else {
144            $toTop.removeClass('absolute');
145        }
146    }
147
148    // 画面内リンクをスクロールして表示させる
149    $('.page-top-btn').click(function () {
150        var speed = 400;
151        var href = $(this).attr('href');
152        var target = $(href == '#' || href == '' ? 'html' : href);
153        if (target.length > 0) {
154            var position = target.offset().top;
155            $('body,html').animate({scrollTop: position}, speed, 'swing');
156            return false;
157        }
158    });
159
160    // // SP版メニューの開閉
161    $('.header-btn-menu').click(function () {
162        var speed = 250;
163
164        if ($(this).hasClass('opened')) {
165            $('.header-btn-menu').removeClass('opened').animate({
166                'right': 0
167            }, speed);
168            $('.header-menu.v-sp').show().animate({
169                'right': '-338px'
170            }, speed);
171
172        } else {
173            $('.header-btn-menu').addClass('opened').animate({
174                'right': '338px'
175            }, speed);
176            $('.header-menu.v-sp').show().animate({
177                'right': 0
178            }, speed);
179        }
180        return false;
181    });
182
183    // ニュース詳細上部ゲームタイトルの文字サイズ自動調整
184    var $headerGameTitle = $(".single-news .title-box .title-name");
185    if ($headerGameTitle.length > 0) {
186        var maxFont = 20;
187        if (windowWidth <= 640) {
188            maxFont = 26;
189        }
190        $headerGameTitle.flowtype({
191            maxFont:  maxFont,
192            fontRatio:  $headerGameTitle.text().length + 1
193        });
194    }
195
196    var $pickupList = $('.secondary').find('.pickup-list');
197    if ($pickupList.length > 0) {
198        $.ajax({
199            url: '/wp-content/pickup.json',
200            dataType: 'json',
201            success: function (data) {
202                var items = data.items,
203                    pcHtml = [],
204                    spHtml = [],
205                    item, spHtmlItem;
206
207                for (var i = 0, length = items.length; i < length; i++) {
208                    item = items[i];
209                    spHtmlItem = [];
210                    pcHtml.push([
211                        '<li>',
212                        '<a href="' + item.url + '" target="_blank" title="' + item.title + '" class="hover-border-efct">',
213                        '<img src="' + item.image + '" alt="' + item.title + '">',
214                        '</a>',
215                        '</li>'
216                    ].join(''));
217                    pcHtml.push(spHtmlItem.join(''));
218                }
219
220                $pickupList.html(pcHtml.join('')); // PC
221
222                if ($(window).width() <= 640) {
223                    initSlick();
224                }
225            }
226        })
227    }
228
229    var $topicList = $('.secondary').find('.topics-list');
230    if ($topicList.length > 0) {
231        $.ajax({
232            url: '/wp-content/latest_news.json',
233            dataType: 'json',
234            success: function (data) {
235                var items = data.items,
236                    pcHtml = [],
237                    spHtml = [],
238                    item, spHtmlItem;
239
240                for (var i = 0, length = items.length; i < length; i++) {
241                    item = items[i];
242                    spHtmlItem = [];
243                    pcHtml.push([
244                        '<li class="title-' + item.title_id + '-bg">',
245                            '<a href="' + item.url.permalink + '" target="' + item.url.target + '" class="hover-border-efct">',
246                                '<div class="lineup-title-box v-sp">',
247                                '<p class="lineup-title"  data-row-cnt="2">' + item.game_title + '</p>',
248                                '</div>',
249                                '<img src="' + item.eye_catch.url + '">',
250                                '<div class="tag">' + item.category + '</div>',
251                                '</div>',
252                                '<div class="lineup-post-box">',
253                                    '<p class="post-date">' + item.published + '</p>',
254                                    '<p class="post-title" data-row-cnt="2">' + item.title + '</p>',
255                                '</div>',
256                            '</a>',
257                        '</li>'
258                    ].join(''));
259                }
260
261                $topicList.html(pcHtml.join('')); // PC
262                ellipsisMultiline($('[data-row-cnt]'));
263            }
264        })
265    }
266
267    // ニュースフィードを省略して末尾に…を付ける処理
268    function ellipsisMultiline($ellipsisTarget) {
269        $ellipsisTarget.each(function(index, element) {
270            var $target = $(element),
271                html = $target.html(),
272                rowCnt = $(element).data('row-cnt');
273            // font size * line height * line count
274            var fontSize = parseFloat( $target.css('font-size') );
275            var lineHeight = parseFloat( $target.css('line-height') );
276            var targetHeight = Math.ceil(fontSize * lineHeight * rowCnt);
277            if ($target.css('line-height').match(/px/)) {
278                targetHeight = Math.ceil(lineHeight * rowCnt);
279            }
280            // 対象の要素を非表示で複製する
281            var $clone = $target.clone();
282            $clone.css({
283                display: 'none',
284                position: 'absolute',
285                overflow: 'visible'
286            }).width($target.width()).height('auto');
287            $target.after($clone);
288
289            // 指定した高さになるまで、1文字ずつ消去していく
290            while ((html.length > 0) && ($clone.height() > targetHeight)) {
291                html = html.substr(0, html.length - 1);
292                $clone.html(html + '...');
293            }
294
295            // 文章を入れ替えて、複製した要素を削除する
296            $target.html($clone.html());
297            $clone.remove();
298        });
299    }
300
301    ellipsisMultiline($('[data-row-cnt]'));
302
303    function initSlick() {
304        var $slickTarget = $('.is_slick');
305        if ($slickTarget) {
306            $slickTarget.slick({
307                infinite: true,
308                speed: 300,
309                initialSlide: 0,
310                slidesToShow: 2.23,
311                arrows: false,
312            });
313        }
314    }
315
316    $('.category-pull-down').click(function () {
317        $('.category-pull-down-list').fadeToggle(200);
318        return false;
319    });
320
321    $('.category-pull-down-close').click(function () {
322        $('.category-pull-down-list').fadeOut(200);
323        return false;
324    });
325
326    var $categoryPullDownList = $('.category-pull-down-list'),
327        $categoryPullDown = $('.category-pull-down');
328    var isMouseHover = true;
329    var pullDownCloseTimer;
330    function pullDownMouseOut() {
331        isMouseHover = false;
332        $(":hover").each(function() {
333            if ($(this).hasClass('title-pull-down-list')) {
334                isMouseHover = true;
335            }
336        });
337
338        if (!isMouseHover) {
339            pullDownCloseTimer = setTimeout(function() {
340                $categoryPullDownList.fadeOut(200);
341            }, 1000);
342        }
343    }
344
345    $categoryPullDownList.mouseout(pullDownMouseOut);
346    $categoryPullDown.mouseout(pullDownMouseOut);
347
348    function pullDownMouseOver() {
349        isMouseHover = true;
350        clearTimeout(pullDownCloseTimer)
351    }
352    $categoryPullDownList.mouseover(pullDownMouseOver);
353    $categoryPullDown.mouseover(pullDownMouseOver);
354
355    $('body').on('click', function () {
356        if(!isMouseHover) {
357            $categoryPullDownList.fadeOut(200);
358        }
359    });
360})(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.