/* Single source of truth for the documentation version dropdown. * * Consumed by BOTH: * - the legacy Doxygen pages (2.x .. 4.x, 5.0.0-pre): the block below * renders this list into the `#projectnumber` span next to the logo * (needs jQuery, which those pages already load); and * - the new Sphinx (PyData) 5.0 docs: the navbar switcher template reads * `window.OPENCV_DOC_VERSIONS` directly and builds its own '; var current_ver = $("#projectnumber")[0].innerText || versions[0][0]; current_ver = current_ver.trim(); for (i = 0; i < versions.length; i++) { selected = '' if(current_ver === versions[i][0]) selected = ' selected="selected"'; h += ''; } h += ''; $("#projectnumber")[0].innerHTML = h; $("#projectnumber select")[0].addEventListener('change', function() { var v = $(this).children('option:selected').attr('value'); var path = undefined; for (i = 0; i < versions.length; i++) { if(v === versions[i][0]) { path = versions[i][1]; break; } } if (!path) return; // Go straight to the chosen version's index via its site-absolute path, // so switching works from ANY page of ANY version — no fragile attempt to // substitute the current version inside the current URL (which fails on // pages whose path isn't "//...", e.g. the 5.0 C++ API tree). // The S3 *website* endpoint serves "/4.13.0/" as index.html, but the plain // REST endpoint does not, so append index.html explicitly. if (!/\.html?($|[?#])/.test(path)) path = path.replace(/\/+$/, '') + '/index.html'; window.location.href = path; // navigate }); return current_ver; } // Run as soon as possible. On a normal page load this fires on DOMContentLoaded; // but on the already-deployed legacy pages this file is pulled in dynamically // (a loader appended to dynsections.js) and may arrive AFTER DOMContentLoaded // has fired — in which case render immediately instead of waiting for an event // that will never come again. if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", renderDoxygenVersionDropdown); } else { renderDoxygenVersionDropdown(); }