diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..40d3877
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,10 @@
+
+
+- [ ] 这个 PR 是关于添加Links的
+- [ ] 我在申请之前加上了[贵站](https://mabbs.github.io)友链
+- [ ] 我的网站 **全站启用 HTTPS**
+- [ ] 我的博客满足: **原创文章比例>80%,数量>10** 的要求
+- [ ] 我的网站满足 **站点稳定,不弃坑** 的要求
+- [ ] 我的链接列表不需要客户端渲染
+
+我的网站是:
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8ca0f68..80822de 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,14 +6,14 @@
# Template project: https://gitlab.com/pages/jekyll
# Docs: https://docs.gitlab.com/ee/pages/
-image: ruby:2.6
+image: ruby:2.7
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
before_script:
- - gem install bundler
+ - gem install bundler -v 2.4.22
- bundle install
pages:
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000..5124702
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,16 @@
+# Required
+version: 2
+
+build:
+ os: ubuntu-24.04
+ tools:
+ ruby: "3.3"
+
+ commands:
+ - gem install bundler
+ - bundle install
+ - mkdir Mabbs
+ - curl -L -o Mabbs/README.md https://github.com/Mabbs/Mabbs/raw/main/README.md
+ - bundle exec jekyll build --destination $READTHEDOCS_OUTPUT/html
+ - tar czvf MayxBlog.tgz -C $READTHEDOCS_OUTPUT html
+ - mv MayxBlog.tgz $READTHEDOCS_OUTPUT/html
\ No newline at end of file
diff --git a/404.md b/404.md
index e861b44..6cc9116 100644
--- a/404.md
+++ b/404.md
@@ -2,5 +2,13 @@
layout: default
title: 404 - 找不到页面
---
+
# 找不到页面
你访问的资源 不存在或者可能已经被永久移除。
+
+ 或者看看近期的其他文章?
+
+ {% for post in site.posts limit:10 %}
+ - {{ post.date | date: "%Y/%m/%d" }} - [{{ post.title }}{% if post.layout == "encrypt" %} [加密] {% endif %}]({{ post.url }})
+
+ {% endfor %}
\ No newline at end of file
diff --git a/5b60338bca964816af2f0b76965a1b84.txt b/5b60338bca964816af2f0b76965a1b84.txt
new file mode 100644
index 0000000..a710f75
--- /dev/null
+++ b/5b60338bca964816af2f0b76965a1b84.txt
@@ -0,0 +1 @@
+5b60338bca964816af2f0b76965a1b84
\ No newline at end of file
diff --git a/BingSiteAuth.xml b/BingSiteAuth.xml
deleted file mode 100644
index 5bbf248..0000000
--- a/BingSiteAuth.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 0ADFCE64B3557DC4DC5F2DC224C5FDDD
-
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 6547c92..211c197 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,20 @@
source "https://rubygems.org"
-gem "jekyll", "~> 4.1.0"
+gem "jekyll", "~> 3.9.3"
group :jekyll_plugins do
- gem "jekyll-gist"
- gem "jekyll-coffeescript"
- gem "jekyll-assets"
- gem "jekyll-sitemap"
- gem "jekyll-feed"
+ gem "jekyll-gist", "~> 1.5.0"
+ gem "jekyll-coffeescript", "~> 1.1.1"
+ gem "jekyll-assets", "~> 1.0.0"
+ gem "jekyll-sitemap", "~> 1.4.0"
+ gem "jekyll-feed", "~> 0.15.1"
+ gem "jekyll-include-cache", "~> 0.2.1"
+ gem "jekyll-readme-index", "~> 0.3.0"
+ gem "jekyll-default-layout", "~> 0.1.5"
+ gem "jekyll-titles-from-headings", "~> 0.5.3"
gem "jekyll-theme-minimal"
- gem "jekyll-paginate"
+ gem "jekyll-paginate", "~> 1.1.0"
+ gem "kramdown-parser-gfm", "~> 1.1.0"
+ gem "kramdown", "~> 2.3.2"
+ gem "csv"
+ gem "base64"
+ gem "bigdecimal"
end
diff --git a/Live2dHistoire/README.md b/Live2dHistoire/README.md
index 6cd0553..d1ba4b3 100644
--- a/Live2dHistoire/README.md
+++ b/Live2dHistoire/README.md
@@ -1,4 +1,5 @@
# Live2d的看板娘——伊斯特瓦尔(Histoire)
+[Original Repo](https://github.com/eeg1412/Live2dHistoire)
#### 可用于网页端显示Live2D版的伊斯特瓦尔(Histoire) emlog插件版可以看这里:[传送门](https://www.wikimoe.com/?post=75)
#### 基于[《给博客添加能动的看板娘(Live2D)-将其添加到网页上吧》](https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02)上的源码进行修改。
#### 在原先的基础上加上了如下功能:
@@ -93,9 +94,6 @@ var talkAPI = "";//如果有类似图灵机器人的聊天接口请填写接口
注意路径别弄错了噢 ~
PHP 程序推荐使用主题函数获取绝对路径。
-### 效果预览
-
-
### 模型说明
本插件仅供学习和交流使用,禁止用于商业用途。
diff --git a/Live2dHistoire/demo.html b/Live2dHistoire/demo.html
deleted file mode 100644
index 5846c31..0000000
--- a/Live2dHistoire/demo.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- Live2D!
-
-
-
-
-
-召唤伊斯特瓦尔
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Live2dHistoire/live2d/css/live2d.css b/Live2dHistoire/live2d/css/live2d.css
index 3ce12d2..7154b49 100644
--- a/Live2dHistoire/live2d/css/live2d.css
+++ b/Live2dHistoire/live2d/css/live2d.css
@@ -79,7 +79,7 @@
background-color: rgba(74, 59, 114,0.9);
}
.live_talk_input_name_body{
- width:70px;
+ width:100px;
box-sizing:border-box;
height:24px;
border: 2px solid rgb(223, 179, 241);
diff --git a/Live2dHistoire/live2d/js/message.js b/Live2dHistoire/live2d/js/message.js
index 032fcf6..d1ee819 100644
--- a/Live2dHistoire/live2d/js/message.js
+++ b/Live2dHistoire/live2d/js/message.js
@@ -1,257 +1,270 @@
-var home_Path = document.location.protocol +'//' + window.document.location.hostname +'/';
-
var userAgent = window.navigator.userAgent.toLowerCase();
console.log(userAgent);
-var norunAI = [ "android", "iphone", "ipod", "ipad", "windows phone"];
+var norunAI = ["android", "iphone", "ipod", "ipad", "windows phone"];
var norunFlag = false;
-for(var i=0;i -1){
+for (var i = 0; i < norunAI.length; i++) {
+ if (userAgent.indexOf(norunAI[i]) > -1) {
norunFlag = true;
break;
}
}
-if(!window.WebGLRenderingContext){
+if (!window.WebGLRenderingContext) {
norunFlag = true;
}
-if(!norunFlag){
+if (!norunFlag) {
var hitFlag = false;
var AIFadeFlag = false;
var liveTlakTimer = null;
var sleepTimer_ = null;
var AITalkFlag = false;
var talkNum = 0;
- (function (){
+ // 暴露到全局,供 pjax.js 在页面切换后重新调用
+ window._live2d = { initTips: null, showMessage: null, showHitokoto: null };
+ (function () {
function renderTip(template, context) {
var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g;
return template.replace(tokenReg, function (word, slash1, token, slash2) {
if (slash1 || slash2) {
- return word.replace('\\', '');
+ return word.replace(/\\/g, '');
}
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 '';
+ variable = currentObject[variables[i]];
+ if (variable === undefined || variable === null) return '';
+ currentObject = variable;
}
- return currentObject;
+ return String(currentObject);
});
}
-
+
String.prototype.renderTip = function (context) {
return renderTip(this, context);
};
-
+
var re = /x/;
- re.toString = function() {
+ console.log(re);
+ re.toString = function () {
showMessage('哈哈,你打开了控制台,是想要看看我的秘密吗?', 5000);
return '';
};
-
- $(document).on('copy', function (){
+
+ $(document).on('copy', function () {
showMessage('你都复制了些什么呀,转载要记得加上出处哦~~', 5000);
});
-
- function initTips(){
+
+ // 缓存 message.json 数据,供 PJAX 重绑定使用
+ var tipsData = null;
+
+ function initTips() {
$.ajax({
cache: true,
- url: message_Path+'message.json',
+ url: message_Path + 'message.json',
dataType: "json",
- success: function (result){
- $.each(result.mouseover, function (index, tips){
- $(tips.selector).mouseover(function (){
+ success: function (result) {
+ tipsData = result;
+ // 解绑旧事件(用命名空间避免影响其他绑定)
+ $.each(result.mouseover, function (index, tips) {
+ $(tips.selector).off('mouseover._live2d_tips mouseout._live2d_tips');
+ $(tips.selector).on('mouseover._live2d_tips', function () {
var text = tips.text;
- if(Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1)-1];
- text = text.renderTip({text: $(this).text()});
+ if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
+ text = text.renderTip({ text: $(this).text() });
showMessage(text, 3000);
talkValTimer();
clearInterval(liveTlakTimer);
liveTlakTimer = null;
});
- $(tips.selector).mouseout(function (){
+ $(tips.selector).on('mouseout._live2d_tips', function () {
showHitokoto();
- if(liveTlakTimer == null){
- liveTlakTimer = window.setInterval(function(){
+ if (liveTlakTimer == null) {
+ liveTlakTimer = window.setInterval(function () {
showHitokoto();
- },15000);
+ }, 15000);
};
});
});
- $.each(result.click, function (index, tips){
- $(tips.selector).click(function (){
- if(hitFlag){
+ $.each(result.click, function (index, tips) {
+ $(tips.selector).off('click._live2d_tips');
+ $(tips.selector).on('click._live2d_tips', function () {
+ if (hitFlag) {
return false
}
hitFlag = true;
- setTimeout(function(){
+ setTimeout(function () {
hitFlag = false;
- },8000);
+ }, 8000);
var text = tips.text;
- if(Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1)-1];
- text = text.renderTip({text: $(this).text()});
+ if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
+ text = text.renderTip({ text: $(this).text() });
showMessage(text, 3000);
});
clearInterval(liveTlakTimer);
liveTlakTimer = null;
- if(liveTlakTimer == null){
- liveTlakTimer = window.setInterval(function(){
+ if (liveTlakTimer == null) {
+ liveTlakTimer = window.setInterval(function () {
showHitokoto();
- },15000);
+ }, 15000);
};
});
}
});
}
+ window._live2d.initTips = initTips;
initTips();
-
+
var text;
- if(document.referrer !== '' && document.referrer.split('/')[2] !== window.location.host ){
+ if (document.referrer !== '' && document.referrer.split('/')[2] !== window.location.host) {
var referrer = document.createElement('a');
referrer.href = document.referrer;
- text = '嗨!来自 ' + referrer.hostname + ' 的朋友!';
var domain = referrer.hostname.split('.')[1];
- if (domain == 'baidu') {
- text = '嗨! 来自 百度搜索 的朋友!
欢迎访问「 ' + document.title.split(' | ')[0] + ' 」';
- }else if (domain == 'so') {
- text = '嗨! 来自 360搜索 的朋友!
欢迎访问「 ' + document.title.split(' | ')[0] + ' 」';
- }else if (domain == 'google') {
- text = '嗨! 来自 谷歌搜索 的朋友!
欢迎访问「 ' + document.title.split(' | ')[0] + ' 」';
- }
- }else {
- if (window.location.href == home_Path) { //主页URL判断,需要斜杠结尾
- 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 = '嗨~ 快来逗我玩吧!';
- }
- }else {
- text = '欢迎阅读「 ' + document.title.split(' | ')[0] + ' 」';
+ if (domain == 'baidu' || domain == 'so' || domain == 'google') {
+ var source = domain == 'baidu' ? '百度搜索' : domain == 'so' ? '360搜索' : '谷歌搜索';
+ text = '嗨! 来自 ' + source + ' 的朋友!
欢迎访问「 ' + document.title.split(' | ')[0] + ' 」';
+ } else {
+ text = '嗨!来自 ' + referrer.hostname + ' 的朋友!';
}
+ } else {
+ text = getWelcomeText();
}
showMessage(text, 12000);
})();
-
- liveTlakTimer = setInterval(function(){
+
+ liveTlakTimer = setInterval(function () {
showHitokoto();
- },15000);
-
- function showHitokoto(){
- if(sessionStorage.getItem("Sleepy")!=="1"){
- if(!AITalkFlag){
- $.getJSON('https://v1.hitokoto.cn/',function(result){
+ }, 15000);
+
+ function showHitokoto() {
+ if (sessionStorage.getItem("Sleepy") !== "1") {
+ if (!AITalkFlag) {
+ $.getJSON('https://hitokoto.mayx.eu.org/', function (result) {
talkValTimer();
showMessage(result.hitokoto, 0);
});
}
- }else{
+ } else {
hideMessage(0);
- if(sleepTimer_==null){
- sleepTimer_ = setInterval(function(){
+ if (sleepTimer_ == null) {
+ sleepTimer_ = setInterval(function () {
checkSleep();
- },200);
+ }, 200);
}
console.log(sleepTimer_);
}
}
-
- function checkSleep(){
+ window._live2d.showHitokoto = showHitokoto;
+
+ function checkSleep() {
var sleepStatu = sessionStorage.getItem("Sleepy");
- if(sleepStatu!=='1'){
+ if (sleepStatu !== '1') {
talkValTimer();
showMessage('你回来啦~', 0);
clearInterval(sleepTimer_);
- sleepTimer_= null;
+ sleepTimer_ = null;
}
}
-
- function showMessage(text, timeout){
- if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1];
+
+ function showMessage(text, timeout) {
+ if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1) - 1];
//console.log('showMessage', text);
$('.message').stop();
- $('.message').html(text);
+ if (typeof EventSource !== 'undefined' && text instanceof EventSource) {
+ var outputContainer = $('.message')[0];
+ var eventFlag = false;
+ text.onmessage = function (event) {
+ if (event.data == "[DONE]") {
+ text.close();
+ return;
+ } else {
+ if (!eventFlag) {
+ talkValTimer();
+ outputContainer.textContent = "";
+ eventFlag = true;
+ }
+ var data = JSON.parse(event.data);
+ if (data.response) {
+ outputContainer.textContent += data.response;
+ }
+ }
+ }
+ } else {
+ $('.message').html(text);
+ }
$('.message').fadeTo(200, 1);
//if (timeout === null) timeout = 5000;
//hideMessage(timeout);
}
- function talkValTimer(){
+ window._live2d.showMessage = showMessage;
+ function talkValTimer() {
$('#live_talk').val('1');
}
-
- function hideMessage(timeout){
+
+ function hideMessage(timeout) {
//$('.message').stop().css('opacity',1);
if (timeout === null) timeout = 5000;
$('.message').delay(timeout).fadeTo(200, 0);
}
-
- function initLive2d (){
- $('#hideButton').on('click', function(){
- if(AIFadeFlag){
+
+ function initLive2d() {
+ $("#landlord").mouseenter(function () {
+ $(".live_ico_box").fadeIn();
+ });
+ $("#landlord").mouseleave(function () {
+ $(".live_ico_box").fadeOut();
+ });
+ $('#hideButton').on('click', function () {
+ if (AIFadeFlag) {
return false;
- }else{
+ } else {
AIFadeFlag = true;
localStorage.setItem("live2dhidden", "0");
$('#landlord').fadeOut(200);
$('#open_live2d').delay(200).fadeIn(200);
- setTimeout(function(){
+ setTimeout(function () {
AIFadeFlag = false;
- },300);
+ }, 300);
}
});
- $('#open_live2d').on('click', function(){
- if(AIFadeFlag){
+ $('#open_live2d').on('click', function () {
+ if (AIFadeFlag) {
return false;
- }else{
+ } else {
AIFadeFlag = true;
localStorage.setItem("live2dhidden", "1");
$('#open_live2d').fadeOut(200);
$('#landlord').delay(200).fadeIn(200);
- setTimeout(function(){
+ setTimeout(function () {
AIFadeFlag = false;
- },300);
+ }, 300);
}
});
- $('#youduButton').on('click',function(){
- if($('#youduButton').hasClass('doudong')){
+ $('#youduButton').on('click', function () {
+ if ($('#youduButton').hasClass('doudong')) {
var typeIs = $('#youduButton').attr('data-type');
$('#youduButton').removeClass('doudong');
$('body').removeClass(typeIs);
- $('#youduButton').attr('data-type','');
- }else{
+ $('#youduButton').attr('data-type', '');
+ } else {
var duType = $('#duType').val();
var duArr = duType.split(",");
var dataType = duArr[Math.floor(Math.random() * duArr.length)];
$('#youduButton').addClass('doudong');
- $('#youduButton').attr('data-type',dataType);
+ $('#youduButton').attr('data-type', dataType);
$('body').addClass(dataType);
}
});
- if(talkAPI!==""){
- $('#showInfoBtn').on('click',function(){
+ if (talkAPI !== "" && typeof EventSource !== 'undefined') {
+ $('#showInfoBtn').on('click', function () {
var live_statu = $('#live_statu_val').val();
- if(live_statu=="0"){
+ if (live_statu == "0") {
return
- }else{
+ } else {
$('#live_statu_val').val("0");
$('.live_talk_input_body').fadeOut(500);
AITalkFlag = false;
@@ -260,139 +273,53 @@ if(!norunFlag){
$('#showInfoBtn').hide();
}
});
- $('#showTalkBtn').on('click',function(){
+ $('#showTalkBtn').on('click', function () {
var live_statu = $('#live_statu_val').val();
- if(live_statu=="1"){
+ if (live_statu == "1") {
return
- }else{
+ } else {
$('#live_statu_val').val("1");
$('.live_talk_input_body').fadeIn(500);
AITalkFlag = true;
$('#showTalkBtn').hide();
$('#showInfoBtn').show();
-
+
}
});
- $('#talk_send').on('click',function(){
+ $('#live_talk_input_form').on('submit', function (e) {
+ e.preventDefault();
var info_ = $('#AIuserText').val();
- var userid_ = $('#AIuserName').val();
- if(info_ == "" ){
- showMessage('写点什么吧!',0);
- return;
+ // var userid_ = $('#AIuserName').val();
+ let add_id = "";
+ if ($('#load_this').prop("checked")) {
+ add_id = "&id=" + encodeURIComponent($('#post_id').val());
}
- if(userid_ == ""){
- showMessage('聊之前请告诉我你的名字吧!',0);
+ if (info_ == "") {
+ showMessage('写点什么吧!', 0);
return;
}
showMessage('思考中~', 0);
- $.ajax({
- type: 'POST',
- url: talkAPI,
- data: {
- "info":info_,
- "userid":userid_
- },
- success: function(res) {
- if(res.code !== 100000){
- talkValTimer();
- showMessage('似乎有什么错误,请和站长联系!',0);
- }else{
- talkValTimer();
- showMessage(res.text,0);
- }
- console.log(res);
- $('#AIuserText').val("");
- sessionStorage.setItem("live2duser", userid_);
- }
- });
+ showMessage(new EventSource(talkAPI + "?info=" + encodeURIComponent(info_) + add_id));
});
- }else{
+ } else {
$('#showInfoBtn').hide();
$('#showTalkBtn').hide();
-
- }
- //获取音乐信息初始化
- var bgmListInfo = $('input[name=live2dBGM]');
- if(bgmListInfo.length == 0){
- $('#musicButton').hide();
- }else{
- 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");
- if(live2dBGM_Num){
- if(live2dBGM_Num<=$('input[name=live2dBGM]').length-1){
- bgmPlayNow = parseInt(live2dBGM_Num);
- }
- }
- if(live2dBGM_PlayTime){
- bgmPlayTime = parseInt(live2dBGM_PlayTime);
- }
- var live2dBGMSrc = bgmListInfo.eq(bgmPlayNow).val();
- $('#live2d_bgm').attr('data-bgm',bgmPlayNow);
- $('#live2d_bgm').attr('src',live2dBGMSrc);
- $('#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");
- if(live2dBGM_IsPlay == '0' && live2dBGM_WindowClose == '0'){
- $('#live2d_bgm')[0].play();
- $('#musicButton').addClass('play');
- }
- sessionStorage.setItem("live2dBGM_WindowClose" , '1');
- $('#musicButton').on('click',function(){
- if($('#musicButton').hasClass('play')){
- $('#live2d_bgm')[0].pause();
- $('#musicButton').removeClass('play');
- sessionStorage.setItem("live2dBGM_IsPlay",'1');
- }else{
- $('#live2d_bgm')[0].play();
- $('#musicButton').addClass('play');
- sessionStorage.setItem("live2dBGM_IsPlay",'0');
- }
- });
- window.onbeforeunload = function(){
- sessionStorage.setItem("live2dBGM_WindowClose" , '0');
- if($('#musicButton').hasClass('play')){
- sessionStorage.setItem("live2dBGM_IsPlay",'0');
- }
- }
- document.getElementById('live2d_bgm').addEventListener("timeupdate", function(){
- var live2dBgmPlayTimeNow = document.getElementById('live2d_bgm').currentTime;
- sessionStorage.setItem("live2dBGM_PlayTime" , live2dBgmPlayTimeNow );
- });
- document.getElementById('live2d_bgm').addEventListener("ended", function(){
- var listNow = parseInt($('#live2d_bgm').attr('data-bgm'));
- listNow ++ ;
- if(listNow > $('input[name=live2dBGM]').length-1){
- listNow = 0;
- }
- var listNewSrc = $('input[name=live2dBGM]').eq(listNow).val();
- sessionStorage.setItem("live2dBGM_Num",listNow);
- $('#live2d_bgm').attr('src',listNewSrc);
- $('#live2d_bgm')[0].play();
- $('#live2d_bgm').attr('data-bgm',listNow);
- });
- document.getElementById('live2d_bgm').addEventListener("error", function(){
- $('#live2d_bgm')[0].pause();
- $('#musicButton').removeClass('play');
- showMessage('音乐似乎加载不出来了呢!',0);
- });
- }
- //获取用户名
- var live2dUser = sessionStorage.getItem("live2duser");
- if(live2dUser !== null){
- $('#AIuserName').val(live2dUser);
+
}
+ // //获取用户名
+ // 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){
+ if (landL == null || landB == null) {
landL = '5px'
landB = '0px'
}
- $('#landlord').css('left',landL+'px');
- $('#landlord').css('bottom',landB + 'px');
+ $('#landlord').css('left', landL + 'px');
+ $('#landlord').css('bottom', landB + 'px');
//移动
function getEvent() {
return window.event || arguments.callee.caller.arguments[0];
@@ -405,7 +332,7 @@ if(!norunFlag){
var moveable = false;
var docMouseMoveEvent = document.onmousemove;
var docMouseUpEvent = document.onmouseup;
- smcc.onmousedown = function(){
+ smcc.onmousedown = function () {
var ent = getEvent();
moveable = true;
moveX = ent.clientX;
@@ -413,20 +340,20 @@ if(!norunFlag){
var obj = smcc;
moveBottom = parseInt(obj.style.bottom);
moveLeft = parseInt(obj.style.left);
- if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
+ if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
window.getSelection().removeAllRanges();
- }
- document.onmousemove = function(){
- if(moveable){
+ }
+ document.onmousemove = function () {
+ if (moveable) {
var ent = getEvent();
var x = moveLeft + ent.clientX - moveX;
- var y = moveBottom + (moveY - ent.clientY);
+ var y = moveBottom + (moveY - ent.clientY);
obj.style.left = x + "px";
obj.style.bottom = y + "px";
}
};
- document.onmouseup = function(){
- if(moveable){
+ document.onmouseup = function () {
+ if (moveable) {
var historywidth = obj.style.left;
var historyheight = obj.style.bottom;
historywidth = historywidth.replace('px', '');
@@ -435,7 +362,7 @@ if(!norunFlag){
sessionStorage.setItem("historyheight", historyheight);
document.onmousemove = docMouseMoveEvent;
document.onmouseup = docMouseUpEvent;
- moveable = false;
+ moveable = false;
moveX = 0;
moveY = 0;
moveBottom = 0;
@@ -443,37 +370,131 @@ if(!norunFlag){
}
};
};
+ //获取音乐信息初始化
+ var $bgm = $('#live2d_bgm');
+
+ // 音乐按钮点击事件(幂等,使用命名空间避免重复绑定)
+ $('#musicButton').off('click._bgm').on('click._bgm', function () {
+ if ($('#musicButton').hasClass('play')) {
+ $bgm[0].pause();
+ $('#musicButton').removeClass('play');
+ sessionStorage.setItem("live2dBGM_IsPlay", '1');
+ } else {
+ $bgm[0].play();
+ $('#musicButton').addClass('play');
+ sessionStorage.setItem("live2dBGM_IsPlay", '0');
+ }
+ });
+
+ // BGM 事件监听(仅绑定一次,使用标志位避免重复)
+ if (!window._live2d._bgmEventsBound) {
+ $bgm[0].addEventListener("timeupdate", function () {
+ sessionStorage.setItem("live2dBGM_PlayTime", $bgm[0].currentTime);
+ });
+ $bgm[0].addEventListener("ended", function () {
+ var listNow = parseInt($bgm.attr('data-bgm'));
+ listNow++;
+ var inputs = $('input[name=live2dBGM]');
+ if (inputs.length === 0) return;
+ if (listNow > inputs.length - 1) {
+ listNow = 0;
+ }
+ var listNewSrc = inputs.eq(listNow).val();
+ if (!listNewSrc) return;
+ sessionStorage.setItem("live2dBGM_Num", listNow);
+ $bgm.attr('src', listNewSrc);
+ $bgm[0].play();
+ $bgm.attr('data-bgm', listNow);
+ });
+ $bgm[0].addEventListener("error", function () {
+ $bgm[0].pause();
+ $('#musicButton').removeClass('play');
+ showMessage('音乐似乎加载不出来了呢!', 0);
+ });
+ window.onbeforeunload = function () {
+ sessionStorage.setItem("live2dBGM_WindowClose", '0');
+ if ($('#musicButton').hasClass('play')) {
+ sessionStorage.setItem("live2dBGM_IsPlay", '0');
+ }
+ };
+ window._live2d._bgmEventsBound = true;
+ }
+
+ // 初始化 BGM(根据当前页面是否有 BGM 输入)
+ if (typeof window._live2d.initBGM === 'function') {
+ window._live2d.initBGM();
+ }
}
- $(document).ready(function() {
+
+ // 暴露 BGM 初始化函数,供 PJAX 重初始化时调用
+ window._live2d.initBGM = function() {
+ var bgmListInfo = $('input[name=live2dBGM]');
+ var $bgm = $('#live2d_bgm');
+ if (bgmListInfo.length === 0) {
+ $('#musicButton').hide();
+ if ($bgm.length) $bgm[0].pause();
+ return;
+ }
+ var bgmPlayNow = parseInt($bgm.attr('data-bgm')) || 0;
+ var bgmPlayTime = 0;
+ var live2dBGM_Num = sessionStorage.getItem("live2dBGM_Num");
+ var live2dBGM_PlayTime = sessionStorage.getItem("live2dBGM_PlayTime");
+ if (live2dBGM_Num) {
+ if (parseInt(live2dBGM_Num) <= bgmListInfo.length - 1) {
+ bgmPlayNow = parseInt(live2dBGM_Num);
+ }
+ }
+ if (live2dBGM_PlayTime) {
+ bgmPlayTime = parseFloat(live2dBGM_PlayTime);
+ }
+ var newSrc = bgmListInfo.eq(bgmPlayNow).val();
+ $bgm.attr('data-bgm', bgmPlayNow);
+ if ($bgm.attr('src') !== newSrc) {
+ $bgm[0].pause();
+ $bgm.attr('src', newSrc);
+ $bgm[0].currentTime = bgmPlayTime;
+ }
+ $bgm[0].volume = 0.5;
+ var live2dBGM_IsPlay = sessionStorage.getItem("live2dBGM_IsPlay");
+ var live2dBGM_WindowClose = sessionStorage.getItem("live2dBGM_WindowClose");
+ if (live2dBGM_IsPlay == '0' && live2dBGM_WindowClose == '0') {
+ $bgm[0].play();
+ $('#musicButton').addClass('play');
+ }
+ sessionStorage.setItem("live2dBGM_WindowClose", '1');
+ $('#musicButton').show();
+ };
+
+ $(document).ready(function () {
var AIimgSrc = [
- home_Path + message_Path + "model/histoire/histoire.1024/texture_00.png",
- home_Path + message_Path + "model/histoire/histoire.1024/texture_01.png",
- home_Path + message_Path + "model/histoire/histoire.1024/texture_02.png",
- home_Path + message_Path + "model/histoire/histoire.1024/texture_03.png"
+ 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"
]
var images = [];
var imgLength = AIimgSrc.length;
var loadingNum = 0;
- for(var i=0;i