Skip to content

Commit

Permalink
Done with web version switching (Closes #1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Oct 14, 2021
1 parent 6c435ff commit 4e2cd35
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions doc/source/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@
{% block sidebartitle %}
{{ super() }}
<script>
function onMRPTVersionChange() {
var selectBox = document.getElementById("docsVersionSelectBox");
const newVersion = selectBox.options[selectBox.selectedIndex].value;
var curURL = window.location.href;
const lastURLSegment = curURL;
const newURL = window.location.protocol + "//" + window.location.host + "/" +
"reference/" + newVersion + "/" +
window.location.pathname.split("/").pop();
window.location.href = newURL;
}
var req = new XMLHttpRequest();
req.onload = function(){
var versions = JSON.parse(this.responseText);
var versionDiv = document.getElementsByClassName('version')[0];
var curVer = versionDiv.innerHTML.trim();
var s='<select>\n';
var s='<select id="docsVersionSelectBox" onchange="onMRPTVersionChange();">\n';
for(var i = 0; i < versions.length; i++) {
var v = versions[i];
var vstr = v;
Expand All @@ -30,7 +40,7 @@
}
s=s+ '<option value="' +v+'"';
if (curVer==v) {s=s+' selected';}
s=s+'>'+ vstr + '</option>\n';
s=s+'">'+ vstr + '</option>\n';
}
s = s + '</select>\n';
versionDiv.innerHTML = s;
Expand Down

0 comments on commit 4e2cd35

Please sign in to comment.