Created
March 31, 2021 07:46
-
-
Save qaqland/c1d987c8486ad0637cf49e18be979eea to your computer and use it in GitHub Desktop.
仿tiddlywiki的首页
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let links = document.getElementsByTagName("a") | |
for (let i = 0; i < links.length; i++) { | |
links[i].onclick = change | |
} | |
let makes = document.getElementsByClassName("make") | |
for (let i = 0; i < makes.length; i++) { | |
makes[i].onclick = editor | |
} | |
function change() { | |
let herehref = this.getAttribute("href").slice(1) | |
let heretarget = document.getElementById(herehref) | |
if (heretarget.style.display != "flex") { | |
order() | |
heretarget.style.display = "flex" | |
heretarget.style.order = "0" | |
} | |
} | |
function order() { | |
let articles = document.getElementsByTagName("article") | |
for (let i = 0; i < articles.length; i++) { | |
console.log(articles[i].style.display) | |
if (articles[i].style.display == "") { | |
continue | |
} | |
articles[i].style.order++ | |
console.log(articles[i].style.order) | |
} | |
} | |
function editor() { | |
let content = this.parentNode.parentNode.childNodes[3] | |
// console.log(content) | |
content.contentEditable = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment