/** * Advanced Taxonomy Reengineering - SJB Interceptor * Reconstructs flat selects into hierarchies. */ (function() { const reengineerCategories = () => { // Target the category select by name to ignore dynamic IDs const selectNodes = document.querySelectorAll('select[name="categories[]"]'); selectNodes.forEach(selectElement => { if (selectElement.dataset.reengineered === 'true') return; const $select = window.jQuery ? jQuery(selectElement) : null; // 1. Destroy widget to access underlying DOM if ($select && $select.data("ech-multiselect")) { $select.multiselect('destroy'); } const optionsArray = Array.from(selectElement.options); let currentOptGroup = null; optionsArray.forEach(option => { const text = option.text; // 2. Identification and Header Creation if (text.includes('(Do NOT select this one')) { const cleanLabel = text.split(':')[0].trim(); currentOptGroup = document.createElement('optgroup'); currentOptGroup.label = cleanLabel; selectElement.insertBefore(currentOptGroup, option); option.remove(); } // 3. Purge legacy dividers else if (text.includes('---')) { option.remove(); } // 4. Nest valid child categories else if (currentOptGroup && option.value !== "") { currentOptGroup.appendChild(option); } }); selectElement.dataset.reengineered = 'true'; // 5. Re-initialize and Scrub visible widget labels if ($select) { $select.multiselect({ selectedText: "# selected", noneSelectedText: "Categories", header: false, menuHeight: 'auto', buttonWidth: 'auto' }); const widget = $select.multiselect("widget"); if (widget) { widget.find(".ui-multiselect-optgroup a").each(function() { const $header = jQuery(this); const cleanText = $header.text().split(':')[0].replace('(Do NOT select this one', '').trim(); $header.text(cleanText); }); } } }); }; // Delay 300ms to ensure SJB's native scripts have loaded first window.addEventListener('load', () => { setTimeout(reengineerCategories, 300); // Handle dynamic form loads (modals/AJAX) const observer = new MutationObserver(() => reengineerCategories()); observer.observe(document.body, { childList: true, subtree: true }); }); })(); Unlimited Posting Plan Advanced Search Job Alerts Featured Jobs Post a Job Pricing/Plans Post a Resume Sign in Sign up Unlimited Posting Plan Advanced Search Job Alerts Featured Jobs Post a Job Pricing/Plans Post a Resume Back Promeus Inc. Toronto, ON, Canada https://promeus.ca/ Company Description Jobs (0) Load more Email me jobs from Promeus Inc. Your email Email frequency Daily Weekly Monthly