const hamburgerIcon = ` ` const innersOfCopyDiv = `

Copy

` function formDiv(id) { return `
${innersOfCopyDiv}
` } $(document).ready(async function () { const codeSnippets = $( '.rst-content div[class^=highlight] div[class^=highlight], .rst-content pre.literal-block div[class^=highlight], .rst-content pre.literal-block div[class^=highlight]' ) codeSnippets.each((index, el) => { el.insertAdjacentHTML('beforeend', formDiv(index)) }) const copyButton = $('.copyDiv') copyButton.click(async ({ currentTarget }) => { // we obtain text and copy it const id = currentTarget.dataset.identifier try { await navigator.clipboard.writeText(currentTarget.offsetParent.innerText) } catch (error) { console.log('Copiing text failed, please try again', { error }) } // we edit the copyDiv connected to copied text const divWithNeededId = $(`div[data-identifier='${id}']`) divWithNeededId.addClass('copiedNotifier') divWithNeededId.html('Copied!') setTimeout(() => { divWithNeededId.html(innersOfCopyDiv) divWithNeededId.removeClass('copiedNotifier') }, 2000) }) // we edit the button that is added by readthedocs portal const readTheDocsButton = $('div.rst-versions') const navbar = $('nav[data-toggle=wy-nav-shift]') navbar.append(readTheDocsButton) });