给评论按钮添加Loading动画

This commit is contained in:
呆瓜云 2023-07-31 14:12:23 +08:00
parent 2d86241d39
commit a98cf47a63

View File

@ -47,7 +47,7 @@ h1 {display:flex;}
</h1>
<div id="postBody"></div>
<button class="btn btn-block" type="button" onclick="openComments()" id="cmButton">Comments </button>
<button class="btn btn-block" type="button" onclick="openComments()" id="cmButton"> </button>
<div class="comments" style="display:none;" id="comments"></div>
<div class="footer">Copyright © <span id="year"></span> <a id="footerblogTitle" href=""></a> <p><span id="filingNum"></span><span id="runday"></span>Powered by <a href="https://github.com/Meekdai/Gmeek" target="_blank">Gmeek</a></p></div>
@ -59,8 +59,8 @@ h1 {display:flex;}
var blogBase=%s
var i18nEN=["switch theme","Run "," days","Home"];
var i18nCN=["切换主题","网站运行","天","首页"];
var i18nEN=["switch theme","Run "," days","Home","Comments","Loading"];
var i18nCN=["切换主题","网站运行","天","首页","评论","加载中"];
if(blogBase["i18n"]=="CN"){var i18n=i18nCN;}
else{var i18n=i18nEN;}
@ -78,6 +78,7 @@ document.getElementById("postTitle").innerHTML=blogBase["postTitle"];
document.getElementById("postBody").innerHTML=blogBase["postBody"];
document.getElementById("changeTheme").setAttribute("title",i18n[0]);
document.getElementById("buttonHome").setAttribute("title",i18n[3]);
document.getElementById("cmButton").innerHTML=i18n[4];
if(blogBase["faviconUrl"]!=""){
link=document.createElement("link");
@ -131,6 +132,11 @@ if(blogBase["commentNum"]>0){
function openComments(){
cm=document.getElementById("comments");
cmButton=document.getElementById("cmButton");
cmButton.innerHTML=i18n[5];
span=document.createElement("span");
span.setAttribute("class","AnimatedEllipsis");
cmButton.appendChild(span);
script=document.createElement("script");
script.setAttribute("src","https://utteranc.es/client.js");
script.setAttribute("repo",blogBase["repoName"]);
@ -141,9 +147,17 @@ function openComments(){
script.setAttribute("async","");
cm.appendChild(script);
while(utterancesLoad==0){
utterancesFrame=document.getElementsByClassName("utterances-frame")[0];
if (utterancesFrame.attachEvent){
utterancesFrame.attachEvent("onload", function(){utterancesLoad=1;});
}
else {
utterancesFrame.onload = function(){utterancesLoad=1;};
}
}
cmButton.style.display="none";
cm.style.display="block";
utterancesLoad=1;
}
</script>