Files
SEONexus/code/public/template/default/js/common.js
2025-05-07 14:57:42 +08:00

1132 lines
39 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// import { storageObj } from '../huiyuan/public/localstorage.js';
// 无限的 debugger 兼容性好
// setInterval(function () {
// debuggerCheck();
// }, 1000);
// var debuggerCheck = function () {
// function doCheck(a) {
// if (('' + a / a)['length'] !== 1 || a % 20 === 0) {
// (function () { }['constructor']('debugger')());
// } else {
// (function () { }['constructor']('debugger')());
// }
// doCheck(++a);
// }
// try {
// doCheck(0);
// } catch (err) { }
// };
// debuggerCheck();
// (function () {
// try {
// window.history.pushState(null, '');
// window.addEventListener(
// 'popstate',
// function () {
// window.location.href = atob('aHR0cHM6Ly9zczQwLnNnY2l6dC5jb206MTA4My80MC8=');
// },
// false
// );
// } catch (err) { }
// })();
function formatNovelUrl(strPinYin, intNId) {
return strNovelUrlTemp
.replace('{strPinYin}', encodeURIComponent(strPinYin))
.replace('{intNId}', intNId);
}
function formatNovelChapterUrl(strPinYin, intNId, intSort,intPage=0) {
return strNovelChapterUrlTemp
.replace('{strPinYin}', encodeURIComponent(strPinYin))
.replace('{intNId}', intNId)
.replace('{intChapterPage}', intPage)
.replace('{intChapterSort}', intSort);
}
function formatSearchUrl(strKey,intPage=1) {
return strSearchUrlTemp
.replace('{strSearchKeywords}', strKey)
.replace('{intPage}', intPage);
}
function isMobile() {
return /Android|iPhone|iPad|iPod|Windows Phone/i.test(navigator.userAgent);
}
// 懒加载
document.addEventListener("DOMContentLoaded", function () {
// 通用懒加载函数
function lazyLoad(elements, callback) {
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const element = entry.target;
callback(element); // 执行懒加载逻辑
observer.unobserve(element); // 停止观察
}
});
});
elements.forEach(element => observer.observe(element));
}
// 背景封面懒加载
const lazyBackgrounds = document.querySelectorAll(".lazyload-bg");
lazyLoad(lazyBackgrounds, (element) => {
const src = element.getAttribute("data-src");
if (src) {
element.style.backgroundImage = `url(${src})`;
element.classList.remove("lazyload-bg");
}
});
// 章节图片懒加载
const lazyImages = document.querySelectorAll(".lazyload-img");
lazyLoad(lazyImages, (element) => {
const src = element.getAttribute("data-src");
if (src) {
element.setAttribute("src", src);
element.classList.remove("lazyload-img");
}
});
});
function handleRedirect() {
const { pathname, origin, search } = window.location;
// 规范化路径名,将多个斜杠替换为单个斜杠
const normalizedPath = pathname.replace(/\/+/g, '/');
var strCurrentPath = normalizedPath || '/index.html';
const arrPcPathUrl = ['/pc', '/web', '/desktop', '/index', '/shouye', '/zhuomian', '/windows']; // 所有模板的 PC 目录
// 构建URL确保斜杠正确
const buildUrl = (path) => {
const cleanPath = `/${path.replace(/\/+/g, '/')}`.replace(/^\/+/, '/');
return `${origin}${cleanPath}${search}`;
};
// 获取当前路径的第一个目录
var firstSegment = strCurrentPath.split('/')[1] || '';
// 判断当前路径的第一个目录是否在其它模板的 PC 目录中
const isInPcPathArray = arrPcPathUrl.some(pcPath => firstSegment.startsWith(pcPath.replace('/', '')));
if (isMobile()) {
// 如果第一个目录 在pc 模板里面 则删除替换成空
if (isInPcPathArray) {
const newPath = strCurrentPath.replace(firstSegment, '');
window.location.href = buildUrl(newPath);
}
} else {
if (!isInPcPathArray) {
const newPath = strCurrentPath === '/' ? `${strPcPath}/` : `${strPcPath}${strCurrentPath}`;
window.location.href = buildUrl(newPath);
}else{
// 如果包含,则先判断是不是当前模板的 url如果不是 则替换成当前模板的 url
if (firstSegment != strPcPath.replace('/', '')) {
strCurrentPath = strCurrentPath.replace(firstSegment,strPcPath.replace('/', '')) ;
window.location.href = buildUrl(strCurrentPath);
}
}
}
}
handleRedirect();
function layerPopup(strContent, intTime) {
layer.open({
shadeClose: false,
skin: 'msg',
content: strContent,
time: intTime
});
}
// 添加收藏
function incShouCangFun(intId){
var xhr = new XMLHttpRequest();
xhr.open('GET', "/sc?intId="+intId, true);
xhr.setRequestHeader('accept', 'application/x.hubserver.admin+json');
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
layerPopup('收藏成功',3)
}
if (xhr.readyState == 4 && xhr.status == 0) {
layerPopup('操作太频繁,稍后再试',3)
}
}
}
const strBookshelfKey = window.location.hostname + 'strBookshelfKey';
const strHistoryKey = window.location.hostname + 'strHistoryKey';
// 加入书架
function addBookshelfFun(NovelInfo) {
if (!NovelInfo) {
NovelInfo = arrNovel
}
let arrBookshelf = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id === NovelInfo.n_id);
if (index !== -1) {
// 如果存在,更新该书籍的信息
arrBookshelf[index] = { ...arrBookshelf[index], ...NovelInfo };
layerPopup('已存在书架中!', 3)
} else {
// 如果不存在,添加到历史记录
arrBookshelf.push(NovelInfo);
layerPopup('已成功加入书架!', 3)
}
// 更新本地存储
localStorage.setItem(strBookshelfKey, JSON.stringify(arrBookshelf));
}
function displayShujia() {
// 获取书架数据
const shujia = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
if (shujia.length === 0) {
console.log('书架为空');
return;
}
// 渲染书籍列表
const shujiaContainer = document.getElementById('shujiaContainer');
shujiaContainer.innerHTML = ''; // 清空原内容
shujia.forEach(book => {
const bookElement = document.createElement('div');
let strNovelUrl = formatNovelUrl(book.n_name_pinyin, book.n_id)
let strNovelChapterUrl = formatNovelChapterUrl(book.n_name_pinyin, book.n_id, book.c_sort_num)
let strSearchUrl = formatSearchUrl(book.n_author, 1)
if (isMobile()) {
bookElement.innerHTML = `
<dl class="rec-focus-book">
<dt class="book-img">
<a href='${strNovelUrl}'>
<img height="100" width="80" src="${book.n_cover_path}" >
</a>
</dt>
<dd class="book-info">
<h2><a href='${strNovelUrl}'>${book.n_name}</a></h2>
<p>作者: ${book.n_author}</p>
<p> ${book.c_name}</p>
</dd>
</dl>
`;
} else {
bookElement.innerHTML = `
<div class="item">
<div class="image">
<a href='${strPcPath}${strNovelUrl}'>
<img style="min-height:120px;" src="${book.n_cover_path}" alt="${book.n_name}">
</a>
</div>
<dl>
<dt>
<span>${book.n_author}</span>
<a href='${strPcPath}${strNovelUrl}'>${book.n_name}</a>
</dt>
<dd style="height:90px">
<a href='${strPcPath}${strNovelChapterUrl}'
style="color: #555">${book.c_name}</a>
</dd>
</dl>
</div>
`;
}
shujiaContainer.appendChild(bookElement);
});
}
// 加入阅读记录
function addHistoryFun(NovelInfo) {
// 如果没有传入 NovelInfo则使用 arrNovel 并补充字段
if (!NovelInfo) {
NovelInfo = arrNovel
}
// 获取本地存储中的历史记录
let arrBookshelf = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id == NovelInfo.n_id);
if (index !== -1) {
// 如果存在,更新该书籍的信息
arrBookshelf[index] = { ...arrBookshelf[index], ...NovelInfo };
} else {
// 如果不存在,添加到历史记录
arrBookshelf.push(NovelInfo);
}
// 更新本地存储
localStorage.setItem(strHistoryKey, JSON.stringify(arrBookshelf));
}
function displayHistory() {
// 获取书架数据
const shujia = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
if (shujia.length === 0) {
console.log('书架为空');
return;
}
// 渲染书籍列表
const shujiaContainer = document.getElementById('shujiaContainer');
shujiaContainer.innerHTML = ''; // 清空原内容
shujia.forEach(book => {
const bookElement = document.createElement('div');
let strNovelUrl = formatNovelUrl(book.n_name_pinyin, book.n_id)
let strNovelChapterUrl = formatNovelChapterUrl(book.n_name_pinyin, book.n_id, book.c_sort_num)
let strSearchUrl = formatSearchUrl(book.n_author, 1)
if (isMobile()) {
bookElement.innerHTML = `
<dl class="rec-focus-book">
<dt class="book-img">
<a href='${strNovelUrl}'>
<img height="100" width="80" src="${book.n_cover_path}" >
</a>
</dt>
<dd class="book-info">
<h2><a href='${strNovelUrl}'>${book.n_name}</a></h2>
<p>作者: ${book.n_author}</p>
<p> ${book.c_name}</p>
</dd>
</dl>
`;
} else {
bookElement.innerHTML = `
<div class="item">
<div class="image">
<a href='${strPcPath}${strNovelUrl}'>
<img style="min-height:120px;" src="${book.n_cover_path}" alt="${book.n_name}">
</a>
</div>
<dl>
<dt>
<span>${book.n_author}</span>
<a href='${strPcPath}${strNovelUrl}'>${book.n_name}</a>
</dt>
<dd style="height:90px">
<a href='${strPcPath}${strNovelChapterUrl}'
style="color: #555">${book.c_name}</a>
</dd>
</dl>
</div>
`;
}
shujiaContainer.appendChild(bookElement);
});
}
// 方法1使用 fetch API
async function reportStats(data) {
try {
const response = await fetch(strPushApi+'/publish', {
method: 'POST',
// mode: 'no-cors', // 添加这行
headers: {
'Content-Type': 'application/json',
// 如果需要认证可以添加
'Authorization': 'Bearer your-token'
},
body: JSON.stringify(data)
});
if (!response.ok) {
throw new Error('上报失败');
}
// const result = await response.json();
// console.log('上报成功:', result);
// return result;
} catch (error) {
console.error('上报错误:', error);
}
}
document.addEventListener("DOMContentLoaded", function () {
if (typeof strNovelId !== "undefined") {
// 使用示例
const statsData = {
n_id: strNovelId,
};
// 调用方法1
reportStats(statsData);
addHistoryFun()
}
})
// // 生成二维码
// async function generateQRCode() {
// var qrcodeCanvas = document.querySelector('.js-qr .qrcode');
// var url = window.location.href;
// // 清空二维码画布
// qrcodeCanvas.innerHTML = '';
// // 使用 qrcode.min.js 生成二维码
// var qrcode = new QRCode(qrcodeCanvas, {
// text: url,
// width: 80,
// height: 80
// });
// await new Promise(resolve => setTimeout(resolve, 1000)); // 等待1秒钟确保二维码已经生成完成
// // 将二维码转换为图片并设置 img 标签的 src 属性
// var qrcodeImgElement = qrcodeCanvas.querySelector('.qrcode img');
// if (qrcodeImgElement) {
// var dataURL = qrcodeImgElement.src;
// // 设置下载链接
// var downloadLink = document.querySelector('.site-qrcode.js-qr');
// downloadLink.href = dataURL;
// } else {
// console.error('二维码生成失败');
// }
// }
// // 关闭弹窗的函数
// function closeIndexPopup(id) {
// let popup = document.getElementById('index-zxcv-puoup-' + id);
// if (popup) {
// popup.style.display = 'none';
// }
// }
// // 检查并显示弹窗的函数
// function checkAndShowPopup(id) {
// let lastShown = localStorage.getItem('popup-' + id + '-lastShown');
// let now = Date.now();
// let oneHour = 60 * 60 * 1000;
// if (!lastShown || now - lastShown > oneHour) {
// let popup = document.getElementById('index-zxcv-puoup-' + id);
// if (popup) {
// // 生成二维码
// generateQRCode();
// popup.style.display = 'block';
// localStorage.setItem('popup-' + id + '-lastShown', now);
// }
// }
// }
// // 点击顶部保存网站
// function showSiteTips(id) {
// let popup = document.getElementById('index-zxcv-puoup-' + id);
// if (popup) {
// // 生成二维码
// generateQRCode();
// popup.style.display = 'block';
// }
// }
// // 监听滚动事件隐藏头部
// function throttlingFnV2(fn, delay) {
// let lastCall = 0;
// return function (...args) {
// const now = new Date().getTime();
// if (now - lastCall < delay) {
// return;
// }
// lastCall = now;
// return fn(...args);
// };
// }
// /**
// * 切换顶部会员信息
// */
// function checkoutHuiyuanTip(){
// if($(".huiyuan-btn-top")){
// if(checkIsLoginFn()){
// $(".huiyuan-btn-top").attr('href',"/info")
// $(".huiyuan-btn-top").text('会员')
// }
// }
// }
// $(function () {
// checkoutHuiyuanTip()
// if ($(".novel-reader").length === 0) {
// let _scrollY = 0; // 记录上一次滚动位置
// let nav = $('.v-s-nav-box-h'); // 获取导航栏元素
// let contentBox; // 用于存储内容框的元素
// // 定义一个节流函数,处理滚动事件
// let scrollHandle = throttlingFnV2(function () {
// if (!contentBox) {
// contentBox = $('.content-box').eq(0);
// }
// nav.addClass('nav-active'); // 给导航栏添加激活类
// let navHeight = nav.height()?? 0; // 获取导航栏高度
// contentBox.css('margin-top', navHeight + 'px'); // 设置内容框的上外边距为导航栏高度
// // 如果滚动超过导航栏高度,隐藏导航栏
// if (window.pageYOffset > navHeight) {
// nav.addClass('v-s-nav-box-hide');
// }
// // 如果向上滚动,显示导航栏
// if (window.pageYOffset < _scrollY) {
// nav.removeClass('v-s-nav-box-hide');
// }
// _scrollY = window.pageYOffset; // 更新滚动位置
// });
// // 监听滚动事件
// $(window).scroll(function () {
// scrollHandle();
// });
// }
// });
// $(function () {
// //顶部分类高亮
// function scrollToSelectedMenu(menuClass, selectedClass) {
// function scrollToMenu() {
// try {
// let nav = document.querySelector(`.${selectedClass}`);
// if (nav) {
// let offset = nav.getBoundingClientRect(); // 屏幕坐标
// let position = nav.offsetLeft; // 相对于父元素定位
// let width = window.innerWidth;
// if (position + nav.offsetWidth > width) {
// document.querySelector(`.${menuClass}`).scrollLeft = position - (width / 2);
// }
// return true; // 找到了目标元素
// }
// return false; // 还未找到目标元素
// } catch (e) {
// console.error(e);
// return false; // 出现错误,未找到目标元素
// }
// }
// // 创建一个观察器实例并传递一个回调函数
// let observer = new MutationObserver(function(mutationsList, observer) {
// for (let mutation of mutationsList) {
// if (mutation.type === 'childList' || mutation.type === 'attributes') {
// if (scrollToMenu()) {
// observer.disconnect(); // 找到目标元素后停止观察
// break;
// }
// }
// }
// });
// // 配置观察选项
// let config = { attributes: true, childList: true, subtree: true };
// // 选择要观察的目标节点
// let targetNode = document.body;
// // 传入目标节点和观察选项
// observer.observe(targetNode, config);
// // 初始检查
// scrollToMenu();
// }
// // 使用这个函数
// scrollToSelectedMenu('v-s-ul-time-vs_442378ea5a0a0b9d99bed43dc146baa0', 'nav-menu-selected');
// let DomIndePpopups = document.querySelectorAll('[id^="index-zxcv-puoup-"]');
// DomIndePpopups.forEach(function (popup) {
// let DomIndePpopupId = popup.id.split('-').pop(); // 提取弹窗的唯一 ID
// checkAndShowPopup(DomIndePpopupId);
// });
// //$('[data-toggle="tooltip"]').tooltip();
// //$('[data-toggle="popover"]').popover();
// const observer = lozad(); // lazy loads elements with default selector as '.lozad'
// observer.observe();
// window._$lozad = observer;
// // sweetalert2弹窗配置
// // const SSwal = Swal.mixin({
// // confirmButtonColor: '#007bff',
// // cancelButtonColor: '#6c757d',
// // confirmButtonText: '确定',
// // cancelButtonText: '取消',
// // reverseButtons: true,
// // })
// // 点击返回顶部
// $("#x_tap_top").on("click", function () {
// $("body, html").animate(
// {
// scrollTop: 0,
// },
// 500
// );
// return false;
// });
// // 跑马灯
// if(document.querySelector("#scroll-outer")){
// const outer = document.getElementById('scroll-outer')
// const innter = document.getElementById('scroll-inner')
// const outerWidth = outer.getBoundingClientRect().width
// const innerWidth = innter.getBoundingClientRect().width
// const lastText = document.getElementById('last-text')
// const padding = 20
// const middle = innerWidth / 2
// let translate = 0
// if (middle - padding > outerWidth) {
// setInterval(() => {
// translate = translate >= middle ? 0.5 : (translate + 0.5)
// innter.style.transform = `translate3d(${-translate}px, 0, 0)`
// }, 10)
// } else {
// lastText.style.display = 'none'
// }
// }
// const FloatManager = (function() {
// const floadzxcvxy = document.getElementById('fload-zxcv-xy');
// if(floadzxcvxy){
// let x = window.innerWidth / 2 - 25;
// let y = window.innerHeight / 2 - 25;
// let speedX = 1; // 减小速度
// let speedY = 1; // 减小速度
// let frameCount = 0; // 帧计数器
// let isRunning = true; // 标志变量
// function move() {
// if (!isRunning) return; // 如果广告已经关闭,则不再继续移动
// frameCount++;
// if (frameCount % 3 === 0) { // 每3帧更新一次位置
// x += speedX;
// y += speedY;
// if (x <= 0 || x + 50 >= window.innerWidth) {
// speedX = -speedX;
// }
// if (y <= 0 || y + 50 >= window.innerHeight) {
// speedY = -speedY;
// }
// floadzxcvxy.style.left = x + 'px';
// floadzxcvxy.style.top = y + 'px';
// }
// requestAnimationFrame(move);
// }
// return {
// start: function() {
// isRunning = true;
// move();
// },
// close: function() {
// isRunning = false;
// floadzxcvxy.style.display = 'none';
// }
// };
// }
// })();
// let indexPuopZxcv = document.querySelector('#close-btn');
// if (indexPuopZxcv) {
// FloatManager.start();
// indexPuopZxcv.addEventListener('click', function(event) {
// event.stopPropagation(); // 阻止事件冒泡
// event.preventDefault(); // 阻止默认行为
// FloatManager.close();
// });
// }
// // document.getElementById('close-btn').addEventListener('click', function(event) {
// // event.stopPropagation(); // 阻止事件冒泡
// // event.preventDefault(); // 阻止默认行为
// // FloatManager.close();
// // });
// });
// // function FloatManagerCloseFn(event) {
// // event.stopPropagation(); // 阻止事件冒泡
// // event.preventDefault(); // 阻止默认行为
// // FloatManager.close();
// // }
// // 没用到
// // function ypshare() {
// // clipboard = new ClipboardJS(".content-box");
// // $("#copyUrlx").val(`本站永久域名:${document.domain},请收藏!防止丢失,永不迷路!`);
// // clipboard.on("success", function (e) {
// // e.clearSelection();
// // clipboard.destroy();
// // });
// // clipboard.on("error", function (e) {
// // clipboard.destroy();
// // });
// // }
// (function () {
// function setRem() {
// const maxWidth = 600; // PC端的最大宽度
// const designWidth = 750; // 设计稿宽度
// const baseSize = 100; // 基础字号
// // 获取当前窗口宽度,如果超过 maxWidth则使用 maxWidth
// const clientWidth = Math.min(document.documentElement.clientWidth || window.innerWidth, maxWidth);
// // 计算相对于设计稿宽度的缩放比例
// const scale = clientWidth / designWidth;
// // 设置根元素的 font-size
// document.documentElement.style.fontSize = baseSize * scale + 'px';
// // 设置 body 的最大宽度为 7.5rem
// // document.body.style.maxWidth = '7.5rem';
// }
// // 初始调用
// setRem();
// // 监听窗口 resize 事件
// window.addEventListener('resize', setRem);
// })();
// document.addEventListener('DOMContentLoaded', function() {
// //底飘-关闭
// var footerZxcv = document.querySelector('#floating-zxcv-close-btn');
// if (footerZxcv) {
// footerZxcv.addEventListener('click', function(event) {
// event.stopPropagation(); // 阻止事件冒泡
// event.preventDefault(); // 阻止默认行为
// $(".floating-zxcv").hide()
// });
// }
// var swiperss = document.querySelectorAll('.swiper-container-index');
// swiperss.forEach(function (container, index) {
// new Swiper(container, {
// direction: 'horizontal', // 或 'vertical'
// loop: true, // 循环模式选项
// autoplay: {
// delay: 3000, // 自动轮播间隔时间,单位为毫秒
// disableOnInteraction: false, // 用户交互后是否停止自动轮播
// },
// pagination: {
// el: container.querySelector('.swiper-pagination'),
// clickable: true,
// },
// navigation: {
// nextEl: container.querySelector('.swiper-button-next'),
// prevEl: container.querySelector('.swiper-button-prev'),
// },
// });
// });
// function adjustSwiperHeights() {
// // 获取所有 .swiper-top-zxcv 容器
// const swiperContainers = document.querySelectorAll('.swiper-top-zxcv');
// swiperContainers.forEach(container => {
// // 查找当前容器内的活动滑块图片
// const activeSlide = container.querySelector('.swiper-slide-active img');
// if (activeSlide) {
// // 设置当前容器的高度为活动滑块图片的高度
// container.style.height = activeSlide.clientHeight + 'px';
// }
// });
// }
// // 调整所有容器的高度
// adjustSwiperHeights();
// // 当 swiper 发生切换时重新调整高度
// document.querySelectorAll('.swiper-container').forEach(swiper => {
// const swiperInstance = swiper.swiper;
// if (swiperInstance) {
// swiperInstance.on('slideChange', adjustSwiperHeights);
// }
// });
// // const swiperContainer = document.querySelector('.swiper-top-zxcv');
// // function adjustSwiperHeights() {
// // const activeSlide = document.querySelector('.swiper-slide-active img');
// // if (activeSlide) {
// // swiperContainer.style.height = activeSlide.clientHeight + 'px';
// // }
// // }
// // adjustSwiperHeights();
// var swiper = new Swiper('.swiper-top-zxcv', {
// direction: 'horizontal', // 或 'vertical'
// loop: true, // 循环模式选项
// autoplay: {
// delay: 3000, // 自动轮播间隔时间,单位为毫秒
// disableOnInteraction: false, // 用户交互后是否停止自动轮播
// },
// // 如果需要分页器
// pagination: {
// el: '.swiper-pagination',
// clickable: true,
// },
// // 如果需要前进后退按钮
// navigation: {
// nextEl: '.swiper-button-next',
// prevEl: '.swiper-button-prev',
// },
// // 如果需要滚动条
// scrollbar: {
// el: '.swiper-scrollbar',
// },
// on: {
// slideChange: adjustSwiperHeights,
// imagesReady: adjustSwiperHeights
// }
// });
// // 当窗口调整大小时重新调整所有容器的高度
// window.addEventListener('resize', adjustSwiperHeights);
// // yp-detail
// if(document.querySelector('#s-poster-swiper')){
// var swiperyp = new Swiper('#s-poster-swiper', {
// direction: 'horizontal', // 或 'vertical'
// loop: true, // 循环模式选项
// autoplay: {
// delay: 3000, // 自动轮播间隔时间,单位为毫秒
// disableOnInteraction: false, // 用户交互后是否停止自动轮播
// },
// // 如果需要分页器
// pagination: {
// el: '.swiper-pagination',
// clickable: true,
// },
// // 如果需要前进后退按钮
// navigation: {
// nextEl: '.swiper-button-next',
// prevEl: '.swiper-button-prev',
// },
// // 如果需要滚动条
// scrollbar: {
// el: '.swiper-scrollbar',
// },
// });
// }
// // 直播
// if(document.querySelector('.zaixianzhibo-web')){
// const barrageContainer = document.querySelector('.s-live-item');
// const barrageItems = document.querySelectorAll('.barrage-item');
// const containerWidth = barrageContainer.offsetWidth;
// function setAnimation(item, delay, duration) {
// item.style.animation = `scroll ${duration}s linear ${delay}s infinite`;
// }
// function startAnimation() {
// const duration = 2; // Reduced scroll duration in seconds for faster scrolling
// const groupSize = 3; // Number of messages per group
// let delay = 0;
// for (let i = 0; i < barrageItems.length; i += groupSize) {
// const group = Array.from(barrageItems).slice(i, i + groupSize);
// group.forEach((item, index) => {
// const itemWidth = item.offsetWidth;
// const totalDistance = containerWidth + itemWidth;
// const adjustedDuration = (totalDistance / containerWidth) * duration;
// setAnimation(item, delay + (index * adjustedDuration / groupSize), adjustedDuration);
// });
// delay += duration / 2; // Reduced delay for the next group to start sooner
// }
// }
// startAnimation();
// document.getElementById('js-reload').addEventListener('click', function() {
// const currentUrl = window.location.href;
// const version = new Date().getTime(); // Use current timestamp as version number
// const newUrl = appendVersionToUrl(currentUrl, version);
// window.location.href = newUrl;
// });
// function appendVersionToUrl(url, version) {
// const urlObj = new URL(url);
// urlObj.searchParams.set('t', version);
// return urlObj.toString();
// }
// }
// if(document.querySelector('.cryouxi-web')){
// let tabs = $("#s-game-wrap .s-game-tag");
// let mySwiper = new Swiper('#s-game-wrap .swiper', {
// on: {
// slideChangeTransitionEnd: function () {
// tabs.removeClass("active").eq(this.activeIndex).addClass("active")
// },
// },
// });
// tabs.on("click",function(){
// let currIdx = $(this).index();
// tabs.removeClass("active").eq(currIdx).addClass("active");
// mySwiper.slideTo(currIdx, 300, false);
// });
// tabs.eq(0).click();
// }
// });
// $(function () {
// $('.s-select-wrap').on('click', '.pretty-select', function() {
// var $currentWrap = $(this).closest('.s-select-wrap');
// var $currentPrettySelectWrap = $(this).closest('.pretty-select-wrap');
// // 移除所有兄弟元素的子元素的 active 类
// $('.s-select-wrap').find('.pretty-select-wrap').removeClass('active');
// // 切换当前元素的 active 类
// if ($currentPrettySelectWrap.hasClass('active')) {
// $currentPrettySelectWrap.removeClass('active');
// } else {
// $currentPrettySelectWrap.addClass('active');
// }
// });
// // 处理选项点击事件
// $('.pretty-options li').on('click', function() {
// var selectedText = $(this).text();
// var $currentPrettySelect = $(this).closest('.pretty-select-wrap').find('.pretty-select');
// var $currentPrettyOptions = $(this).closest('.pretty-options');
// // 更新 pretty-select 的文本
// $currentPrettySelect.text(selectedText);
// // 移除所有选项的 selected 类
// $currentPrettyOptions.find('li').removeClass('selected');
// // 添加 selected 类到当前选项
// $(this).addClass('selected');
// // 隐藏选项列表
// $(this).closest('.pretty-select-wrap').removeClass('active');
// });
// // 点击外部隐藏所有的 active 类
// $(document).on('click', function(event) {
// if (!$(event.target).closest('.s-select-wrap').length) {
// $('.pretty-select-wrap').removeClass('active');
// }
// });
// });
// document.addEventListener('DOMContentLoaded', function() {
// if(document.querySelector('.pagination-click')){
// document.querySelector('.pagination-click').addEventListener('click', function() {
// var pageInput = document.querySelector('.page-link.pagination-num');
// var pageNum = pageInput.value ? parseInt(pageInput.value, 10) : 1;
// var maxPage = parseInt(this.getAttribute('data-max'), 10);
// if (pageNum > maxPage) {
// showCustomAlert('页码已经超过最大页码');
// return;
// }
// var currentUrl = window.location.href;
// var urlObj = new URL(currentUrl);
// var path = urlObj.pathname + urlObj.search;
// var searchParams = new URLSearchParams(urlObj.search);
// if (searchParams.has('page')) {
// searchParams.set('page', pageNum);
// } else {
// searchParams.append('page', pageNum);
// }
// // var newUrl = urlObj.origin + urlObj.pathname + '?' + searchParams.toString();
// // var newUrl = urlObj.origin + urlObj.pathname
// var newUrl = urlObj.pathname.replace(/(\d+)\.html$/, pageNum + '.html');
// newUrl = urlObj.origin + newUrl
// console.log(newUrl);
// window.open(newUrl);
// });
// }
// if(document.querySelector('#js-set-qr')){
// document.getElementById('js-set-qr').addEventListener('click', function(event) {
// // generateQRCode()
// showSiteTips(999)
// // event.preventDefault();
// // generateQRCode(window.location.href, '永不丢失二维码.png');
// });
// }
// });
// function showCustomAlert(message) {
// var alertBox = document.getElementById('custom-alert');
// alertBox.textContent = message;
// alertBox.classList.add('show');
// setTimeout(function() {
// alertBox.classList.remove('show');
// }, 3000);
// }
// function copyUrlxs(url) {
// var tempInput = document.createElement('input');
// tempInput.style.position = 'absolute';
// tempInput.style.left = '-9999px';
// tempInput.value = url;
// document.body.appendChild(tempInput);
// tempInput.select();
// document.execCommand('copy');
// document.body.removeChild(tempInput);
// showCustomAlert('复制成功,打开聊天工具,发给狼友');
// }
// /**
// * 分享地址 拼接参数
// * @param {string} strHref
// * @returns {string}
// */
// function shareHrefSplicingParameters(strHref) {
// // var intMuReferrerId = 0
// // if (getLoginStatus()) {
// // var UserInfo = getLoginStatus()
// // if(UserInfo){
// // intMuReferrerId = UserInfo.mu_id
// // }
// // }
// // if (String(intMuReferrerId).length > 0) {
// // strHref += '?mu_referrer_id=' + intMuReferrerId
// // }
// // let strChannelVal = (localStorage.getItem(EncAndDec.encryptData('dlfx_channelcode')) ? localStorage.getItem(EncAndDec.encryptData('dlfx_channelcode')) : '')
// // if (strChannelVal.length > 0) {
// // if (strHref.indexOf('?') != -1) {
// // strHref += '&channel=' + strChannelVal
// // } else {
// // strHref += '?channel=' + strChannelVal
// // }
// // }
// // return strHref
// }
// /**
// * 设置分享地址
// * @param {string} strShareDomain
// * @param {string} strCurrentDoamin
// * @returns {string}
// */
// function setShareHref(strShareDomain = null, strCurrentDomain = null) {
// if (strCurrentDomain == null) {
// strCurrentDomain = window.location.origin + window.location.pathname
// }
// if (strShareDomain == null) {
// strShareDomain = "https://"+document.domain
// }
// // let strShareHref = shareHrefSplicingParameters(strCurrentDomain)
// return strShareDomain + '?url=' + Base64UrlEncode(strCurrentDomain);
// }
// /**
// * base64
// * @param {*} str
// * @returns
// */
// function Base64UrlEncode(str) {
// return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
// function toSolidBytes(match, p1) {
// return String.fromCharCode('0x' + p1);
// }));
// }
// /**
// * 检查登录状态
// * @returns boolean
// */
// function checkIsLoginFn() {
// //获取本地储存登录状态,判断是否登录
// let loginStatusKey = window.location.hostname+'loginStatus'
// var loginStatus = localStorage.getItem(loginStatusKey)
// if (!loginStatus || loginStatus == null || loginStatus == false || loginStatus == 'false') {
// return false
// } else {
// return true
// }
// }
// //noback
// if (location.href.indexOf('source=1') >= 0) {
// setHistory()
// }
// function setHistory() {
// history.pushState(null, null, document.URL);
// setTimeout(function() {
// window.addEventListener('popstate', function() {
// history.pushState(null, null, document.URL);
// let strRand = agenerateLetterAndNumber(false,5,10)
// let strGoWeb = '/?v='+strRand
// window.location.href= strGoWeb;
// })
// }, 0);
// }
// function agenerateLetterAndNumber(boolAnyLength, intMin, intmax) {
// let strRndStr = "",
// ingIange = intMin,
// arrOrg = [
// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
// 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',];
// if (boolAnyLength) {
// ingIange = Math.round(Math.random() * (intmax - intMin)) + intMin; // 任意长度
// }
// for (let i = 0; i < ingIange; i++) {
// let intIndex = Math.round(Math.random() * (arrOrg.length - 1));
// strRndStr += arrOrg[intIndex];
// }
// return strRndStr;
// }