ClickHouse/docs/_static/custom.js
BayoNet 13d9a4eebe Sources for english documentation switched to Markdown.
Edit page link is fixed too for both language versions of documentation.
2017-12-28 18:13:23 +03:00

39 lines
1.4 KiB
JavaScript

$(function() {
$('a[href="#edit"]').on('click', function(e) {
e.preventDefault();
var pathname = window.location.pathname;
var url;
if (pathname.indexOf('html') >= 0) {
url = pathname.replace('/docs/', 'https://github.com/yandex/ClickHouse/edit/master/docs/').replace('html', 'md');
} else {
if (pathname.indexOf('/single/') >= 0) {
if (pathname.indexOf('ru') >= 0) {
url = 'https://github.com/yandex/ClickHouse/tree/master/docs/ru';
} else {
url = 'https://github.com/yandex/ClickHouse/tree/master/docs/en';
}
} else {
if (pathname.indexOf('ru') >= 0) {
url = 'https://github.com/yandex/ClickHouse/edit/master/docs/ru/index.md';
} else {
url = 'https://github.com/yandex/ClickHouse/edit/master/docs/en/index.md';
}
}
}
if (url) {
var win = window.open(url, '_blank');
win.focus();
}
});
$('a[href="#en"]').on('click', function(e) {
e.preventDefault();
window.location = window.location.toString().replace('/ru/', '/en/');
});
$('a[href="#ru"]').on('click', function(e) {
e.preventDefault();
window.location = window.location.toString().replace('/en/', '/ru/');
});
});