From ebe169bc961bbadec576b60d669284ac2dad17a9 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 18 Feb 2021 11:55:16 -0800 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 1396 (#1695) * Change other version to all versions * Exclude the packages which already show up in latest GA and preview * Update main.js Co-authored-by: Sima Zhu Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> --- .../templates/matthews/styles/main.js | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/eng/common/docgeneration/templates/matthews/styles/main.js b/eng/common/docgeneration/templates/matthews/styles/main.js index 346a94dad..7ab1dd9e2 100644 --- a/eng/common/docgeneration/templates/matthews/styles/main.js +++ b/eng/common/docgeneration/templates/matthews/styles/main.js @@ -153,6 +153,33 @@ function httpGetLatestAsync(targetUrl, latestVersions, packageName) { }) } +function loadedOtherVersions(url, latestVersions, publishedVersions, selector, collapsible, packageName) { + var hasAdded = function (currentVersion) { + return $(publishedVersions).children('li').filter(function() { + return $(this).text() === currentVersion + }).length || $(latestVersions).children('li').filter(function() { + return $(this).text() === currentVersion + }).length + } + httpGetAsync(url, function (responseText) { + if (responseText) { + options = responseText.match(/[^\r\n]+/g) + for (var i in options) { + if (!hasAdded(options[i])) { + $(publishedVersions).append('
  • ' + options[i] + '
  • ') + } + } + } + else { + $(publishedVersions).append('
  • No discovered versions present in blob storage.
  • ') + } + $(selector).addClass("loaded") + if ($(publishedVersions).children('li').length < 1) { + $(collapsible).remove() + } + }) +} + function populateIndexList(selector, packageName) { var url = "https://azuresdkdocs.blob.core.windows.net/$web/" + SELECTED_LANGUAGE + "/" + packageName + "/versioning/versions" var latestGAUrl = "https://azuresdkdocs.blob.core.windows.net/$web/" + SELECTED_LANGUAGE + "/" + packageName + "/versioning/latest-ga" @@ -170,6 +197,7 @@ function populateIndexList(selector, packageName) { } $(latestVersions).after(collapsible) $(collapsible).after(publishedVersions) + // Add collapsible arrows on versioned docs. $(collapsible).on('click', function(event) { event.preventDefault(); @@ -179,19 +207,7 @@ function populateIndexList(selector, packageName) { $(this).toggleClass('down') if ($(this).hasClass('down')) { if (!$(selector).hasClass('loaded')){ - httpGetAsync(url, function (responseText) { - if (responseText) { - options = responseText.match(/[^\r\n]+/g) - for (var i in options) { - $(publishedVersions).append('
  • ' + options[i] + '
  • ') - - } - } - else { - $(publishedVersions).append('
  • No discovered versions present in blob storage.
  • ') - } - $(selector).addClass("loaded") - }) + loadedOtherVersions(url, latestVersions, publishedVersions, selector, collapsible, packageName) } $(publishedVersions).show() } else {