Added ShowHide-Button in case of CW.
This commit is contained in:
27
index.html
27
index.html
@@ -14,7 +14,7 @@
|
||||
|
||||
<main id="comments">
|
||||
<link rel="stylesheet" href="fontawesome/css/all.css">
|
||||
<link rel="stylesheet" href="style.css?v=1.2">
|
||||
<link rel="stylesheet" href="style.css?v=1.21">
|
||||
|
||||
|
||||
</main>
|
||||
@@ -93,8 +93,11 @@
|
||||
if(obj.spoiler_text.length > 0){
|
||||
const myCW = document.createElement('summary');
|
||||
const myButton = document.createElement('button');
|
||||
myButton.textContent = "+";
|
||||
myButton.addEventListener("click", showHide);
|
||||
myButton.textContent = "\u{1F648}";
|
||||
myCW.textContent = obj.spoiler_text;
|
||||
myButton.classList.toggle("show");
|
||||
|
||||
myHeader.appendChild(myCW);
|
||||
myHeader.appendChild(myButton);
|
||||
|
||||
@@ -109,6 +112,9 @@
|
||||
|
||||
const mySection = document.createElement('section');
|
||||
mySection.innerHTML = `${obj['content']}`;
|
||||
if(obj.spoiler_text.length > 0){
|
||||
mySection.style.display="none";
|
||||
}
|
||||
item.appendChild(mySection);
|
||||
}
|
||||
|
||||
@@ -144,7 +150,22 @@
|
||||
}
|
||||
|
||||
buildCommentTree("107735248507147283");
|
||||
// buildCommentTree("107724981153178707");
|
||||
// buildCommentTree("107724981153178707");
|
||||
|
||||
function showHide(){
|
||||
button = event.srcElement;
|
||||
article = button.parentNode.parentNode;
|
||||
section = article.querySelector('section');
|
||||
|
||||
if( section.style.display == "none" ){
|
||||
section.style.display = "block";
|
||||
button.classList.toggle("hide");
|
||||
}
|
||||
else {
|
||||
section.style.display = "none";
|
||||
button.classList.toggle("show");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user