document.body.on('click', '.widget-list.widget-wikis .wiki-side-title>[type="checkbox"]', function () {
    let id = this.getAttribute('post-id'), title = this.parentElement;
    if (this.disabled) return
    this.disabled = !0
    if (!this.checked) {
        title.classList.remove('checked')
        Doghole.Wiki.rm(id)
        this.disabled = !1
        return
    }
    if (title.parentElement.classList.contains('side-list-item-lock')) {
        setTimeout(function() {
            this.disabled = !1
            this.checked = !1
        }.bind(this))
        return
    }
    Doghole.Wiki.add(id)
    if (Doghole.Elem.siblings(title, 'ul').length) {
        title.classList.add('checked')
        this.disabled = !1
        return
    }
    fetch('/wiki/list/' + id, {method: 'GET'})
    .then(async resp => {
        if (!resp.ok) {
            throw new Error('获取 Wiki 层级失败')
        }
        return resp.text()
    })
    .then(html => {
        title.after(Doghole.Elem.create(html))
        title.classList.add('checked')
    })
    .catch(error => console.error(error))
    .finally(function () {
        this.disabled = !1
    }.bind(this))
    
})