Server IP : 192.158.238.246 / Your IP : 3.148.192.220 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/jenniferflocom/www/wp-content/plugins/code-snippets/js/services/settings/ |
Upload File : |
const selectTab = (tabsWrapper: Element, tab: Element, section: string) => { // Swap the active tab class from the previously active tab to the current one. tabsWrapper.querySelector('.nav-tab-active')?.classList.remove('nav-tab-active') tab.classList.add('nav-tab-active') // Update the current active tab attribute so that only the active tab is displayed. tabsWrapper.closest('.wrap')?.setAttribute('data-active-tab', section) } // Refresh the editor preview if we're viewing the editor section. const refreshEditorPreview = (section: string) => { if ('editor' === section) { window.code_snippets_editor_preview?.codemirror.refresh() } } // Update the http referer value so that any redirections lead back to this tab. const updateHttpReferer = (section: string) => { const httpReferer = document.querySelector<HTMLInputElement>('input[name=_wp_http_referer]') if (!httpReferer) { console.error('could not find http referer') return } const newReferer = httpReferer.value.replace(/(?<base>[&?]section=)[^&]+/, `$1${section}`) httpReferer.value = newReferer + (newReferer === httpReferer.value ? `§ion=${section}` : '') } export const handleSettingsTabs = () => { const tabsWrapper = document.getElementById('settings-sections-tabs') if (!tabsWrapper) { console.error('Could not find snippets tabs') return } const tabs = tabsWrapper.querySelectorAll('.nav-tab') for (const tab of tabs) { tab.addEventListener('click', event => { event.preventDefault() const section = tab.getAttribute('data-section') if (section) { selectTab(tabsWrapper, tab, section) refreshEditorPreview(section) updateHttpReferer(section) } }) } }