添加All标签按钮
This commit is contained in:
parent
ebc61593a0
commit
f1584f9e9e
@ -25,7 +25,7 @@ h1 a:not([href]){color:inherit;text-decoration:none;vertical-align: bottom;font-
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<h1><a>Tag</a></h1>
|
<h1><a href="/tag.html">Tag</a></h1>
|
||||||
<div class="title-right">
|
<div class="title-right">
|
||||||
|
|
||||||
<a href="/"><button id="buttonHome" class="btn btn-invisible circle" title="{{ i18n['home'] }}">
|
<a href="/"><button id="buttonHome" class="btn btn-invisible circle" title="{{ i18n['home'] }}">
|
||||||
@ -83,8 +83,16 @@ request.onload=function(){
|
|||||||
function showList(){
|
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"]){
|
|
||||||
|
|
||||||
|
if(tagList.length==0){
|
||||||
|
let showLabels=document.createElement("button");
|
||||||
|
showLabels.setAttribute("class","Label");
|
||||||
|
showLabels.setAttribute("style","background-color:#000");
|
||||||
|
showLabels.innerHTML="All";
|
||||||
|
showLabels.setAttribute("onclick","javascript:updateShowTag('All');");
|
||||||
|
tagLable.appendChild(showLabels);
|
||||||
|
}
|
||||||
|
for(i in jsonData["postListJson"]){
|
||||||
if(!(tagList.includes(jsonData["postListJson"][i]['label']))){
|
if(!(tagList.includes(jsonData["postListJson"][i]['label']))){
|
||||||
tagList.push(jsonData["postListJson"][i]['label']);
|
tagList.push(jsonData["postListJson"][i]['label']);
|
||||||
let showLabels=document.createElement("button");
|
let showLabels=document.createElement("button");
|
||||||
@ -95,7 +103,6 @@ function showList(){
|
|||||||
tagLable.appendChild(showLabels);
|
tagLable.appendChild(showLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(encodeURI(jsonData["postListJson"][i]['label'])==tag || tag==''){
|
|
||||||
let div=document.createElement("div");
|
let div=document.createElement("div");
|
||||||
div.setAttribute("class","lists "+jsonData["postListJson"][i]['label']);
|
div.setAttribute("class","lists "+jsonData["postListJson"][i]['label']);
|
||||||
let item=document.createElement("a");
|
let item=document.createElement("a");
|
||||||
@ -136,7 +143,6 @@ function showList(){
|
|||||||
item.appendChild(listLabels);
|
item.appendChild(listLabels);
|
||||||
div.appendChild(item);
|
div.appendChild(item);
|
||||||
SideNav.appendChild(div);
|
SideNav.appendChild(div);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,19 +150,22 @@ 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);
|
||||||
setClassDisplay(label);
|
setClassDisplay(label);
|
||||||
console.log("change to "+label);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setClassDisplay(lable) {
|
function setClassDisplay(lable) {
|
||||||
let lists = document.getElementsByClassName("lists");
|
let lists = document.getElementsByClassName("lists");
|
||||||
for(let i = 0; i < lists.length; i++){
|
|
||||||
lists[i].style.display='none';
|
|
||||||
}
|
|
||||||
|
|
||||||
let lables = document.getElementsByClassName(lable);
|
if(lable=="All"){for(let i = 0; i < lists.length; i++){lists[i].style.display='block';}}
|
||||||
for(let i = 0; i < lables.length; i++){
|
else{
|
||||||
lables[i].style.display='block';
|
for(let i = 0; i < lists.length; i++){
|
||||||
|
lists[i].style.display='none';
|
||||||
|
}
|
||||||
|
|
||||||
|
let lables = document.getElementsByClassName(lable);
|
||||||
|
for(let i = 0; i < lables.length; i++){
|
||||||
|
lables[i].style.display='block';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user