|
@@ -1,4 +1,5 @@
|
|
var nodemcu = nodemcu || {};
|
|
var nodemcu = nodemcu || {};
|
|
|
|
+
|
|
(function () {
|
|
(function () {
|
|
'use strict';
|
|
'use strict';
|
|
//var languageCodeToNameMap = {en: 'English', de: 'Deutsch'};
|
|
//var languageCodeToNameMap = {en: 'English', de: 'Deutsch'};
|
|
@@ -112,7 +113,7 @@ var nodemcu = nodemcu || {};
|
|
* replaces the relative path with an absolute path based on the selected branch.
|
|
* replaces the relative path with an absolute path based on the selected branch.
|
|
*/
|
|
*/
|
|
function replaceRelativeLinksWithStaticGitHubUrl() {
|
|
function replaceRelativeLinksWithStaticGitHubUrl() {
|
|
- var relativePath = "../../../..";
|
|
|
|
|
|
+ var relativePath = isOnRtd() ? "../../../.." : "../../..";
|
|
var gitHubPath = "https://github.com/nodemcu/nodemcu-firmware/tree/" + determineSelectedBranch();
|
|
var gitHubPath = "https://github.com/nodemcu/nodemcu-firmware/tree/" + determineSelectedBranch();
|
|
var gitHubLinks = $("a[href^='" + relativePath + "']").each(function (index) {
|
|
var gitHubLinks = $("a[href^='" + relativePath + "']").each(function (index) {
|
|
var url = $(this).attr('href');
|
|
var url = $(this).attr('href');
|
|
@@ -148,7 +149,7 @@ var nodemcu = nodemcu || {};
|
|
*/
|
|
*/
|
|
function determineSelectedLanguageCode() {
|
|
function determineSelectedLanguageCode() {
|
|
var selectedLanguageCode, path = window.location.pathname;
|
|
var selectedLanguageCode, path = window.location.pathname;
|
|
- if (window.location.origin.indexOf('readthedocs') > -1) {
|
|
|
|
|
|
+ if (isOnRtd()) {
|
|
// path is like /en/<branch>/<lang>/build/ -> extract 'lang'
|
|
// path is like /en/<branch>/<lang>/build/ -> extract 'lang'
|
|
// split[0] is an '' because the path starts with the separator
|
|
// split[0] is an '' because the path starts with the separator
|
|
selectedLanguageCode = path.split('/')[3];
|
|
selectedLanguageCode = path.split('/')[3];
|
|
@@ -171,7 +172,7 @@ var nodemcu = nodemcu || {};
|
|
*/
|
|
*/
|
|
function determineSelectedBranch() {
|
|
function determineSelectedBranch() {
|
|
var branch = 'dev', path = window.location.pathname;
|
|
var branch = 'dev', path = window.location.pathname;
|
|
- if (window.location.origin.indexOf('readthedocs') > -1) {
|
|
|
|
|
|
+ if (isOnRtd()) {
|
|
// path is like /en/<branch>/<lang>/build/ -> extract 'lang'
|
|
// path is like /en/<branch>/<lang>/build/ -> extract 'lang'
|
|
// split[0] is an '' because the path starts with the separator
|
|
// split[0] is an '' because the path starts with the separator
|
|
var thirdPathSegment = path.split('/')[2];
|
|
var thirdPathSegment = path.split('/')[2];
|
|
@@ -192,4 +193,8 @@ var nodemcu = nodemcu || {};
|
|
}
|
|
}
|
|
return values;
|
|
return values;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ function isOnRtd() {
|
|
|
|
+ return window.location.origin.indexOf('readthedocs') > -1;
|
|
|
|
+ }
|
|
}());
|
|
}());
|