Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1396 (#14324)
Browse files Browse the repository at this point in the history
* 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 <sizhu@microsoft.com>
Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 18, 2021
1 parent 0d0efc2 commit 8a9488f
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions eng/common/docgeneration/templates/matthews/styles/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<li><a href="' + getPackageUrl(SELECTED_LANGUAGE, packageName, options[i]) + '" target="_blank">' + options[i] + '</a></li>')
}
}
}
else {
$(publishedVersions).append('<li>No discovered versions present in blob storage.</li>')
}
$(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"
Expand All @@ -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();
Expand All @@ -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('<li><a href="' + getPackageUrl(SELECTED_LANGUAGE, packageName, options[i]) + '" target="_blank">' + options[i] + '</a></li>')

}
}
else {
$(publishedVersions).append('<li>No discovered versions present in blob storage.</li>')
}
$(selector).addClass("loaded")
})
loadedOtherVersions(url, latestVersions, publishedVersions, selector, collapsible, packageName)
}
$(publishedVersions).show()
} else {
Expand Down

0 comments on commit 8a9488f

Please sign in to comment.