Skip to content

Commit e8eabb3

Browse files
ibuclawdlang-bot
authored andcommitted
listanchors.js: Match both dlang.org and docarchives.dlang.io in version selector
Currently, when you view an archived version of dlang.org site via docarchives.dlang.io, you can (1) only go further back in time, and (2) the master/stable options only refer to the current archived version. This change lays down the foundations to allow going both forwards and backwards between dlang versions, and the master/stable options now point at the main dlang.org site, so you can go from whatever archived version to mainline in one click.
1 parent 16af6a1 commit e8eabb3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

js/listanchors.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,43 @@ function addVersionSelector() {
6666
return {
6767
name: e,
6868
url: "https://docarchives.dlang.io/v" + e + ".0/" + currentRoot + ddocModuleURL,
69-
selected: false,
7069
};
7170
});
7271

73-
var rootURL = location.href.split(/\/(phobos|library|spec)(-prerelease)?/)[0]
7472
var onlineVersions;
7573
if (isSpec) {
7674
onlineVersions = [{
7775
name: "master",
78-
url: rootURL + "/spec/" + ddocModuleURL,
76+
url: "https://dlang.org/spec/" + ddocModuleURL,
7977
}];
8078
} else {
8179
onlineVersions = [{
8280
name: "master",
83-
url: rootURL + "/phobos-prerelease/" + ddocModuleURL,
81+
url: "https://dlang.org/phobos-prerelease/" + ddocModuleURL,
8482
},{
8583
name: "master (ddox)",
86-
url: rootURL + "/library-prerelease/" + ddoxModuleURL,
84+
url: "https://dlang.org/library-prerelease/" + ddoxModuleURL,
8785
},{
8886
name: "stable",
89-
url: rootURL + "/phobos/" + ddocModuleURL,
87+
url: "https://dlang.org/phobos/" + ddocModuleURL,
9088
},{
9189
name: "stable (ddox)",
92-
url: rootURL + "/library/" + ddoxModuleURL,
90+
url: "https://dlang.org/library/" + ddoxModuleURL,
9391
}];
9492
}
9593

9694
// set the current URL as selected
9795
var currentURL = location.href.split(/[#?]/)[0];
98-
onlineVersions.forEach(function(v, i) {
99-
onlineVersions[i].selected = v.url === currentURL;
96+
var versions = onlineVersions.concat(archivedVersions);
97+
versions.forEach(function(v, i) {
98+
versions[i].selected = v.url === currentURL;
10099
});
101100
// Don't show the option chooser if the page hasn't been recognized
102101
// For example, Ddox symbol pages are currently not supported
103-
if (onlineVersions.filter(function(v){return v.selected}).length === 0)
102+
if (versions.filter(function(v){return v.selected}).length === 0)
104103
return;
105104

106105
// build select box of all versions and append to current DOM
107-
var versions = onlineVersions.concat(archivedVersions);
108106
var options = versions.map(function(e, i){
109107
return "<option value='" + i + "'" + (e.selected ? "selected" : "") + ">" + e.name + "</option>";
110108
});

0 commit comments

Comments
 (0)