Update tag.html

This commit is contained in:
Meekdai 2023-11-21 16:58:14 +08:00
parent 6e7ca11645
commit e67297b6fd

View File

@ -105,51 +105,53 @@ request.onload=function(){
showList(jsonData); showList(jsonData);
} }
tag=window.location.hash.slice(1)
function showList(jsonData){ function showList(jsonData){
let SideNav=document.getElementsByClassName("SideNav")[0]; let SideNav=document.getElementsByClassName("SideNav")[0];
for(let i=1;i<jsonData.length;i++){ for(let i=1;i<jsonData.length;i++){
let item=document.createElement("a"); if(jsonData["postListJson"][i]['label']==tag || tag==''){
item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between"); let item=document.createElement("a");
item.setAttribute("href",jsonData["postListJson"][i]['postUrl']); item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between");
item.setAttribute("target","_blank"); item.setAttribute("href",jsonData["postListJson"][i]['postUrl']);
item.setAttribute("target","_blank");
let center=document.createElement("div"); let center=document.createElement("div");
center.setAttribute("class","d-flex flex-items-center"); center.setAttribute("class","d-flex flex-items-center");
svg=document.createElementNS('http://www.w3.org/2000/svg','svg'); svg=document.createElementNS('http://www.w3.org/2000/svg','svg');
path=document.createElementNS("http://www.w3.org/2000/svg","path"); path=document.createElementNS("http://www.w3.org/2000/svg","path");
span=document.createElement("span"); span=document.createElement("span");
svg.setAttributeNS(null,"class","SideNav-icon octicon"); svg.setAttributeNS(null,"class","SideNav-icon octicon");
svg.setAttributeNS(null,"style","witdh:16px;height:16px"); svg.setAttributeNS(null,"style","witdh:16px;height:16px");
path.setAttributeNS(null, "d", IconList["post"]); path.setAttributeNS(null, "d", IconList["post"]);
svg.appendChild(path); svg.appendChild(path);
let title=document.createElement("span"); let title=document.createElement("span");
title.setAttribute("class","listTitle"); title.setAttribute("class","listTitle");
title.innerHTML=jsonData["postListJson"][i]['title']; title.innerHTML=jsonData["postListJson"][i]['title'];
center.appendChild(svg); center.appendChild(svg);
center.appendChild(title); center.appendChild(title);
let listLabels=document.createElement("div"); let listLabels=document.createElement("div");
listLabels.setAttribute("class","listLabels"); listLabels.setAttribute("class","listLabels");
let LabelName=document.createElement("span"); let LabelName=document.createElement("span");
LabelName.setAttribute("class","Label"); LabelName.setAttribute("class","Label");
LabelName.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']); LabelName.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']);
LabelName.innerHTML=jsonData["postListJson"][i]['label']; LabelName.innerHTML=jsonData["postListJson"][i]['label'];
listLabels.appendChild(LabelName); listLabels.appendChild(LabelName);
let LabelTime=document.createElement("span"); let LabelTime=document.createElement("span");
LabelTime.setAttribute("class","Label"); LabelTime.setAttribute("class","Label");
LabelTime.setAttribute("style","background-color:"+jsonData["postListJson"][i]['dateLabelColor']); LabelTime.setAttribute("style","background-color:"+jsonData["postListJson"][i]['dateLabelColor']);
LabelTime.innerHTML=jsonData["postListJson"][i]['createdDate']; LabelTime.innerHTML=jsonData["postListJson"][i]['createdDate'];
listLabels.appendChild(LabelTime); listLabels.appendChild(LabelTime);
item.appendChild(center);
item.appendChild(listLabels);
SideNav.appendChild(item)
item.appendChild(center);
item.appendChild(listLabels);
SideNav.appendChild(item);
}
} }
} }
</script> </script>
{% endblock %} {% endblock %}