(function ($) { $.ajax({ url: '/wp-content/main_visual.json', dataType: 'json', success: function (data) { let totalWeight = 0; for(let i = 0;i -1 || navigator.userAgent.indexOf('Android') > -1) { isSp = true; } if (data.bg) { $('.bg-image').html(''); } if (data.youtube_live_url) { cls += 'slide-youtube-live'; } else if (data.label) { cls += 'slide-' + data.label; } var html = html = ['']; if (data.youtube_id) { html.push(''); } else if (data.youtube_live_url) { if (isSp) { var widthRegexp = new RegExp(/width="([0-9]*)"/), heightRegexp = new RegExp(/height="([0-9]*)"/), widthMatches = widthRegexp.exec(data.youtube_live_url), heightMatches = heightRegexp.exec(data.youtube_live_url); if (widthMatches.length > 1 && heightMatches.length > 1) { iframeWidth = widthMatches[1]; iframeHeight = heightMatches[1]; iframeHeight = Math.floor(iframeHeight * (624 / iframeWidth)); iframeWidth = 624; } } html.push('
' + data.youtube_live_url + '
'); } else { if (data.pc_main_visual) { html.push(''); } if (data.sp_main_visual) { html.push(''); } } html.push('
'); $topVisual.html(html.join('')); if (data.youtube_live_url && iframeWidth && iframeHeight && isSp) { $topVisual.find('iframe').attr('width', iframeWidth).attr('height', iframeHeight); } } }); })(jQuery);