Update tag.html
This commit is contained in:
parent
547d4137de
commit
656c97bc03
@ -78,10 +78,11 @@ 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(window.location.hash.slice(1));
|
showList();
|
||||||
|
setClassDisplay(decodeURI(window.location.hash.slice(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function showList(tag){
|
function showList(){
|
||||||
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"]){
|
||||||
@ -96,55 +97,67 @@ function showList(tag){
|
|||||||
tagLable.appendChild(showLabels);
|
tagLable.appendChild(showLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(encodeURI(jsonData["postListJson"][i]['label'])==tag || tag==''){
|
// if(encodeURI(jsonData["postListJson"][i]['label'])==tag || tag==''){
|
||||||
let item=document.createElement("a");
|
let item=document.createElement("a");
|
||||||
item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between");
|
item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between "+jsonData["postListJson"][i]['label']);
|
||||||
item.setAttribute("href",jsonData["postListJson"][i]['postUrl']);
|
item.setAttribute("href",jsonData["postListJson"][i]['postUrl']);
|
||||||
|
|
||||||
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]['postTitle'];
|
title.innerHTML=jsonData["postListJson"][i]['postTitle'];
|
||||||
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(center);
|
||||||
item.appendChild(listLabels);
|
item.appendChild(listLabels);
|
||||||
SideNav.appendChild(item);
|
SideNav.appendChild(item);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(label);
|
setClassDisplay(label);
|
||||||
console.log("change to "+label);
|
console.log("change to "+label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setClassDisplay(lable) {
|
||||||
|
let SideNav = document.getElementsByClassName("SideNav-item");
|
||||||
|
for(let i = 0; i < SideNav.length; i++){
|
||||||
|
SideNav[i].style.display='none';
|
||||||
|
}
|
||||||
|
|
||||||
|
let lables = document.getElementsByClassName(lable);
|
||||||
|
for(let i = 0; i < lables.length; i++){
|
||||||
|
lables[i].style.display='block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user