Update tag.html

This commit is contained in:
Meekdai 2023-11-21 22:52:13 +08:00
parent 826850ccd8
commit 547d4137de

View File

@ -69,6 +69,7 @@ document.getElementById("{{ blogBase['singeListJson'][num]['postTitle'] }}").set
{%- endfor %} {%- endfor %}
tagList=[]; tagList=[];
jsonData='';
let requestJson="blogBase.json" let requestJson="blogBase.json"
let request=new XMLHttpRequest(); let request=new XMLHttpRequest();
request.open("GET",requestJson); request.open("GET",requestJson);
@ -77,10 +78,10 @@ request.send();
request.onload=function(){ request.onload=function(){
jsonData=JSON.parse(request.response); jsonData=JSON.parse(request.response);
console.log(jsonData); console.log(jsonData);
showList(jsonData,window.location.hash.slice(1)); showList(window.location.hash.slice(1));
} }
function showList(jsonData,tag){ function showList(tag){
let SideNav=document.getElementsByClassName("SideNav")[0]; let SideNav=document.getElementsByClassName("SideNav")[0];
let tagLable=document.getElementById("tagLable"); let tagLable=document.getElementById("tagLable");
for(i in jsonData["postListJson"]){ for(i in jsonData["postListJson"]){
@ -140,9 +141,9 @@ function showList(jsonData,tag){
function updateShowTag(label){ function updateShowTag(label){
if(window.location.hash.slice(1)!=encodeURI(label)){ if(window.location.hash.slice(1)!=encodeURI(label)){
window.location.hash="#"+(label); window.location.hash="#"+(label);
showList(jsonData,label); showList(label);
console.log("change to "+label);
} }
} }
</script> </script>