/* Js for , Version=1795173276 */
 
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?8ef91a87681fb8372316d3b1e8331688";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
;if(typeof(v) != "object") v = {};v.theme = {"template":"default","theme":"wide","device":"desktop"};;v.lang = {"confirmDelete":"您确定要执行删除操作吗？","deleteing":"删除中","doing":"处理中","loading":"加载中","updating":"更新中...","timeout":"网络超时,请重试","errorThrown":"执行出错：","continueShopping":"继续购物","required":"必填","back":"返回","continue":"继续","bindWechatTip":"发帖功能设置了绑定微信的限制，请先绑定微信会员。","importTip":"只导入主题的风格和样式","fullImportTip":"将会导入测试数据以及替换站点文章、产品等数据"};;
(function()
{
    function initNav()
    {
        if(!window.jQuery) return;
        var $ = window.jQuery;

        $(function()
        {
            var $link = $('#navbar').find('.js-try-for-free');
            if(!$link.length) return;

            var raw = $.cookie('siteContext');
            if(!raw) return;

            var siteContext = {};
            try
            {
                siteContext = JSON.parse(raw) || {};
            }
            catch(e)
            {
                return;
            }

            var siteNumber = parseInt(siteContext.siteNumber, 10);
            if(isNaN(siteNumber)) siteNumber = 0;

            var defaultTryUrl = $link.data('defaultTryUrl');
            var chooseSiteUrl = $link.data('chooseSiteUrl');
            var loginSiteTpl  = $link.data('loginSiteTpl');
            var siteID        = siteContext.siteID || '';
            var userSite      = siteContext.userSite || '';

            if(defaultTryUrl) $link.attr('href', defaultTryUrl);

            if(siteNumber > 1)
            {
                $link.attr('href', chooseSiteUrl);
                return;
            }

            if(siteNumber === 1 && userSite && siteID && loginSiteTpl)
            {
                $link.attr('href', loginSiteTpl.replace('__SITE_ID__', siteID));
            }
        });
    }

    if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initNav);
    else initNav();
})();
;v.pageID = 15;;const demoForm = document.getElementById("application-form");
const demoFormCard = document.getElementById("demo-form-card");

function validateDemoField(field) {
  const input = field.querySelector("input");
  const value = input.value.trim();
  let isValid = true;

  if (!value) {
    isValid = false;
  } else if (input.type === "email") {
    isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
  }

  field.classList.toggle("is-invalid", !isValid);
  return isValid;
}

demoForm.querySelectorAll(".field input").forEach(function (input) {
  input.addEventListener("input", function () {
    validateDemoField(input.closest(".field"));
  });
});

demoForm.addEventListener("submit", function (event) {
  event.preventDefault();

  const fields = Array.from(demoForm.querySelectorAll(".field"));
  const isFormValid = fields.every(validateDemoField);

  if (!isFormValid) {
    const firstInvalidField = demoForm.querySelector(".field.is-invalid input");
    if (firstInvalidField) {
      firstInvalidField.focus();
    }
    return;
  }
});

$.setAjaxForm('#application-form', function(response)
{
    if(response.result == 'success') location.href = '/cn/demo-request-success.html';
    if(response.result == 'fail') {
      $('#application-form .button-primary').popover({container:'body', trigger:'manual', content:response.message, placement: 'right', tipClass: 'popover-danger popover-ajaxform'}).popover('show');
    }
});
;v.pageLayout = "global";;$(document).ready(function()
{
    $('.nav-page-' + v.pageID + ':first').addClass('active');
    $('#navbar li.active').parents('li').addClass('active');

    function basename(str)
    {
        var pos = str.lastIndexOf('/');
        return str.substring(pos + 1,str.length);
    }

    $('.article-content img').click(function(){
        var itemSrc  = $(this).attr('src');
        var itemName = basename(itemSrc).split('&')[0];
        if(typeof(itemName) == 'string')
        {
            $('.files-list .' + itemName).click();
        }
    });
});
var lang = $.cookie('browseLang');
if (!lang) {
  var url = new URL(location.href);
  var isCnPath =
      url.pathname === '/cn' ||
      url.pathname.indexOf('/cn/') === 0;

  lang = isCnPath ? 'zh-cn' : (/^zh/i.test(navigator.language || '') ? 'zh-cn' : 'en');

  $.cookie('browseLang', lang, {
      expires: 365,
      path: ''/'',
      secure: true,
      sameSite: 'lax'
  });

  if (lang === 'en' && isCnPath) {
      // /cn、/cn/XXX -> /、/XXX
      url.pathname = url.pathname.substring(3) || '/';
      location.replace(url.href);
  } else if (lang === 'zh-cn' && !isCnPath) {
      // /、/XXX -> /cn/、/cn/XXX
      url.pathname = '/cn' + url.pathname;
      location.replace(url.href);
  }
}
;
$(document).ready(function()
{
    $('a[data-download=1]').each(function()
    {
        link = window.btoa(window.encodeURIComponent($(this).attr('href')));
        fileName = window.btoa(window.encodeURIComponent($(this).text()));
        $(this).attr('data-toggle', 'modal').attr('href', createLink('misc', 'download', 'link=' + link + '&fileName=' + fileName));
    });
})
