2022-01-24 21:27:29 +08:00
|
|
|
|
var userAgent = window.navigator.userAgent.toLowerCase();
|
|
|
|
|
console.log(userAgent);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
var norunAI = ["android", "iphone", "ipod", "ipad", "windows phone"];
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var norunFlag = false;
|
|
|
|
|
|
|
|
|
|
|
2025-05-25 01:33:47 +08:00
|
|
|
|
for (var i = 0; i < norunAI.length; i++) {
|
|
|
|
|
if (userAgent.indexOf(norunAI[i]) > -1) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
norunFlag = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (!window.WebGLRenderingContext) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
norunFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (!norunFlag) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var hitFlag = false;
|
|
|
|
|
var AIFadeFlag = false;
|
|
|
|
|
var liveTlakTimer = null;
|
|
|
|
|
var sleepTimer_ = null;
|
|
|
|
|
var AITalkFlag = false;
|
|
|
|
|
var talkNum = 0;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
function renderTip(template, context) {
|
|
|
|
|
var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g;
|
|
|
|
|
return template.replace(tokenReg, function (word, slash1, token, slash2) {
|
|
|
|
|
if (slash1 || slash2) {
|
2025-06-07 22:45:58 +08:00
|
|
|
|
return word.replace(/\\/g, '');
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
var variables = token.replace(/\s/g, '').split('.');
|
|
|
|
|
var currentObject = context;
|
|
|
|
|
var i, length, variable;
|
|
|
|
|
for (i = 0, length = variables.length; i < length; ++i) {
|
|
|
|
|
variable = variables[i];
|
|
|
|
|
currentObject = currentObject[variable];
|
|
|
|
|
if (currentObject === undefined || currentObject === null) return '';
|
|
|
|
|
}
|
|
|
|
|
return currentObject;
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
2022-01-24 21:27:29 +08:00
|
|
|
|
String.prototype.renderTip = function (context) {
|
|
|
|
|
return renderTip(this, context);
|
|
|
|
|
};
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var re = /x/;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
console.log(re);
|
|
|
|
|
re.toString = function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showMessage('哈哈,你打开了控制台,是想要看看我的秘密吗?', 5000);
|
|
|
|
|
return '';
|
|
|
|
|
};
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
$(document).on('copy', function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showMessage('你都复制了些什么呀,转载要记得加上出处哦~~', 5000);
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
function initTips() {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: true,
|
2025-05-25 01:33:47 +08:00
|
|
|
|
url: message_Path + 'message.json',
|
2022-01-24 21:27:29 +08:00
|
|
|
|
dataType: "json",
|
2025-05-25 01:33:47 +08:00
|
|
|
|
success: function (result) {
|
|
|
|
|
$.each(result.mouseover, function (index, tips) {
|
|
|
|
|
$(tips.selector).mouseover(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var text = tips.text;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
|
|
|
|
|
text = text.renderTip({ text: $(this).text() });
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showMessage(text, 3000);
|
|
|
|
|
talkValTimer();
|
|
|
|
|
clearInterval(liveTlakTimer);
|
|
|
|
|
liveTlakTimer = null;
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$(tips.selector).mouseout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showHitokoto();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (liveTlakTimer == null) {
|
|
|
|
|
liveTlakTimer = window.setInterval(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showHitokoto();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 15000);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$.each(result.click, function (index, tips) {
|
|
|
|
|
$(tips.selector).click(function () {
|
|
|
|
|
if (hitFlag) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
hitFlag = true;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
setTimeout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
hitFlag = false;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 8000);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var text = tips.text;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
|
|
|
|
|
text = text.renderTip({ text: $(this).text() });
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showMessage(text, 3000);
|
|
|
|
|
});
|
|
|
|
|
clearInterval(liveTlakTimer);
|
|
|
|
|
liveTlakTimer = null;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (liveTlakTimer == null) {
|
|
|
|
|
liveTlakTimer = window.setInterval(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showHitokoto();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 15000);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
initTips();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var text;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (document.referrer !== '' && document.referrer.split('/')[2] !== window.location.host) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var referrer = document.createElement('a');
|
|
|
|
|
referrer.href = document.referrer;
|
|
|
|
|
text = '嗨!来自 <span style="color:#0099cc;">' + referrer.hostname + '</span> 的朋友!';
|
|
|
|
|
var domain = referrer.hostname.split('.')[1];
|
|
|
|
|
if (domain == 'baidu') {
|
|
|
|
|
text = '嗨! 来自 百度搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' | ')[0] + ' 」</span>';
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else if (domain == 'so') {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
text = '嗨! 来自 360搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' | ')[0] + ' 」</span>';
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else if (domain == 'google') {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
text = '嗨! 来自 谷歌搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' | ')[0] + ' 」</span>';
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2025-08-05 20:54:04 +08:00
|
|
|
|
if (window.location.pathname == "/") { //主页URL判断,需要斜杠结尾
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var now = (new Date()).getHours();
|
|
|
|
|
if (now > 23 || now <= 5) {
|
|
|
|
|
text = '你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?';
|
|
|
|
|
} else if (now > 5 && now <= 7) {
|
|
|
|
|
text = '早上好!一日之计在于晨,美好的一天就要开始了!';
|
|
|
|
|
} else if (now > 7 && now <= 11) {
|
|
|
|
|
text = '上午好!工作顺利嘛,不要久坐,多起来走动走动哦!';
|
|
|
|
|
} else if (now > 11 && now <= 14) {
|
|
|
|
|
text = '中午了,工作了一个上午,现在是午餐时间!';
|
|
|
|
|
} else if (now > 14 && now <= 17) {
|
|
|
|
|
text = '午后很容易犯困呢,今天的运动目标完成了吗?';
|
|
|
|
|
} else if (now > 17 && now <= 19) {
|
|
|
|
|
text = '傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~~';
|
|
|
|
|
} else if (now > 19 && now <= 21) {
|
|
|
|
|
text = '晚上好,今天过得怎么样?';
|
|
|
|
|
} else if (now > 21 && now <= 23) {
|
|
|
|
|
text = '已经这么晚了呀,早点休息吧,晚安~~';
|
|
|
|
|
} else {
|
|
|
|
|
text = '嗨~ 快来逗我玩吧!';
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
text = '欢迎阅读<span style="color:#0099cc;">「 ' + document.title.split(' | ')[0] + ' 」</span>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
showMessage(text, 12000);
|
|
|
|
|
})();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
liveTlakTimer = setInterval(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
showHitokoto();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 15000);
|
|
|
|
|
|
|
|
|
|
function showHitokoto() {
|
|
|
|
|
if (sessionStorage.getItem("Sleepy") !== "1") {
|
|
|
|
|
if (!AITalkFlag) {
|
|
|
|
|
$.getJSON('https://hitokoto.mayx.eu.org/', function (result) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
talkValTimer();
|
|
|
|
|
showMessage(result.hitokoto, 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
hideMessage(0);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (sleepTimer_ == null) {
|
|
|
|
|
sleepTimer_ = setInterval(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
checkSleep();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 200);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
console.log(sleepTimer_);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
function checkSleep() {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var sleepStatu = sessionStorage.getItem("Sleepy");
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (sleepStatu !== '1') {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
talkValTimer();
|
|
|
|
|
showMessage('你回来啦~', 0);
|
|
|
|
|
clearInterval(sleepTimer_);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sleepTimer_ = null;
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
function showMessage(text, timeout) {
|
|
|
|
|
if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1) - 1];
|
2022-01-24 21:27:29 +08:00
|
|
|
|
//console.log('showMessage', text);
|
|
|
|
|
$('.message').stop();
|
2025-06-19 19:19:19 +08:00
|
|
|
|
if (typeof EventSource !== 'undefined' && text instanceof EventSource) {
|
2024-10-21 19:16:17 +08:00
|
|
|
|
var outputContainer = $('.message')[0];
|
|
|
|
|
var eventFlag = false;
|
2025-08-07 20:27:42 +08:00
|
|
|
|
text.onmessage = function (event) {
|
2024-10-21 18:12:21 +08:00
|
|
|
|
if (event.data == "[DONE]") {
|
|
|
|
|
text.close();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
return;
|
2024-10-21 18:12:21 +08:00
|
|
|
|
} else {
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (!eventFlag) {
|
|
|
|
|
talkValTimer();
|
|
|
|
|
outputContainer.textContent = "";
|
|
|
|
|
eventFlag = true;
|
|
|
|
|
}
|
2025-06-19 18:14:53 +08:00
|
|
|
|
var data = JSON.parse(event.data);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
outputContainer.textContent += data.response;
|
2024-10-21 18:12:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2024-10-21 18:12:21 +08:00
|
|
|
|
$('.message').html(text);
|
|
|
|
|
}
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('.message').fadeTo(200, 1);
|
|
|
|
|
//if (timeout === null) timeout = 5000;
|
|
|
|
|
//hideMessage(timeout);
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
function talkValTimer() {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live_talk').val('1');
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
function hideMessage(timeout) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
//$('.message').stop().css('opacity',1);
|
|
|
|
|
if (timeout === null) timeout = 5000;
|
|
|
|
|
$('.message').delay(timeout).fadeTo(200, 0);
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
|
|
|
|
function initLive2d() {
|
|
|
|
|
$("#landlord").mouseenter(function () {
|
|
|
|
|
$(".live_ico_box").fadeIn();
|
|
|
|
|
});
|
|
|
|
|
$("#landlord").mouseleave(function () {
|
|
|
|
|
$(".live_ico_box").fadeOut();
|
|
|
|
|
});
|
|
|
|
|
$('#hideButton').on('click', function () {
|
|
|
|
|
if (AIFadeFlag) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return false;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
AIFadeFlag = true;
|
|
|
|
|
localStorage.setItem("live2dhidden", "0");
|
|
|
|
|
$('#landlord').fadeOut(200);
|
|
|
|
|
$('#open_live2d').delay(200).fadeIn(200);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
setTimeout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
AIFadeFlag = false;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 300);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#open_live2d').on('click', function () {
|
|
|
|
|
if (AIFadeFlag) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return false;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
AIFadeFlag = true;
|
|
|
|
|
localStorage.setItem("live2dhidden", "1");
|
|
|
|
|
$('#open_live2d').fadeOut(200);
|
|
|
|
|
$('#landlord').delay(200).fadeIn(200);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
setTimeout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
AIFadeFlag = false;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 300);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#youduButton').on('click', function () {
|
|
|
|
|
if ($('#youduButton').hasClass('doudong')) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var typeIs = $('#youduButton').attr('data-type');
|
|
|
|
|
$('#youduButton').removeClass('doudong');
|
|
|
|
|
$('body').removeClass(typeIs);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#youduButton').attr('data-type', '');
|
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var duType = $('#duType').val();
|
|
|
|
|
var duArr = duType.split(",");
|
|
|
|
|
var dataType = duArr[Math.floor(Math.random() * duArr.length)];
|
|
|
|
|
|
|
|
|
|
$('#youduButton').addClass('doudong');
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#youduButton').attr('data-type', dataType);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('body').addClass(dataType);
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-06-19 18:14:53 +08:00
|
|
|
|
if (talkAPI !== "" && typeof EventSource !== 'undefined') {
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#showInfoBtn').on('click', function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var live_statu = $('#live_statu_val').val();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live_statu == "0") {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live_statu_val').val("0");
|
|
|
|
|
$('.live_talk_input_body').fadeOut(500);
|
|
|
|
|
AITalkFlag = false;
|
|
|
|
|
showHitokoto();
|
|
|
|
|
$('#showTalkBtn').show();
|
|
|
|
|
$('#showInfoBtn').hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#showTalkBtn').on('click', function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var live_statu = $('#live_statu_val').val();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live_statu == "1") {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live_statu_val').val("1");
|
|
|
|
|
$('.live_talk_input_body').fadeIn(500);
|
|
|
|
|
AITalkFlag = true;
|
|
|
|
|
$('#showTalkBtn').hide();
|
|
|
|
|
$('#showInfoBtn').show();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-06-19 18:14:53 +08:00
|
|
|
|
$('#live_talk_input_form').on('submit', function (e) {
|
|
|
|
|
e.preventDefault();
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var info_ = $('#AIuserText').val();
|
2024-10-21 18:12:21 +08:00
|
|
|
|
// var userid_ = $('#AIuserName').val();
|
2024-10-21 19:16:17 +08:00
|
|
|
|
let add_id = "";
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if ($('#load_this').prop("checked")) {
|
|
|
|
|
add_id = "&id=" + encodeURIComponent($('#post_id').val());
|
2024-10-21 19:16:17 +08:00
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (info_ == "") {
|
|
|
|
|
showMessage('写点什么吧!', 0);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
showMessage('思考中~', 0);
|
2025-06-19 18:14:53 +08:00
|
|
|
|
showMessage(new EventSource(talkAPI + "?info=" + encodeURIComponent(info_) + add_id));
|
2022-01-24 21:27:29 +08:00
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#showInfoBtn').hide();
|
|
|
|
|
$('#showTalkBtn').hide();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
2025-08-07 20:27:42 +08:00
|
|
|
|
// //获取用户名
|
|
|
|
|
// var live2dUser = sessionStorage.getItem("live2duser");
|
|
|
|
|
// if(live2dUser !== null){
|
|
|
|
|
// $('#AIuserName').val(live2dUser);
|
|
|
|
|
// }
|
|
|
|
|
//获取位置
|
|
|
|
|
var landL = sessionStorage.getItem("historywidth");
|
|
|
|
|
var landB = sessionStorage.getItem("historyheight");
|
|
|
|
|
if (landL == null || landB == null) {
|
|
|
|
|
landL = '5px'
|
|
|
|
|
landB = '0px'
|
|
|
|
|
}
|
|
|
|
|
$('#landlord').css('left', landL + 'px');
|
|
|
|
|
$('#landlord').css('bottom', landB + 'px');
|
|
|
|
|
//移动
|
|
|
|
|
function getEvent() {
|
|
|
|
|
return window.event || arguments.callee.caller.arguments[0];
|
|
|
|
|
}
|
|
|
|
|
var smcc = document.getElementById("landlord");
|
|
|
|
|
var moveX = 0;
|
|
|
|
|
var moveY = 0;
|
|
|
|
|
var moveBottom = 0;
|
|
|
|
|
var moveLeft = 0;
|
|
|
|
|
var moveable = false;
|
|
|
|
|
var docMouseMoveEvent = document.onmousemove;
|
|
|
|
|
var docMouseUpEvent = document.onmouseup;
|
|
|
|
|
smcc.onmousedown = function () {
|
|
|
|
|
var ent = getEvent();
|
|
|
|
|
moveable = true;
|
|
|
|
|
moveX = ent.clientX;
|
|
|
|
|
moveY = ent.clientY;
|
|
|
|
|
var obj = smcc;
|
|
|
|
|
moveBottom = parseInt(obj.style.bottom);
|
|
|
|
|
moveLeft = parseInt(obj.style.left);
|
|
|
|
|
if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
|
|
|
|
|
window.getSelection().removeAllRanges();
|
|
|
|
|
}
|
|
|
|
|
document.onmousemove = function () {
|
|
|
|
|
if (moveable) {
|
|
|
|
|
var ent = getEvent();
|
|
|
|
|
var x = moveLeft + ent.clientX - moveX;
|
|
|
|
|
var y = moveBottom + (moveY - ent.clientY);
|
|
|
|
|
obj.style.left = x + "px";
|
|
|
|
|
obj.style.bottom = y + "px";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.onmouseup = function () {
|
|
|
|
|
if (moveable) {
|
|
|
|
|
var historywidth = obj.style.left;
|
|
|
|
|
var historyheight = obj.style.bottom;
|
|
|
|
|
historywidth = historywidth.replace('px', '');
|
|
|
|
|
historyheight = historyheight.replace('px', '');
|
|
|
|
|
sessionStorage.setItem("historywidth", historywidth);
|
|
|
|
|
sessionStorage.setItem("historyheight", historyheight);
|
|
|
|
|
document.onmousemove = docMouseMoveEvent;
|
|
|
|
|
document.onmouseup = docMouseUpEvent;
|
|
|
|
|
moveable = false;
|
|
|
|
|
moveX = 0;
|
|
|
|
|
moveY = 0;
|
|
|
|
|
moveBottom = 0;
|
|
|
|
|
moveLeft = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-24 21:27:29 +08:00
|
|
|
|
//获取音乐信息初始化
|
|
|
|
|
var bgmListInfo = $('input[name=live2dBGM]');
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (bgmListInfo.length == 0) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#musicButton').hide();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var bgmPlayNow = parseInt($('#live2d_bgm').attr('data-bgm'));
|
|
|
|
|
var bgmPlayTime = 0;
|
|
|
|
|
var live2dBGM_Num = sessionStorage.getItem("live2dBGM_Num");
|
|
|
|
|
var live2dBGM_PlayTime = sessionStorage.getItem("live2dBGM_PlayTime");
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live2dBGM_Num) {
|
|
|
|
|
if (live2dBGM_Num <= $('input[name=live2dBGM]').length - 1) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
bgmPlayNow = parseInt(live2dBGM_Num);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live2dBGM_PlayTime) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
bgmPlayTime = parseInt(live2dBGM_PlayTime);
|
|
|
|
|
}
|
|
|
|
|
var live2dBGMSrc = bgmListInfo.eq(bgmPlayNow).val();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#live2d_bgm').attr('data-bgm', bgmPlayNow);
|
|
|
|
|
$('#live2d_bgm').attr('src', live2dBGMSrc);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].currentTime = bgmPlayTime;
|
|
|
|
|
$('#live2d_bgm')[0].volume = 0.5;
|
|
|
|
|
var live2dBGM_IsPlay = sessionStorage.getItem("live2dBGM_IsPlay");
|
|
|
|
|
var live2dBGM_WindowClose = sessionStorage.getItem("live2dBGM_WindowClose");
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live2dBGM_IsPlay == '0' && live2dBGM_WindowClose == '0') {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].play();
|
|
|
|
|
$('#musicButton').addClass('play');
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sessionStorage.setItem("live2dBGM_WindowClose", '1');
|
|
|
|
|
$('#musicButton').on('click', function () {
|
|
|
|
|
if ($('#musicButton').hasClass('play')) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].pause();
|
|
|
|
|
$('#musicButton').removeClass('play');
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sessionStorage.setItem("live2dBGM_IsPlay", '1');
|
|
|
|
|
} else {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].play();
|
|
|
|
|
$('#musicButton').addClass('play');
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sessionStorage.setItem("live2dBGM_IsPlay", '0');
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
window.onbeforeunload = function () {
|
|
|
|
|
sessionStorage.setItem("live2dBGM_WindowClose", '0');
|
|
|
|
|
if ($('#musicButton').hasClass('play')) {
|
|
|
|
|
sessionStorage.setItem("live2dBGM_IsPlay", '0');
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}
|
|
|
|
|
document.getElementById('live2d_bgm').addEventListener("timeupdate", function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var live2dBgmPlayTimeNow = document.getElementById('live2d_bgm').currentTime;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sessionStorage.setItem("live2dBGM_PlayTime", live2dBgmPlayTimeNow);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
document.getElementById('live2d_bgm').addEventListener("ended", function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var listNow = parseInt($('#live2d_bgm').attr('data-bgm'));
|
2025-05-25 01:33:47 +08:00
|
|
|
|
listNow++;
|
|
|
|
|
if (listNow > $('input[name=live2dBGM]').length - 1) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
listNow = 0;
|
|
|
|
|
}
|
|
|
|
|
var listNewSrc = $('input[name=live2dBGM]').eq(listNow).val();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
sessionStorage.setItem("live2dBGM_Num", listNow);
|
|
|
|
|
$('#live2d_bgm').attr('src', listNewSrc);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].play();
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$('#live2d_bgm').attr('data-bgm', listNow);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
});
|
2025-05-25 01:33:47 +08:00
|
|
|
|
document.getElementById('live2d_bgm').addEventListener("error", function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#live2d_bgm')[0].pause();
|
|
|
|
|
$('#musicButton').removeClass('play');
|
2025-05-25 01:33:47 +08:00
|
|
|
|
showMessage('音乐似乎加载不出来了呢!', 0);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
$(document).ready(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var AIimgSrc = [
|
2025-08-05 20:54:04 +08:00
|
|
|
|
message_Path + "model/histoire/histoire.1024/texture_00.png",
|
|
|
|
|
message_Path + "model/histoire/histoire.1024/texture_01.png",
|
|
|
|
|
message_Path + "model/histoire/histoire.1024/texture_02.png",
|
|
|
|
|
message_Path + "model/histoire/histoire.1024/texture_03.png"
|
2022-01-24 21:27:29 +08:00
|
|
|
|
]
|
|
|
|
|
var images = [];
|
|
|
|
|
var imgLength = AIimgSrc.length;
|
|
|
|
|
var loadingNum = 0;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
for (var i = 0; i < imgLength; i++) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
images[i] = new Image();
|
|
|
|
|
images[i].src = AIimgSrc[i];
|
2025-05-25 01:33:47 +08:00
|
|
|
|
images[i].onload = function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
loadingNum++;
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (loadingNum === imgLength) {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
var live2dhidden = localStorage.getItem("live2dhidden");
|
2025-05-25 01:33:47 +08:00
|
|
|
|
if (live2dhidden === "0") {
|
|
|
|
|
setTimeout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#open_live2d').fadeIn(200);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 1300);
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(function () {
|
2022-01-24 21:27:29 +08:00
|
|
|
|
$('#landlord').fadeIn(200);
|
2025-05-25 01:33:47 +08:00
|
|
|
|
}, 1300);
|
2022-01-24 21:27:29 +08:00
|
|
|
|
}
|
2025-05-25 01:33:47 +08:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
loadlive2d("live2d", message_Path + "model/histoire/model.json");
|
|
|
|
|
}, 1000);
|
|
|
|
|
initLive2d();
|
2022-01-24 21:27:29 +08:00
|
|
|
|
images = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|