var preUrl = "" var hostRoot = "" var asyncDone = false; var sdkList = [ { "name" : "bk7236", "lang" : [ "zh-cn" ], "version" : [ "latest" ] }, { "name" : "bk7258", "lang" : [ "zh-cn" ], "version" : [ "latest" ] } ] jQuery(function() { var origin = window.location.origin; if (origin.indexOf("file://") == -1) { SdkVersionStartup(); } else { autoFillVersionInfoForLocalShow(); buildMultiVersionSelector(); setPageStyle(); } setFeedBackItem(); }); function SdkVersionStartup() { var url = "/arminodoc/bk_idk/version.json"; var request = new XMLHttpRequest(); request.open("get", url); request.send(null); request.onload = function () { if (request.status == 200) { var json = JSON.parse(request.responseText); sdkList = json; } else { autoFillVersionInfoForLocalShow(); } buildMultiVersionSelector(); setPageStyle(); } } function autoFillVersionInfoForLocalShow() { // auto change version to current version var urlList = window.location.pathname.split('/'); if (urlList.length <= 3) { console.log("url error: " + curUrl); return; } let version = null; for (let index = 0; index < urlList.length; index++) { if (urlList[index] == "zh_CN" || urlList[index] == "en") { version = urlList[index + 1]; break; } } if (version !== null) { for(let i = 0; i < sdkList.length; i++) { sdkList[i].version = [version] } } } function buildMultiVersionSelector() { var curUrl = window.location.pathname; console.log("Current URL: " + curUrl) var urlList = curUrl.split('/'); if (urlList.length <= 3) { console.log("url error: " + curUrl); return; } var target = urlList[1]; var language = urlList[2] || "zh-cn"; var version = urlList[3]; var index; for (index = 0; index < urlList.length; index++) { if (urlList[index] == "zh_CN" || urlList[index] == "en") { language = urlList[index]; target = urlList[index - 1]; version = urlList[index + 1]; break; } } if (urlList.length > 3) { preUrl = "" for (var i = 1; i < index - 1; i++) { preUrl += urlList[i] + "/" } } hostRoot = "/" + preUrl + target + "/" + language + "/" + version console.log("Index: " + index + " Name: " + target + " Language: " + language + " Version: " + version) console.log("Url: " + hostRoot) var searchUrl = $("#rtd-search-form").attr('action'); var versionPage = `
`;
$(".wy-breadcrumbs-aside").append(stylePage);
var mode = localStorage.getItem('mode') || "light";
setPageMode(mode);
$("#styleIcon").bind('click', function()
{
var mode = $("#styleIcon").attr('mode');
if(mode == "light")
{
mode = "dark";
}
else
{
mode = "light";
}
setPageMode(mode);
});
var styleSet = localStorage.getItem('styleSet') || "false";
setPageWidth(styleSet);
$("#modeIcon").bind('click', function()
{
var styleSet = $("#modeIcon").attr('styleSet');
if(styleSet == "false")
{
styleSet = "true";
}
else
{
styleSet = "false";
}
setPageWidth(styleSet);
});
}
function setPageMode(mode)
{
if(mode == "light")
{
$("").attr({ rel: "stylesheet", type: "text/css", href: hostRoot + "/_static/css/light.css" }).appendTo("head");
$("#styleIcon").attr('src', hostRoot + '/_static/dark.png')
$("#styleIcon").attr('mode', 'light');
localStorage.setItem('mode', 'light');
}
else
{
$("").attr({ rel: "stylesheet", type: "text/css", href: hostRoot + "/_static/css/dark.css" }).appendTo("head");
$("#styleIcon").attr('src', hostRoot + '/_static/light.png')
$("#styleIcon").attr('mode', 'dark');
localStorage.setItem('mode', 'dark');
}
}
function setPageWidth(styleSet)
{
if(styleSet == "false")
{
$("#modeIcon").attr('src', hostRoot + '/_static/open.png')
$("#modeIcon").attr('styleSet', 'false');
$(".wy-nav-content").attr('style', 'max-width:888px');
localStorage.setItem('styleSet', 'false');
}
else
{
$("#modeIcon").attr('src', hostRoot + '/_static/close.png')
$("#modeIcon").attr('styleSet', 'true');
$(".wy-nav-content").attr('style', 'max-width:none');
localStorage.setItem('styleSet', 'true');
}
}
function setFeedBackItem()
{
if ($("#doc-feedback").length > 0) {
const versionNum = encodeURIComponent($("#version-id").val());
let title = encodeURIComponent($(document).attr('title'));
let itemDesc = 'provide feedback about this doc';
if (window.location.pathname.includes('zh_CN')) {
itemDesc = '反馈该文档建议';
}
$("#doc-feedback").append('' + itemDesc +'');
}
}