var $=jQuery;
$(function(){
$('.ToggleSp').click(function(){
$(this).toggleClass('active');
if($(this).hasClass('active')){
$('.globalMenuSp').addClass('active');
$('.global-bg').addClass('active');
$('.global-bg').addClass('navClose');
}else{
$('.globalMenuSp').removeClass('active');
$('.global-bg').removeClass('active');
}});
});
$(function(){
$('.navToggle').click(function(){
$(this).addClass('active');
$('#mask').addClass('open');
if($(this).hasClass('active')){
$('.globalMenuSp').addClass('active');
}else{
$('.globalMenuSp').removeClass('active');
}});
});
$(function(){
$('.navClose').click(function(){
$('.navToggle').removeClass('active');
$('#mask').removeClass('open');
$('html').removeClass('is-fixed');
if($('.navToggle').hasClass('active')){
$('.globalMenuSp').addClass('active');
}else{
$('.globalMenuSp').removeClass('active');
}});
});
$(function(){
$('.bg-close').click(function(){
$('.navToggle').removeClass('active');
$('.globalMenuSp').removeClass('active');
});
});
$(function(){
$('#mask').click(function(){
$('.globalMenuSp').removeClass('active');
$('.navToggle').removeClass('active');
$('#mask').removeClass('open');
$('html').removeClass('is-fixed');
});
});
(function($){
var $nav=$('.globalMenuSp');
var $btn=$('.navToggle');
var $mask=$('#mask');
var $close_btn=$('.navClose');
var open='open';
$btn.on('click', function(){
$mask.addClass(open);
});
$close_btn.on('click' , function(){
$nav.removeClass('active');
});
$mask.on('click', function(){
$nav.removeClass('active');
$('html').removeClass('is-fixed');
$mask.removeClass(open);
});
})(jQuery);
const setFillHeight=()=> {
const vh=window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
}
let vw=window.innerWidth;
window.addEventListener('resize', ()=> {
if(vw===window.innerWidth){
return;
}
vw=window.innerWidth;
setFillHeight();
});
setFillHeight();
$(function(){
$('.accordion').click(function(){
$(this).toggleClass('bg02').next().slideToggle();
});
});
$(function(){
$('.modal-open-button').on('click', function(){
$('html').addClass('is-fixed-modal');
$('#mask2').addClass('open');
});
$('.close-fv, #mask2').on('click', function(){
$('html').removeClass('is-fixed-modal');
$('#mask2').removeClass('open');
if(this.id==='mask2') $('#modalToggle').prop('checked', false);
});
});
document.addEventListener('DOMContentLoaded', ()=> {
const openBtn=document.querySelector('.modal-open-button');
const closeBtn=document.querySelector('.close-fv');
const mask2=document.getElementById('mask2');
const html=document.documentElement;
let scrollPosition=0;
const closeModal=()=> {
html.classList.remove('is-fixed-modal');
html.style.top='';
html.style.position='';
html.style.width='';
window.scrollTo(0, scrollPosition);
};
if(openBtn){
openBtn.addEventListener('click', ()=> {
scrollPosition=window.pageYOffset||html.scrollTop;
html.classList.add('is-fixed-modal');
html.style.top=`-${scrollPosition}px`;
html.style.position='fixed';
html.style.width='100%';
});
}
if(closeBtn){
closeBtn.addEventListener('click', closeModal);
}
if(mask2){
mask2.addEventListener('click', closeModal);
}});
$(function(){
$('.modal-open-button2').click(()=> $('#mask3').addClass('open'));
$('#mask3').click(()=> {
$("#modalToggle2").prop("checked", false);
$('#mask3').removeClass('open');
});
$('.navToggle').click(()=> $('html').addClass('is-fixed'));
$('.navClose').click(()=> $('html').removeClass('is-fixed'));
$('.ToggleSp').click(()=> $('html').toggleClass('is-fixed'));
});
$(document).ready(function(){
if($("h2:contains('同一運営者の可能性が高い競馬サイト一覧')").length){
$('.same-site-area').show();
$('.same-site-area').insertAfter("h2:contains('同一運営者の可能性が高い競馬サイト一覧')");
}});
$(function(){
$('.readmore').click(function(){
$(this).hide();
$(this).parent('.div__author__content__right').removeClass('onhidden');
});
});
document.addEventListener('DOMContentLoaded', ()=> {
const checkboxes=document.querySelectorAll('.img-check');
const previewContainers=document.querySelectorAll('.registered-thumbnail');
const choiceMenu=document.querySelector('.scode-comparison-site__choice');
const choiceButton=document.querySelector('.modal-open-button2');
const choiceResult=document.querySelector('.modal2');
const updatePreview=(e)=> {
const checkedItems=Array.from(checkboxes).filter(cb=> cb.checked);
if(choiceMenu){
choiceMenu.style.display=checkedItems.length >=1 ? 'block':'none';
}
if(checkedItems.length > 2){
alert('比較できるのは2つまでです。');
if(e) e.target.checked=false;
return;
}
previewContainers.forEach(container=> {
container.innerHTML='';
container.removeAttribute('data-target-id');
const span=container.nextElementSibling;
if(span&&span.tagName==='SPAN') span.style.display='block';
const parentPost=container.closest('.scode-comparison-site__choice__post');
if(parentPost){
const closeBtn=parentPost.querySelector('.close');
if(closeBtn) closeBtn.style.display='none';
}});
checkedItems.forEach((checkbox, index)=> {
if(index >=previewContainers.length) return;
const container=previewContainers[index];
const imgSrc=checkbox.getAttribute('data-img');
const siteId=checkbox.getAttribute('data-id')||checkbox.value;
container.setAttribute('data-target-id', siteId);
const row=checkbox.closest('tr');
const nameElement=row.querySelector('.site-name')||row.querySelector('.site-td');
const siteNameHTML=nameElement ? nameElement.innerHTML:'名称不明';
const siteNameText=nameElement ? nameElement.textContent.trim():'名称不明';
if(imgSrc&&imgSrc!==""){
container.innerHTML=`<img src="${imgSrc}" alt="${siteNameText}"><div class="name-info">${siteNameHTML}</div>`;
const span=container.nextElementSibling;
if(span&&span.tagName==='SPAN') span.style.display='none';
const parentPost=container.closest('.scode-comparison-site__choice__post');
if(parentPost){
const closeBtn=parentPost.querySelector('.close');
if(closeBtn) closeBtn.style.display='block';
}}
});
};
document.addEventListener('click', (e)=> {
const closeBtn=e.target.closest('.close');
if(closeBtn){
const parentPost=closeBtn.closest('.scode-comparison-site__choice__post');
const container=parentPost ? parentPost.querySelector('.registered-thumbnail'):null;
if(container){
const targetId=container.getAttribute('data-target-id');
if(targetId){
checkboxes.forEach(cb=> {
const cbId=cb.getAttribute('data-id')||cb.value;
if(cbId===targetId) cb.checked=false;
});
updatePreview();
}}
}});
let scrollY=0;
const body=document.body;
const openButtons=document.querySelectorAll('.modal-open-button2');
openButtons.forEach(button=> {
button.addEventListener('click', (e)=> {
const currentCheckedCount=Array.from(checkboxes).filter(cb=> cb.checked).length;
if(currentCheckedCount===1){
e.preventDefault();
alert('サイトを2つ選択してください。');
const targetInput=document.getElementById('modalToggle2');
if(targetInput) targetInput.checked=false;
if(choiceResult) choiceResult.style.display='none';
return;
}
scrollY=window.scrollY;
body.style.position='fixed';
body.style.width='100%';
body.style.top=`-${scrollY}px`;
body.classList.add('is-fixed-comparison');
if(choiceResult) choiceResult.style.display='';
});
});
const closeButtons=document.querySelectorAll('.close2');
closeButtons.forEach(button=> {
button.addEventListener('click', ()=> {
body.classList.remove('is-fixed-comparison');
body.style.position='';
body.style.width='';
body.style.top='';
window.scrollTo(0, scrollY);
});
});
const closeButtons2=document.querySelectorAll('.mask3');
closeButtons2.forEach(button=> {
button.addEventListener('click', ()=> {
body.classList.remove('is-fixed-comparison');
body.style.position='';
body.style.width='';
body.style.top='';
window.scrollTo(0, scrollY);
});
});
checkboxes.forEach(cb=> {
cb.addEventListener('change', (e)=> updatePreview(e));
});
});
document.addEventListener('DOMContentLoaded', function (){
const footerNav=document.getElementById('footer-nav');
let lastScrollY=window.scrollY;
let ticking=false;
window.addEventListener('scroll', function (){
if(footerNav){
if(!ticking){
window.requestAnimationFrame(function (){
updateNavState();
ticking=false;
});
ticking=true;
}}
});
function updateNavState(){
const currentScrollY=window.scrollY;
if(currentScrollY < 0) return;
if(currentScrollY < lastScrollY){
if(!footerNav.classList.contains('is-visible')){
footerNav.classList.add('is-visible');
}}else{
if(footerNav.classList.contains('is-visible')){
footerNav.classList.remove('is-visible');
}}
lastScrollY=currentScrollY;
}});
(function(){
const STORAGE_KEY='wp_view_history';
const MAX_ITEMS=5;
function saveAndRender(){
if(!window.currentPostData){
setTimeout(()=> {
if(window.currentPostData) executeSave();
}, 100);
}else{
executeSave();
}
function executeSave(){
let history=[];
try {
const savedData=localStorage.getItem(STORAGE_KEY);
history=savedData ? JSON.parse(savedData):[];
} catch (e){
history=[];
}
history=history.filter(item=> item.id!==window.currentPostData.id);
history.unshift(window.currentPostData);
history=history.slice(0, MAX_ITEMS);
localStorage.setItem(STORAGE_KEY, JSON.stringify(history));
renderHistoryList();
}}
function renderHistoryList(){
const listContainer=document.getElementById('user-history-list');
if(!listContainer) return;
let history=[];
try {
history=JSON.parse(localStorage.getItem(STORAGE_KEY))||[];
} catch (e){
history=[];
}
if(history.length===0){
listContainer.innerHTML='<li>履歴はありません。</li>';
return;
}
listContainer.innerHTML=history.map(item=>
`<li><a href="${item.url}">${item.title}</a></li>`
).join('');
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', saveAndRender);
}else{
saveAndRender();
}})();
window.WebFontConfig={
google: {
families: ['M PLUS 1p:wght@400;700', 'Roboto Condensed:wght@400;700', 'Yusei Magic']
},
active: function(){
sessionStorage.fontsLoaded=true;
}};
(function(d){
var wf=d.createElement('script'), s=d.scripts[0];
wf.src='https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async=true;
s.parentNode.insertBefore(wf, s);
})(document);