Skip to content

Commit b4021b3

Browse files
azure-sdksima-zhu
andauthored
Sync eng/common directory with azure-sdk-tools for PR 1396 (#16810)
* 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 <[email protected]> Co-authored-by: Sima Zhu <[email protected]>
1 parent ab0393d commit b4021b3

File tree

1 file changed

+29
-13
lines changed
  • eng/common/docgeneration/templates/matthews/styles

1 file changed

+29
-13
lines changed

eng/common/docgeneration/templates/matthews/styles/main.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,33 @@ function httpGetLatestAsync(targetUrl, latestVersions, packageName) {
153153
})
154154
}
155155

156+
function loadedOtherVersions(url, latestVersions, publishedVersions, selector, collapsible, packageName) {
157+
var hasAdded = function (currentVersion) {
158+
return $(publishedVersions).children('li').filter(function() {
159+
return $(this).text() === currentVersion
160+
}).length || $(latestVersions).children('li').filter(function() {
161+
return $(this).text() === currentVersion
162+
}).length
163+
}
164+
httpGetAsync(url, function (responseText) {
165+
if (responseText) {
166+
options = responseText.match(/[^\r\n]+/g)
167+
for (var i in options) {
168+
if (!hasAdded(options[i])) {
169+
$(publishedVersions).append('<li><a href="' + getPackageUrl(SELECTED_LANGUAGE, packageName, options[i]) + '" target="_blank">' + options[i] + '</a></li>')
170+
}
171+
}
172+
}
173+
else {
174+
$(publishedVersions).append('<li>No discovered versions present in blob storage.</li>')
175+
}
176+
$(selector).addClass("loaded")
177+
if ($(publishedVersions).children('li').length < 1) {
178+
$(collapsible).remove()
179+
}
180+
})
181+
}
182+
156183
function populateIndexList(selector, packageName) {
157184
var url = "https://azuresdkdocs.blob.core.windows.net/$web/" + SELECTED_LANGUAGE + "/" + packageName + "/versioning/versions"
158185
var latestGAUrl = "https://azuresdkdocs.blob.core.windows.net/$web/" + SELECTED_LANGUAGE + "/" + packageName + "/versioning/latest-ga"
@@ -170,6 +197,7 @@ function populateIndexList(selector, packageName) {
170197
}
171198
$(latestVersions).after(collapsible)
172199
$(collapsible).after(publishedVersions)
200+
173201
// Add collapsible arrows on versioned docs.
174202
$(collapsible).on('click', function(event) {
175203
event.preventDefault();
@@ -179,19 +207,7 @@ function populateIndexList(selector, packageName) {
179207
$(this).toggleClass('down')
180208
if ($(this).hasClass('down')) {
181209
if (!$(selector).hasClass('loaded')){
182-
httpGetAsync(url, function (responseText) {
183-
if (responseText) {
184-
options = responseText.match(/[^\r\n]+/g)
185-
for (var i in options) {
186-
$(publishedVersions).append('<li><a href="' + getPackageUrl(SELECTED_LANGUAGE, packageName, options[i]) + '" target="_blank">' + options[i] + '</a></li>')
187-
188-
}
189-
}
190-
else {
191-
$(publishedVersions).append('<li>No discovered versions present in blob storage.</li>')
192-
}
193-
$(selector).addClass("loaded")
194-
})
210+
loadedOtherVersions(url, latestVersions, publishedVersions, selector, collapsible, packageName)
195211
}
196212
$(publishedVersions).show()
197213
} else {

0 commit comments

Comments
 (0)