mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
Update book.toml
This commit is contained in:
parent
67012ca32d
commit
c53e2f84fa
@ -1,6 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var url = window.location.href;
|
var url = window.location.href;
|
||||||
var host = window.location.host;
|
var host = window.location.host;
|
||||||
|
var home_url = window.location.protocol + '//' + window.location.host;
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
en: "/en/",
|
en: "/en/",
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
var link = "";
|
var link = "";
|
||||||
var word = "";
|
var word = "";
|
||||||
|
var home = "Home";
|
||||||
|
|
||||||
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
|
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
|
||||||
link = url.replace(search.en, replaceWith.en);
|
link = url.replace(search.en, replaceWith.en);
|
||||||
@ -22,12 +24,20 @@
|
|||||||
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
|
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
|
||||||
link = url.replace(search.zh_CN, replaceWith.zh_CN);
|
link = url.replace(search.zh_CN, replaceWith.zh_CN);
|
||||||
word = "English";
|
word = "English";
|
||||||
|
home = "首页";
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = '<a href="' + link + '"><i id="print-button" class="fa fa-language"> ' + word + '</i></a>';
|
var home_node = '';
|
||||||
|
if (window.location.protocol == 'http:' || window.location.protocol == 'https:') {
|
||||||
|
home_node = '<a href="' + home_url + '" title="' + home + '" aria-label="' + home + '"><i id="go-back-homepage" class="fa fa-home"></i></a>';
|
||||||
|
}
|
||||||
|
var lang_node = '';
|
||||||
|
if (link != '') {
|
||||||
|
lang_node = '<a href="' + link + '"><i id="change-language" class="fa fa-language"> ' + word + '</i></a>';
|
||||||
|
}
|
||||||
var insertNode = document.getElementsByClassName('right-buttons');
|
var insertNode = document.getElementsByClassName('right-buttons');
|
||||||
if (insertNode.length > 0 && link != "") {
|
if (insertNode.length > 0) {
|
||||||
var html = insertNode[0].innerHTML;
|
var html = insertNode[0].innerHTML;
|
||||||
insertNode[0].innerHTML = html + node;
|
insertNode[0].innerHTML = home_node + html + lang_node;
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
16
language.js
16
language.js
@ -1,6 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var url = window.location.href;
|
var url = window.location.href;
|
||||||
var host = window.location.host;
|
var host = window.location.host;
|
||||||
|
var home_url = window.location.protocol + '//' + window.location.host;
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
en: "/en/",
|
en: "/en/",
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
var link = "";
|
var link = "";
|
||||||
var word = "";
|
var word = "";
|
||||||
|
var home = "Home";
|
||||||
|
|
||||||
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
|
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
|
||||||
link = url.replace(search.en, replaceWith.en);
|
link = url.replace(search.en, replaceWith.en);
|
||||||
@ -22,12 +24,20 @@
|
|||||||
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
|
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
|
||||||
link = url.replace(search.zh_CN, replaceWith.zh_CN);
|
link = url.replace(search.zh_CN, replaceWith.zh_CN);
|
||||||
word = "English";
|
word = "English";
|
||||||
|
home = "首页";
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = '<a href="' + link + '"><i id="print-button" class="fa fa-language"> ' + word + '</i></a>';
|
var home_node = '';
|
||||||
|
if (window.location.protocol == 'http:' || window.location.protocol == 'https:') {
|
||||||
|
home_node = '<a href="' + home_url + '" title="' + home + '" aria-label="' + home + '"><i id="go-back-homepage" class="fa fa-home"></i></a>';
|
||||||
|
}
|
||||||
|
var lang_node = '';
|
||||||
|
if (link != '') {
|
||||||
|
lang_node = '<a href="' + link + '"><i id="change-language" class="fa fa-language"> ' + word + '</i></a>';
|
||||||
|
}
|
||||||
var insertNode = document.getElementsByClassName('right-buttons');
|
var insertNode = document.getElementsByClassName('right-buttons');
|
||||||
if (insertNode.length > 0 && link != "") {
|
if (insertNode.length > 0) {
|
||||||
var html = insertNode[0].innerHTML;
|
var html = insertNode[0].innerHTML;
|
||||||
insertNode[0].innerHTML = html + node;
|
insertNode[0].innerHTML = home_node + html + lang_node;
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user