提交 2dab719f authored 作者: slefrancois's avatar slefrancois

Version switcher construction in ajax to avoid setting html before version info…

Version switcher construction in ajax to avoid setting html before version info is obtained from server
上级 2db4644f
...@@ -6,25 +6,17 @@ ...@@ -6,25 +6,17 @@
var theano_dir = 'theano'; // directory containing theano doc var theano_dir = 'theano'; // directory containing theano doc
// Default theano version: release and development. // Default theano version: release and development.
var versions_dir = {"release": "theano", "dev": "theano_versions/dev"}; var versions_dir = {"release": "theano", "dev": "theano_versions/dev"};
// When doc is run from server
if (url.startsWith('http')) { // If doc is run localy
var root_url = url.substring(0, url.search('/' + theano_dir)) + '/'; if (url.startsWith('file')) {
// Get theano versions from dynamically generated version file on server.
$.getJSON(root_url + 'theano_versions/versions.json', function(data){
$.each(data, function(version, dir) {
versions_dir[version] = dir
});
});
}
// When doc is run localy
else if (url.startsWith('file')) {
theano_dir = 'html'; theano_dir = 'html';
var root_url = url.substring(0, url.search('/' + theano_dir)) + '/';
versions_dir = {"local":"html"}; versions_dir = {"local":"html"};
} }
var root_url = url.substring(0, url.search('/' + theano_dir)) + '/';
// Regular expression to find theano version directory in URL. // Regular expression to find theano version directory in URL.
var version_regex = new RegExp("\\/" + theano_dir + "(_versions\/)*([_a-zA-Z.0-9]*)\\/"); var version_regex = new RegExp("\\/" + theano_dir + "(_versions\\/)?([_a-zA-Z.0-9]*)\\/");
// Get current version // Get current version
var current_version = url.match(version_regex)[0] var current_version = url.match(version_regex)[0]
...@@ -78,8 +70,20 @@ ...@@ -78,8 +70,20 @@
// Get theano version. // Get theano version.
// var current_version = DOCUMENTATION_OPTIONS.VERSION; // var current_version = DOCUMENTATION_OPTIONS.VERSION;
var select = build_select(); // Build default switcher
$('.version_switcher_placeholder').html(select); $('.version_switcher_placeholder').html(build_select());
$('.version_switcher_placeholder select').bind('change', on_switch)
// Check server for other doc versions and update switcher.
if (url.startsWith('http')) {
$.getJSON(root_url + 'theano_versions/versions.json', function(data){
$.each(data, function(version, dir) {
versions_dir[version] = dir;
});
$('.version_switcher_placeholder').html(build_select());
$('.version_switcher_placeholder select').bind('change', on_switch) $('.version_switcher_placeholder select').bind('change', on_switch)
}); });
}
});
})(); })();
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论