Files
hexo-theme-butterfly/layout/includes/third-party/chat/knocket.pug
T

34 lines
1.1 KiB
Plaintext

//- Knocket live chat — https://trtc.io/solutions/knocket
script.
(() => {
const id = '#{theme.knocket.identifier}'
if (!id) return
btf.getScript(`https://trtc.io/knocket-sdk/sdk.js?identifier=${id}`).then(() => {
const isChatBtn = !{theme.chat.rightside_button}
const isChatHideShow = !{theme.chat.button_hide_show}
const getWidget = () => document.querySelector('#knocket-widget, [id*="knocket"]')
if (isChatBtn) {
const hide = () => { const w = getWidget(); if (w) w.style.display = 'none' }
const show = () => { const w = getWidget(); if (w) w.style.display = '' }
hide()
window.chatBtnFn = () => {
const w = getWidget()
if (w && w.style.display === 'none') show()
else hide()
}
document.getElementById('chat-btn').style.display = 'block'
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => { const w = getWidget(); if (w) w.style.display = 'none' },
show: () => { const w = getWidget(); if (w) w.style.display = '' }
}
}
})
})()