From d97fbe723f8e5c239be4b5b5b883c85ffed47241 Mon Sep 17 00:00:00 2001 From: Aaran Xu Date: Tue, 11 May 2021 22:41:38 +0800 Subject: [PATCH] Update src/title-page.md --- english/book.toml | 2 +- english/language.js | 74 --------------------------------------------- language.js | 9 +++--- src/title-page.md | 4 +++ 4 files changed, 9 insertions(+), 80 deletions(-) delete mode 100644 english/language.js diff --git a/english/book.toml b/english/book.toml index 1c1d787..cc249d4 100644 --- a/english/book.toml +++ b/english/book.toml @@ -4,5 +4,5 @@ author = "Steve Klabnik and Carol Nichols, with Contributions from the Rust Comm [output.html] additional-css = ["ferris.css", "theme/2018-edition.css"] -additional-js = ["ferris.js", "language.js"] +additional-js = ["ferris.js"] git-repository-url = "https://github.com/rust-lang/book" diff --git a/english/language.js b/english/language.js deleted file mode 100644 index 9fa197d..0000000 --- a/english/language.js +++ /dev/null @@ -1,74 +0,0 @@ -(function () { - var url = window.location.href; - var host = window.location.host; - var home_url = window.location.protocol + '//' + window.location.host; - - var search = { - en: "/en/", - zh_CN: "/zh-CN/" - } - - var replaceWith = { - en: "/zh-CN/", - zh_CN: "/en/" - } - - console.log("hheheeh"); - - var link = ""; - var word = ""; - var home = "Home"; - - var edit_url = "https://github.com/rust-lang-cn" - var github_id = document.getElementById("git-repository-button"); - if (github_id != null && github_id.parentNode.href != undefined) { - edit_url = github_id.parentNode.href; - var repo_name = edit_url.split('/').pop(); - var url_repo_name = repo_name.slice(0, -3); - - if (url.indexOf(url_repo_name) > -1) { - var html_file = url.split(url_repo_name).pop(); - } else if (url.indexOf(":3000") > -1) { - var html_file = url.split(":3000").pop(); - } else { - var html_file = '/'; - } - - - if (html_file == '/') { - edit_url += '/tree/master/src' - } else { - var md_len = html_file.indexOf('.html'); - if (md_len > -1) { - var md_file = html_file.substring(0, md_len) + '.md'; - edit_url += '/blob/master/src' + md_file; - } - } - } - - var edit_node = ''; - - if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) { - link = url.replace(search.en, replaceWith.en); - word = "简体中文"; - edit_node = ""; - } 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); - word = "English"; - home = "首页"; - } - - var home_node = ''; - if (window.location.protocol == 'http:' || window.location.protocol == 'https:') { - home_node = ''; - } - var lang_node = ''; - if (link != '') { - lang_node = ' ' + word + ''; - } - var insertNode = document.getElementsByClassName('right-buttons'); - if (insertNode.length > 0) { - var html = insertNode[0].innerHTML; - insertNode[0].innerHTML = home_node + html + edit_node + lang_node; - } -})() diff --git a/language.js b/language.js index 9fa197d..694372d 100644 --- a/language.js +++ b/language.js @@ -13,8 +13,6 @@ zh_CN: "/en/" } - console.log("hheheeh"); - var link = ""; var word = ""; var home = "Home"; @@ -34,9 +32,10 @@ var html_file = '/'; } - - if (html_file == '/') { - edit_url += '/tree/master/src' + if (typeof default_homepage_md !== 'undefined') { + edit_url += '/blob/master/src/' + default_homepage_md; + } else if (html_file == '/') { + edit_url += '/tree/master/src'; } else { var md_len = html_file.indexOf('.html'); if (md_len > -1) { diff --git a/src/title-page.md b/src/title-page.md index 205515f..074bb3f 100644 --- a/src/title-page.md +++ b/src/title-page.md @@ -35,3 +35,7 @@ HTML 格式可从 [https://rustwiki.org/zh-CN/book/](https://rustwiki.org/zh-CN/ [install]: ch01-01-installation.html [editions]: appendix-05-editions.html [nsprust]: https://nostarch.com/rust + +