debug
This commit is contained in:
@@ -37,7 +37,7 @@ function formatVideoUrl(strPinYin, intVId) {
|
||||
.replace('{intVId}', intVId);
|
||||
}
|
||||
|
||||
function formatVideoPlayUrl(strPinYin, intVId, strPlayType='defualt',intPlayIndex=1) {
|
||||
function formatVideoPlayUrl(strPinYin, intVId, strPlayType = 'defualt', intPlayIndex = 1) {
|
||||
return strVideoPlayUrlTemp
|
||||
.replace('{strPinYin}', encodeURIComponent(strPinYin))
|
||||
.replace('{intVId}', intVId)
|
||||
@@ -46,7 +46,7 @@ function formatVideoPlayUrl(strPinYin, intVId, strPlayType='defualt',intPlayInde
|
||||
|
||||
}
|
||||
|
||||
function formatSearchUrl(strKey,intPage=1) {
|
||||
function formatSearchUrl(strKey, intPage = 1) {
|
||||
return strSearchUrlTemp
|
||||
.replace('{strSearchKeywords}', strKey)
|
||||
.replace('{intPage}', intPage);
|
||||
@@ -159,23 +159,23 @@ function handleRedirect() {
|
||||
|
||||
// 判断当前路径的第一个目录是否在其它模板的 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 === '/' ? `/` : `${strCurrentPath}`;
|
||||
window.location.href = buildUrl(newPath);
|
||||
}else{
|
||||
} else {
|
||||
// 如果包含,则先判断是不是当前模板的 url,如果不是 则替换成当前模板的 url
|
||||
if (firstSegment != strPcPath.replace('/', '')) {
|
||||
strCurrentPath = strCurrentPath.replace(firstSegment,strPcPath.replace('/', '')) ;
|
||||
if (firstSegment != strPcPath.replace('/', '')) {
|
||||
strCurrentPath = strCurrentPath.replace(firstSegment, strPcPath.replace('/', ''));
|
||||
window.location.href = buildUrl(strCurrentPath);
|
||||
}
|
||||
}
|
||||
@@ -193,18 +193,18 @@ function layerPopup(strContent, intTime) {
|
||||
}
|
||||
|
||||
// 添加收藏
|
||||
function incShouCangFun(intId){
|
||||
function incShouCangFun(intId) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', "/sc?intId="+intId, true);
|
||||
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)
|
||||
layerPopup('收藏成功', 3)
|
||||
}
|
||||
if (xhr.readyState == 4 && xhr.status == 0) {
|
||||
layerPopup('操作太频繁,稍后再试',3)
|
||||
layerPopup('操作太频繁,稍后再试', 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,9 +218,9 @@ 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);
|
||||
|
||||
@@ -241,7 +241,7 @@ function addBookshelfFun(NovelInfo) {
|
||||
|
||||
|
||||
function displayShujia() {
|
||||
|
||||
|
||||
// 获取书架数据
|
||||
const shujia = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
|
||||
|
||||
@@ -297,12 +297,12 @@ function displayShujia() {
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
shujiaContainer.appendChild(bookElement);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 加入阅读记录
|
||||
@@ -310,7 +310,7 @@ function addHistoryFun(VideoInfo) {
|
||||
// 如果没有传入 VideoInfo arrVideo 并补充字段
|
||||
if (!VideoInfo) {
|
||||
VideoInfo = arrVideo
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 获取本地存储中的历史记录
|
||||
@@ -427,9 +427,9 @@ function escapeHtml(str) {
|
||||
}
|
||||
|
||||
async function reportStats(data) {
|
||||
|
||||
|
||||
try {
|
||||
const response = await fetch(strPushApi+'/publishv', {
|
||||
const response = await fetch(strPushApi + '/publishv', {
|
||||
method: 'POST',
|
||||
// mode: 'no-cors', // 添加这行
|
||||
headers: {
|
||||
@@ -478,21 +478,21 @@ function initDPlayer(strPlayUrl) {
|
||||
// 设置视频元素的样式,取消 max-height
|
||||
document.querySelector("video").style.maxHeight = "none";
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = "none";
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 监听全屏退出事件
|
||||
videoPlayer.on('fullscreen_cancel', function () {
|
||||
DomDPlayer.classList.remove("dp-fullscreen");
|
||||
// 恢复 max-height 为 480px
|
||||
if(isMobile()){
|
||||
if (isMobile()) {
|
||||
document.querySelector("video").style.maxHeight = "218px";
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = "218px";
|
||||
}else{
|
||||
} else {
|
||||
document.querySelector("video").style.maxHeight = strMaxPlayHeight ?? '480px';
|
||||
document.querySelector(".video-play-page .dplayer-video-wrap").style.maxHeight = strMaxPlayHeight ?? '480px';
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
videoPlayer.on('error', function () {
|
||||
@@ -533,7 +533,7 @@ function initDPlayer(strPlayUrl) {
|
||||
if (videoPlayer.video.currentTime >= 6046 && videoPlayer.video.currentTime < 6067) { //19秒
|
||||
videoPlayer.seek(6068); // 跳过到 494 秒
|
||||
}
|
||||
}else if (strPlayType == 'fengchao') {
|
||||
} else if (strPlayType == 'fengchao') {
|
||||
// if (videoPlayer.video.currentTime >= 476 && videoPlayer.video.currentTime < 494) { //18秒
|
||||
// videoPlayer.seek(495); // 跳过到 494 秒
|
||||
// }
|
||||
@@ -549,7 +549,7 @@ function initDPlayer(strPlayUrl) {
|
||||
// if (videoPlayer.video.currentTime >= 6046 && videoPlayer.video.currentTime < 6067) { //19秒
|
||||
// videoPlayer.seek(6068); // 跳过到 494 秒
|
||||
// }
|
||||
}else if (strPlayType == 'wuxian') {
|
||||
} else if (strPlayType == 'wuxian') {
|
||||
// if (videoPlayer.video.currentTime >= 476 && videoPlayer.video.currentTime < 494) { //18秒
|
||||
// videoPlayer.seek(495); // 跳过到 494 秒
|
||||
// }
|
||||
@@ -566,9 +566,9 @@ function initDPlayer(strPlayUrl) {
|
||||
// videoPlayer.seek(6068); // 跳过到 494 秒
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ function findFirstUrl(obj) {
|
||||
}
|
||||
|
||||
// 切换播放线路
|
||||
function checkLine(val){
|
||||
function checkLine(val) {
|
||||
// 构造 ID(去掉 # 前缀)
|
||||
let strLineHeadId = `line_head_${val}`;
|
||||
let strLineListId = `playlist_${val}`;
|
||||
@@ -622,10 +622,29 @@ function checkLine(val){
|
||||
});
|
||||
}
|
||||
|
||||
function reorderObj(obj) {
|
||||
if (!obj || typeof obj !== 'object') return obj;
|
||||
let newObj = {};
|
||||
if (obj.hasOwnProperty('douban')) {
|
||||
newObj['douban'] = obj['douban'];
|
||||
}
|
||||
for (let key in obj) {
|
||||
if (key !== 'douban' && obj.hasOwnProperty(key)) {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
|
||||
if (typeof strVideoId !== "undefined") {
|
||||
|
||||
if (arrPlayUrl) {
|
||||
arrPlayUrl = reorderObj(arrPlayUrl);
|
||||
}
|
||||
|
||||
// 使用示例
|
||||
const statsData = {
|
||||
v_id: strVideoId,
|
||||
@@ -633,8 +652,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
// 调用方法1
|
||||
reportStats(statsData);
|
||||
|
||||
if (typeof strPlayType !== "undefined"){
|
||||
|
||||
if (typeof strPlayType !== "undefined") {
|
||||
if (strPlayType == 'default') {
|
||||
strPlayUrl = findFirstUrl(arrPlayUrl)
|
||||
checkLine('douban');
|
||||
|
||||
Reference in New Issue
Block a user