123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- clearInterval(typeof intervalId == 'undefined' ? 0 : intervalId)
- // Copy HTML to clipboard
- document.querySelector('#copyHTML').addEventListener('click', e => {
- let iconContainer = e.currentTarget.querySelector('.icon');
- navigator.clipboard.writeText(document.querySelector('.content-body').innerHTML.trim()).then(
- () => {
- iconContainer.innerHTML = icon('clipboard-check');
- setTimeout(
- () => {
- iconContainer.innerHTML = icon('clipboard');
- },
- 3000
- );
- },
- () => {
- iconContainer.innerHTML = icon('clipboard-x');
- setTimeout(
- () => {
- iconContainer.innerHTML = icon('clipboard');
- },
- 3000
- );
- }
- );
- });
- // Edit Post form
- document.querySelector('#edit').addEventListener('click', event => {
- const endPoint = event.currentTarget.id == 'new' ? '/posts/new' : `/posts/${event.currentTarget.dataset.id}/${event.currentTarget.id}`
- doFetch(endPoint)
- })
- loadScript('https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.5.0/build/highlight.min.js')
- .then(
- async () => {
- if (document.querySelector('.language-nginx')) {
- await loadScript('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/languages/nginx.min.js')
- }
- hljs.highlightAll({ ignoreUnescapedHTML: true })
- }
- )
|