Skip to content

Commit

Permalink
Merge pull request #42 from youranreus/dev3.0
Browse files Browse the repository at this point in the history
version 3.2.5
  • Loading branch information
youranreus authored Nov 21, 2021
2 parents f96da91 + 80af36b commit 2e22006
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 131 deletions.
2 changes: 0 additions & 2 deletions components/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,3 @@
<img src="<?php $this->options->headerBackground(); ?>" alt="<?php $this->options->title(); ?>" id="header-background">
<?php endif; ?>
</header>


2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package G
* @author 季悠然
* @version 3.2.4
* @version 3.2.5
* @link https://季悠然.space
*/

Expand Down
8 changes: 7 additions & 1 deletion libs/G.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,13 @@ public static function analyzeMeme($content)
//@(xx)格式表情
$result = preg_replace('#@\((.*?)\)#', '<img src="https://cdn.jsdelivr.net/gh/youranreus/[email protected]/G/IMG/bq/$1.png" class="bq">', $content);
//mirage格式表情 (原神,小黄脸)
$result = preg_replace('/::(.*?):(.*?)::/', '<img src="https://cdn.jsdelivr.net/gh/youranreus/[email protected]/W/bq/$1/$2.png" class="bq">', $result);
$result = preg_replace('/\:\:(.*?)\:(.*?)\:\:/','<img src="https://cdn.jsdelivr.net/gh/youranreus/[email protected]/W/bq/$1/$2.png" class="bq">',$result);
$result = preg_replace_callback('#\#\((.*?)\)#',function($matches) {
$emotionText = substr(substr($matches[0], 0, -1), 2);
$url = "<img class='bq bq-aru' src='https://cdn.jsdelivr.net/gh/youranreus/R/W/bq/aru/".urlencode($emotionText).".png'/>";
$url = preg_replace('/%/', '', $url);
return $url;
}, $result);
return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion static/css/G.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/css/G.css.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions static/css/G.less
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ a.icp {
display: inline-block !important;
}

.bq-aru {
width: unset;
padding: 0 .3rem;
}

.g-toast {
background: var(--theme-bg-main);
color: @color_3;
Expand Down
8 changes: 8 additions & 0 deletions static/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ a.next {
border: 1px solid rgba(255, 255, 255, 0.08);
}

table {
color: var(--theme-text-main);
}

.page-navigator li a {
border: 1px solid #555;
}
Expand Down Expand Up @@ -149,3 +153,7 @@ a.next {
#sliderbar-photo div {
background: RGBA(0, 0, 0, 0.7);
}

.lightbox-wrap {
background: RGBA(0, 0, 0, 0.99);
}
178 changes: 91 additions & 87 deletions static/js/G.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,11 @@ let autoDarkMode = () => {
* toolbar按钮赋能
*/
let toolbarInit = () => {
document.querySelector('#gototop').onclick = function () {
console.log('yo');
window.scroll({top: 0, left: 0, behavior: 'smooth'});
};
document.querySelector('#darkmode').onclick = darkModeToggle;
document.querySelector("#sidebar-btn").onclick = toggleSidebar;
document.querySelector('#gototop').onclick = function(){
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
};
document.querySelector('#darkmode').onclick = darkModeToggle;
document.querySelector("#sidebar-btn").onclick = toggleSidebar;
};

/**
Expand Down Expand Up @@ -266,72 +265,75 @@ let slideOwO = (id) => {
/**
* ajax评论
*/
let ajaxComment = () => {
let replyTo = '',
commentForm = document.querySelector("#comment_form");
let bindButton = () => {
document.querySelectorAll(".comment-reply a").forEach(reply => {
reply.onclick = function () {
replyTo = reply.parentNode.parentNode.parentNode.parentNode.id;
console.log('回复绑定成功,当前回复id为', replyTo);
return TypechoComment.reply(replyTo, parseInt(replyTo.slice(8)));
};
});
document.querySelectorAll(".cancel-comment-reply a").forEach((cancel) => {
cancel.onclick = () => {
replyTo = '';
console.log('取消绑定,当前回复id重置为', replyTo);
return TypechoComment.cancelReply();
};
});
};
bindButton();

/**
* 发送前的处理
*/
function beforeSendComment() {
closeOwO();
}

/**
* 发送后的处理
* @param {boolean} status
*/
function afterSendComment(status) {
if (status) {
document.getElementById("comments-textarea").value = '';
replyTo = '';
showToast('发送成功');
}
bindButton();
}

commentForm.onsubmit = function () {
commentData = commentForm.serialize();
beforeSendComment();
Ajax.post(commentForm.getAttribute('action'), commentData,
(result) => {
let newComment = document.createElement('div');
newComment.innerHTML = result;
if (newComment.getElementsByTagName('title').length > 0 && newComment.getElementsByTagName('title')[0].innerText === document.title) {
afterSendComment(true);
TypechoComment.cancelReply();
document.querySelector('#comments').removeChild(document.querySelector('.comment-list'));
document.querySelector('#comments').appendChild(newComment.querySelector('.comment-list'));
replyTo = '';
} else {
afterSendComment(false);
showToast('评论失败,' + newComment.querySelector('.container').innerHTML);
}
},
(error) => {
let newComment = document.createElement('div');
newComment.innerHTML = error;
showToast('评论失败,' + newComment.querySelector('.container').innerHTML);
});
return false;
};
let ajaxComment = () =>{
let replyTo = '',
commentForm = document.querySelector("#comment_form");
let bindButton = () => {
document.querySelectorAll(".comment-reply a").forEach(reply=>{
reply.onclick = function() {
replyTo = reply.parentNode.parentNode.parentNode.parentNode.id;
//console.log('回复绑定成功,当前回复id为', replyTo);
return TypechoComment.reply(replyTo, parseInt(replyTo.slice(8)));
};
});
document.querySelectorAll(".cancel-comment-reply a").forEach((cancel) => {
cancel.onclick = () => {
replyTo = '';
//console.log('取消绑定,当前回复id重置为', replyTo);
return TypechoComment.cancelReply();
};
});
};
bindButton();

/**
* 发送前的处理
*/
function beforeSendComment() {
closeOwO();
}

/**
* 发送后的处理
* @param {boolean} status
*/
function afterSendComment(status) {
if (status) {
document.getElementById("comments-textarea").value = '';
replyTo = '';
showToast('发送成功');
}
bindButton();
}

commentForm.onsubmit = function() {
commentData = commentForm.serialize();
beforeSendComment();
Ajax.post(commentForm.getAttribute('action'), commentData)
.then((result)=>{
let newComment = document.createElement('div');
newComment.innerHTML = result;
if(newComment.getElementsByTagName('title').length > 0 && newComment.getElementsByTagName('title')[0].innerText === document.title)
{
afterSendComment(true);
TypechoComment.cancelReply();
document.querySelector('#comments').removeChild(document.querySelector('.comment-list'));
document.querySelector('#comments').appendChild(newComment.querySelector('.comment-list'));
replyTo = '';
}
else
{
afterSendComment(false);
showToast('评论失败,' + newComment.querySelector('.container').innerHTML);
}
})
.catch((error) => {
let newComment = document.createElement('div');
newComment.innerHTML = error;
showToast('评论失败,' + newComment.querySelector('.container').innerHTML);
});
return false;
};
}

/**
Expand Down Expand Up @@ -413,21 +415,23 @@ let doLazyload = () => {
};

let sendLike = () => {
let btn = document.querySelector('#agree-btn');
btn.style.disabled = true;
Ajax.post(btn.dataset.url, 'agree=' + btn.dataset.cid, (res) => {
let re = /\d/;
if (re.test(res)) {
let counter = btn.childNodes[3];
if (parseInt(res) == parseInt(counter.innerHTML))
showToast('已经点过赞咯');
else
showToast('点赞成功');
counter.innerHTML = res;
counter.parentNode.childNodes[1].innerHTML = '😍';
} else
showToast('出了点小问题');
});
let btn = document.querySelector('#agree-btn');
btn.style.disabled = true;
Ajax.post(btn.dataset.url, 'agree='+btn.dataset.cid)
.then((res) => {
let re = /\d/;
if (re.test(res)) {
let counter = btn.childNodes[3];
if(parseInt(res) == parseInt(counter.innerHTML))
showToast('已经点过赞咯');
else
showToast('点赞成功');
counter.innerHTML = res;
counter.parentNode.childNodes[1].innerHTML = '😍';
}
else
showToast('出了点小问题');
});
}

window.onload = function () {
Expand Down
68 changes: 30 additions & 38 deletions static/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,44 +99,36 @@ function expandSection(element) {
}

let Ajax = {
get: function (url, resolve, reject) {
new Promise((rs, rj) => {
let xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304)
rs(xhr.responseText);
else
rj(xhr.responseText);
}
}
xhr.send();
}).then(success => {
resolve(success);
}).catch(error => {
reject(error);
});
get: function(url){
new Promise((rs, rj)=> {
let xhr=new XMLHttpRequest();
xhr.open('GET',url,true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200 || xhr.status==304)
rs(xhr.responseText);
else
rj(xhr.responseText);
}
}
xhr.send();
});
},
post: function (url, data, resolve, reject) {
new Promise((rs, rj) => {
let xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304)
rs(xhr.responseText);
else
rj(xhr.responseText);
}
}
xhr.send(data);
}).then(success => {
resolve(success);
}).catch(error => {
reject(error);
});
post: function(url, data){
return new Promise((rs,rj)=>{
let xhr=new XMLHttpRequest();
xhr.open('POST',url,true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
if (xhr.status == 200 || xhr.status == 304)
rs(xhr.responseText);
else
rj(xhr.responseText);
}
}
xhr.send(data);
});
}
}

Expand Down Expand Up @@ -204,4 +196,4 @@ Object.prototype.serialize = function () {
}
}
return res.join("&");
}
}

0 comments on commit 2e22006

Please sign in to comment.