WINDOW_CONTENTS = window.location.href.split("/"); function currentVersion() { if (WINDOW_CONTENTS.includes("$web") && WINDOW_CONTENTS.length > 5) { return WINDOW_CONTENTS[6]; } else { return ""; } } function currentPackage() { if (WINDOW_CONTENTS.includes("$web") && WINDOW_CONTENTS.length > 5) { return WINDOW_CONTENTS[5]; } else { return ""; } } function httpGetAsync(targetUrl, callback) { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText); }; xmlHttp.open("GET", targetUrl, true); // true for asynchronous xmlHttp.send(null); } function showSelectors(selectors) { selectors.forEach(function(item, index) { $(item).show(); }); } function hideSelectors(selectors) { selectors.forEach(function(item, index) { $(item).hide(); }); } function populateOptions(optionSelector, otherSelectors) { if (currentPackage()) { var versionRequestUrl = "https://azuresdkdocs.blob.core.windows.net/$web/" + SELECTED_LANGUAGE + "/" + currentPackage() + "/versioning/versions"; httpGetAsync(versionRequestUrl, function(responseText) { if (responseText) { options = responseText.match(/[^\r\n]+/g) populateVersionDropDown(optionSelector, options); showSelectors(otherSelectors); $(optionSelector).change(function() { targetVersion = $(this).val(); url = WINDOW_CONTENTS.slice(); url[6] = targetVersion; window.location.href = url.join("/"); }); } }); } } function populateVersionDropDown(selector, values){ var select = $(selector) $('option', select).remove() $.each(values, function(index, text) { $('