Skip to content

Instantly share code, notes, and snippets.

@qaqland
Created March 31, 2021 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qaqland/c1d987c8486ad0637cf49e18be979eea to your computer and use it in GitHub Desktop.
Save qaqland/c1d987c8486ad0637cf49e18be979eea to your computer and use it in GitHub Desktop.
仿tiddlywiki的首页
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