-
Notifications
You must be signed in to change notification settings - Fork 1
/
policy.html
93 lines (80 loc) · 2.71 KB
/
policy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
layout: default
title: Policy
permalink: /policy/
---
<!-- <section style="height: 100px;"></section>
<div class="en post-container">
{% capture about_en %}{% include policy/en.md %}{% endcapture %}
{{ about_en | markdownify }}
</div> -->
<section style="height: 50px;"></section>
<!-- Language Selector -->
<!-- Chinese Version -->
<div class="zh post-container">
{% capture policy_zh %}{% include policy/zh.md %}{% endcapture %}
{{ policy_zh | markdownify }}
</div>
<!-- English Version -->
<div class="en post-container">
{% capture policy_en %}{% include policy/en.md %}{% endcapture %}
{{ policy_en | markdownify }}
</div>
<select class="sel-lang" onchange= "onLanChange(this.options[this.options.selectedIndex].value)">
<option value="0" selected> 简体中文</option>
<option value="1"> English </option>
</select>
<section style="height: 50px;"></section>
<script type="text/javascript">
// get nodes
var $zh = document.querySelector(".zh");
var $en = document.querySelector(".en");
var $select = document.querySelector("select");
// bind hashchange event
// Changes at v1.7.2: change the language flag from hash-basing to in-memory basing
// due to its confliction with catalog anchors.
// window.addEventListener('hashchange', _render);
// handle render
function _render(_hash){
var _hash = _hash || window.location.hash;
// en
if(_hash == "#zh"){
// $select.selectedIndex = 1;
// $en.style.display = "block";
// $en.classList.add("active");
// $zh.style.display = "none";
// $zh.classList.remove("active");
$select.selectedIndex = 0;
$zh.style.display = "block";
$zh.classList.add("active");
$en.style.display = "none";
$en.classList.remove("active");
// zh by default
}else{
// not trigger onChange, otherwise cause a loop call.
// $select.selectedIndex = 0;
// $zh.style.display = "block";
// $zh.classList.add("active");
// $en.style.display = "none";
// $en.classList.remove("active");
$select.selectedIndex = 1;
$en.style.display = "block";
$en.classList.add("active");
$zh.style.display = "none";
$zh.classList.remove("active");
}
// interop with catalog
if ("{{ page.catalog }}") generateCatalog(".catalog-body");
}
// handle select change
function onLanChange(index){
if(index == 0){
_hash = "#zh"
}else{
_hash = "#en"
}
_render(_hash)
}
// init
_render();
</script>