* [doc] auto switch language only on the landing page.

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/83bfe648
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/83bfe648
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/83bfe648

Branch: refs/heads/master
Commit: 83bfe6481d0309b412343fff831a5f25603ee719
Parents: 5529bb1
Author: Yun Dong <[email protected]>
Authored: Wed Mar 1 10:32:03 2017 +0800
Committer: Yun Dong <[email protected]>
Committed: Wed Mar 1 10:32:03 2017 +0800

----------------------------------------------------------------------
 doc/source/cn/guide/index.md                  | 35 ++++++++-
 doc/source/cn/references/modules/websocket.md | 75 ++++++++----------
 doc/source/guide/index.md                     | 34 +++++++-
 doc/source/references/modules/websocket.md    | 91 ++++++++++------------
 doc/themes/weex/languages/cn.yml              |  2 +-
 doc/themes/weex/languages/en.yml              |  2 +-
 doc/themes/weex/layout/_partial/footer.ejs    |  2 +-
 doc/themes/weex/layout/_partial/head.ejs      | 43 ----------
 doc/themes/weex/layout/index.ejs              | 29 ++++++-
 doc/themes/weex/source/css/index.scss         |  4 +-
 doc/themes/weex/source/js/common.js           | 33 ++++----
 11 files changed, 190 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/source/cn/guide/index.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/guide/index.md b/doc/source/cn/guide/index.md
index 1fdc4ce..e2d43e4 100644
--- a/doc/source/cn/guide/index.md
+++ b/doc/source/cn/guide/index.md
@@ -12,7 +12,7 @@ Weex 是一套简单易用的跨平台开发方案,能以 
web 的开发体验
 
 ## Vue 是什么?
 
-Vue.js 是 Evan You 开发的渐进式 JavaScript 
框架,在易用性、灵活性和性能等方面都非常优秀。开发者
能够通过撰写 `*.vue` 文件,基于 `<template>`, `<style>`, `<script>` 
快速构建组件化的 web 应用。
+Vue.js 是 Evan You 开发的渐进式 JavaScript 框架。开发者
能够通过撰写 `*.vue` 文件,基于 `<template>`, `<style>`, `<script>` 
快速构建组件化的 web 应用。
 
 ## Hello World
 
@@ -21,13 +21,44 @@ Vue.js 是 Evan You 开发的渐进式 JavaScript 
框架,在易用性、灵活
 - 为你的手机安装 [Playground 
App](https://alibaba.github.io/weex/download.html),当然,Weex 
是跨平台的框架,你依然可以使用浏览器进行预览,只是这æ 
·ä½ å°±æ— æ³•感受到 native 优秀的体验了。
 - 在新标签页中打开 [Hello 
World](http://dotwe.org/vue/4d5a0471ece3daabd4681bc6d703c4c1) 
例子,点击预览,然后用  Playground 扫码即可。
 
+在这个例子中,我们看到了熟悉的 HTML 语义化标签、CSS æ 
·å¼å’Œ Javascript 代码。这是一个最简单的 Weex 
示例,它在页面中渲染了一个 “Hello 
World”。请注意,这不是一个 H5 页面,而是 native 的。
 
 
![mobile_preview](https://img.alicdn.com/tps/TB1Ymw3OpXXXXcvXpXXXXXXXXXX-500-1013.jpg)
 
-很简单,我们可以看到语法就是我们熟悉的 Vue。你
可以修改这个例子,再次扫码尝试。
+### 发生了什么?
+
+就如示例代码所示:
+
+```html
+<template>
+  <div>
+    <text class="text">{{text}}</text>
+  </div>
+</template>
+
+<style>
+  .text {
+    font-size: 50;
+  }
+</style>
+
+<script>
+  export default {
+    data () {
+      return {
+        text: 'Hello World.'
+      }
+    }
+  }
+</script>
+```
+
+我们暂时不去关心 Weex 的技术细节,仅看大致的代ç 
ç»“构,我们可以看到语法就是我们熟悉的 Vue。你
可以修改这个例子,再次扫码尝试。
 
 ## 搭建开发环境
 
+使用 dotWe 对 Weex 尝鲜是一个不错的选择,但如果你
想更专业的开发 Weex, dotWe 就不怎么够用了。本节会教你
如何搭建本地开发环境进行 Weex 开发。
+
 ### 第一步:安装依赖
 
 Weex 官方提供了 weex-toolkit 的脚手架工具来辅
助开发和调试。首先,你需要 Node.js 和 weex-toolkit。

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/source/cn/references/modules/websocket.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/references/modules/websocket.md 
b/doc/source/cn/references/modules/websocket.md
index 4835e8e..8efaaa6 100644
--- a/doc/source/cn/references/modules/websocket.md
+++ b/doc/source/cn/references/modules/websocket.md
@@ -90,7 +90,7 @@ WebSockets 是一种先进的技术, 这使得在用户的 
H5/iOS/Android 和一
   <scroller>
     <div>
       <div style="background-color: #286090">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
white">websocket</text>
+        <text class="title" style="height: 80 ;padding: 20;color: 
#FFFFFF">websocket</text>
       </div>
       <input
               type="text"
@@ -107,64 +107,54 @@ WebSockets 是一种先进的技术, 
这使得在用户的 H5/iOS/Android 和一
         <text class="button" onclick="{{send}}">send</text>
         <text class="button" onclick="{{close}}">close</text>
       </div>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = send</text>
+      <div style="background-color: #D3D3D3;margin-top: 20">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = send</text>
       </div>
-      <text style="color: black;height: 80px">{{sendinfo}}</text>
-
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onopen</text>
+      <text style="color: #000000;height: 80">{{sendinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onopen</text>
       </div>
-      <text style="color: black;height: 80px">{{onopeninfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onmessage</text>
+      <text style="color: #000000;height: 80">{{onopeninfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onmessage</text>
       </div>
-      <text style="color: black;height: 400px">{{onmessage}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onclose</text>
+      <text style="color: #000000;height: 100">{{onmessage}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onclose</text>
       </div>
-      <text style="color: black;height: 80px">{{oncloseinfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onerror</text>
+      <text style="color: #000000;height: 80">{{oncloseinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onerror</text>
       </div>
-      <text style="color: black;height: 80px">{{onerrorinfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = close</text>
+      <text style="color: #000000;height: 80">{{onerrorinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = close</text>
       </div>
-      <text style="color: black;height: 80px">{{closeinfo}}</text>
-
+      <text style="color: #000000;height: 80">{{closeinfo}}</text>
     </div>
     </div>
   </scroller>
 </template>
-
 <style>
   .input {
-    font-size: 40px;
-    height: 80px;
-    width: 600px;
+    font-size: 40;
+    height: 80;
+    width: 600;
   }
   .button {
-    font-size: 36px;
-    width: 150px;
+    font-size: 36;
+    width: 150;
     color: #41B883;
     text-align: center;
-    padding-top: 25px;
-    padding-bottom: 25px;
-    border-width: 2px;
+    padding-top: 10;
+    padding-bottom: 10;
+    border-width: 2;
     border-style: solid;
-    margin-right: 20px;
+    margin-right: 20;
     border-color: rgb(162, 217, 192);
     background-color: rgba(162, 217, 192, 0.2);
   }
 </style>
-
 <script>
   var websocket = require('@weex-module/webSocket');
   module.exports = {
@@ -184,11 +174,12 @@ WebSockets 是一种先进的技术, 
这使得在用户的 H5/iOS/Android 和一
     },
     methods: {
       connect:function() {
-        websocket.WebSocket('ws://115.29.193.48:8088','');
+        websocket.WebSocket('ws://echo.websocket.org','');
         var self = this;
+        self.onopeninfo = 'connecting...'
         websocket.onopen = function(e)
         {
-          self.onopeninfo = JSON.stringify(e);
+          self.onopeninfo = 'websocket open';
         }
         websocket.onmessage = function(e)
         {
@@ -200,6 +191,7 @@ WebSockets 是一种先进的技术, 这使得在用户的 
H5/iOS/Android 和一
         }
         websocket.onclose = function(e)
         {
+          self.onopeninfo = '';
           self.onerrorinfo = e.code;
         }
       },
@@ -208,7 +200,6 @@ WebSockets 是一种先进的技术, 这使得在用户的 
H5/iOS/Android 和一
         input.blur();
         websocket.send(this.txtInput);
         this.sendinfo = this.txtInput;
-
       },
       oninput: function(event) {
         this.txtInput = event.value;
@@ -221,4 +212,4 @@ WebSockets 是一种先进的技术, 这使得在用户的 
H5/iOS/Android 和一
 </script>
 ```
 
-[Have a try](http://dotwe.org/weex/993f33173a712fecfb61c1c4b03bcb70)
+[Have a try](http://dotwe.org/weex/0256bbfc448f0fdbe8b10ba311c947b4)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/source/guide/index.md
----------------------------------------------------------------------
diff --git a/doc/source/guide/index.md b/doc/source/guide/index.md
index 0abde32..6c11d54 100644
--- a/doc/source/guide/index.md
+++ b/doc/source/guide/index.md
@@ -12,7 +12,7 @@ Weex is a framework for building Mobile cross-platform high 
performance UI. Deve
 
 ## What is Vue?
 
-[Vue.js](https://vuejs.org/) is an excellent progressive JavaScript framework 
written by [Evan You](https://twitter.com/youyuxi) which is very ease and 
flexible to use. Developers can write `*.vue` files with friendly `<template>`, 
`<style>`, `<script>` tags to build componentized web app. Now Weex and Vue has 
supported each other officially. Weex put Vue 2.x as its built-in JS Framework, 
and Vue has already been able to develop native mobile app.
+[Vue.js](https://vuejs.org/) is an excellent progressive JavaScript framework 
written by [Evan You](https://twitter.com/youyuxi). Now Weex and Vue has 
supported each other officially. Weex put Vue 2.x as its built-in JS Framework, 
and Vue has already been able to develop native mobile app.
 
 ## Hello world
 
@@ -21,16 +21,46 @@ The easiest way to try Weex is to use the [Playground 
App](../playground.html) a
 - Install the [Playground App](../playground.html) for your phone.
 - Open [the Hello World 
example](http://dotwe.org/vue/4d5a0471ece3daabd4681bc6d703c4c1) in a new tab, 
click run, and then use the Playground App to scan the QR code.
 
-Nailed it!
+Nailed it! In this case, We can see HTML semantic tags, CSS styles and 
Javascript code. This is one of the simplest Weex examples. It rendered a 
"Hello World" in the page. Please note that this is not a Web page.
 
 
![mobile_preview](https://img.alicdn.com/tps/TB1Ymw3OpXXXXcvXpXXXXXXXXXX-500-1013.jpg)
 
+### What happened?
+
+As shown in the following code:
+
+```html
+<template>
+  <div>
+    <text class="text">{{text}}</text>
+  </div>
+</template>
+
+<style>
+  .text {
+    font-size: 50;
+  }
+</style>
+
+<script>
+  export default {
+    data () {
+      return {
+        text: 'Hello World.'
+      }
+    }
+  }
+</script>
+```
+
 It's too easy,right? Let's focus on the syntax, obviously this is vue.
 
 You can try to modify the Hello World, then generate a new QR code to scan.
 
 ## Set up development environment 
 
+Use dotWe is a good choice, But if you want to develop locally on your own 
machine, you will set up your development environment.
+
 You will need Node.js and the Weex CLi.
 
 You can installing Node using [nvm](https://github.com/creationix/nvm) (Simple 
bash script to manage multiple active node.js versions). Run the following 
commands in a Terminal after installing nvm:

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/source/references/modules/websocket.md
----------------------------------------------------------------------
diff --git a/doc/source/references/modules/websocket.md 
b/doc/source/references/modules/websocket.md
index 7868903..b2752f4 100644
--- a/doc/source/references/modules/websocket.md
+++ b/doc/source/references/modules/websocket.md
@@ -89,81 +89,71 @@ An event listener to be called when an error occurs.
   <scroller>
     <div>
       <div style="background-color: #286090">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
white">websocket</text>
+        <text class="title" style="height: 80 ;padding: 20;color: 
#FFFFFF">websocket</text>
       </div>
       <input
-        type="text"
-        placeholder="please input message to send"
-        class="input"
-        autofocus="false"
-        value=""
-        onchange="onchange"
-        oninput="oninput"
-        id = "input"
+              type="text"
+              placeholder="please input message to send"
+              class="input"
+              autofocus="false"
+              value=""
+              onchange="onchange"
+              oninput="oninput"
+              id = "input"
       />
       <div style="flex-direction: row; justify-content: center;">
         <text class="button" onclick="{{connect}}">connect</text>
         <text class="button" onclick="{{send}}">send</text>
         <text class="button" onclick="{{close}}">close</text>
       </div>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = send</text>
+      <div style="background-color: #D3D3D3;margin-top: 20">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = send</text>
       </div>
-      <text style="color: black;height: 80px">{{sendinfo}}</text>
-
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onopen</text>
+      <text style="color: #000000;height: 80">{{sendinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onopen</text>
       </div>
-      <text style="color: black;height: 80px">{{onopeninfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onmessage</text>
+      <text style="color: #000000;height: 80">{{onopeninfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onmessage</text>
       </div>
-      <text style="color: black;height: 400px">{{onmessage}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onclose</text>
+      <text style="color: #000000;height: 100">{{onmessage}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onclose</text>
       </div>
-      <text style="color: black;height: 80px">{{oncloseinfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = onerror</text>
+      <text style="color: #000000;height: 80">{{oncloseinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = onerror</text>
       </div>
-      <text style="color: black;height: 80px">{{onerrorinfo}}</text>
-
-      <div style="background-color: lightgray">
-        <text class="title" style="height: 80px ;padding: 20px;color: 
black">method = close</text>
+      <text style="color: #000000;height: 80">{{onerrorinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: 
#000000">method = close</text>
       </div>
-      <text style="color: black;height: 80px">{{closeinfo}}</text>
-
+      <text style="color: #000000;height: 80">{{closeinfo}}</text>
     </div>
     </div>
   </scroller>
 </template>
-
 <style>
   .input {
-    font-size: 40px;
-    height: 80px;
-    width: 600px;
+    font-size: 40;
+    height: 80;
+    width: 600;
   }
   .button {
-    font-size: 36px;
-    width: 150px;
+    font-size: 36;
+    width: 150;
     color: #41B883;
     text-align: center;
-    padding-top: 25px;
-    padding-bottom: 25px;
-    border-width: 2px;
+    padding-top: 10;
+    padding-bottom: 10;
+    border-width: 2;
     border-style: solid;
-    margin-right: 20px;
+    margin-right: 20;
     border-color: rgb(162, 217, 192);
     background-color: rgba(162, 217, 192, 0.2);
   }
 </style>
-
 <script>
   var websocket = require('@weex-module/webSocket');
   module.exports = {
@@ -183,11 +173,12 @@ An event listener to be called when an error occurs.
     },
     methods: {
       connect:function() {
-        websocket.WebSocket('ws://115.29.193.48:8088','');
+        websocket.WebSocket('ws://echo.websocket.org','');
         var self = this;
+        self.onopeninfo = 'connecting...'
         websocket.onopen = function(e)
         {
-          self.onopeninfo = JSON.stringify(e);
+          self.onopeninfo = 'websocket open';
         }
         websocket.onmessage = function(e)
         {
@@ -199,6 +190,7 @@ An event listener to be called when an error occurs.
         }
         websocket.onclose = function(e)
         {
+          self.onopeninfo = '';
           self.onerrorinfo = e.code;
         }
       },
@@ -207,7 +199,6 @@ An event listener to be called when an error occurs.
         input.blur();
         websocket.send(this.txtInput);
         this.sendinfo = this.txtInput;
-
       },
       oninput: function(event) {
         this.txtInput = event.value;
@@ -220,4 +211,4 @@ An event listener to be called when an error occurs.
 </script>
 ```
 
-[Have a try](http://dotwe.org/weex/993f33173a712fecfb61c1c4b03bcb70)
+[Have a try](http://dotwe.org/weex/0256bbfc448f0fdbe8b10ba311c947b4)

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/languages/cn.yml
----------------------------------------------------------------------
diff --git a/doc/themes/weex/languages/cn.yml b/doc/themes/weex/languages/cn.yml
index b158e53..67f72e6 100644
--- a/doc/themes/weex/languages/cn.yml
+++ b/doc/themes/weex/languages/cn.yml
@@ -79,7 +79,7 @@ menu:
   advanced: 高阶知识
   baichuan: 阿里百川
   github: GitHub
-  legacy: 旧文档
+  legacy: 旧语法文档
 playground:
   content: Weex Native 运行时实例 & Weex 文件预览工具。
 categories: Categories

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/languages/en.yml
----------------------------------------------------------------------
diff --git a/doc/themes/weex/languages/en.yml b/doc/themes/weex/languages/en.yml
index d5a0015..47ca0ec 100644
--- a/doc/themes/weex/languages/en.yml
+++ b/doc/themes/weex/languages/en.yml
@@ -80,7 +80,7 @@ menu:
   advanced: Advanced
   baichuan: AliBaichuan
   github: GitHub
-  legacy: Legacy
+  legacy: Old Syntax Doc
 playground:
   content: Weex Native Runtime showcase & Weex we file preview.
 categories: Categories

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/layout/_partial/footer.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/_partial/footer.ejs 
b/doc/themes/weex/layout/_partial/footer.ejs
index 8e36aec..80fdc14 100644
--- a/doc/themes/weex/layout/_partial/footer.ejs
+++ b/doc/themes/weex/layout/_partial/footer.ejs
@@ -13,7 +13,7 @@
           <a href="<%= pick_lang('en') %>" data-lang="en">English</a>
         </li>
         <li>
-          <a href="<%= pick_lang('cn') %>" data-lang="cn">中文</a>
+          <a href="<%= pick_lang('cn') %>" data-lang="zh-cn">中文</a>
         </li>
       </ul>
     </div>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/layout/_partial/head.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/_partial/head.ejs 
b/doc/themes/weex/layout/_partial/head.ejs
index f3d428c..e3f7962 100644
--- a/doc/themes/weex/layout/_partial/head.ejs
+++ b/doc/themes/weex/layout/_partial/head.ejs
@@ -21,49 +21,6 @@
   %>
   <title><% if (title){ %><%= title %> | <% } %><%= config.title %></title>
   <meta name="viewport" content="width=device-width, initial-scale=1, 
maximum-scale=1">
-  <script>
-  ;(function(){
-    var currentOrigin = location.origin,
-        currentPathname = location.pathname,
-        currentLang = navigator.language,
-        selectedLang = '';
-
-    if (!currentLang) {
-      currentLang = navigator.browserLanguage;
-    }
-
-    if (window.sessionStorage) {
-      selectedLang = window.sessionStorage.getItem('lang')
-    }
-
-    if (!selectedLang) {
-      if (currentLang.indexOf('zh') >= 0 && currentPathname.indexOf('/cn/') != 
0) {
-        location.href = getUrl('cn', currentOrigin, currentPathname);
-      } else if (currentLang.indexOf('en') >= 0 && 
currentPathname.indexOf('/cn/') == 0) {
-        location.href = getUrl('en', currentOrigin, currentPathname);
-      }
-    }
-
-    function getUrl (lang, origin, path) {
-      if (lang == 'en') {
-        if (path.indexOf('/cn/') == 0) {
-          return origin + path.substr(3)
-        } else {
-          return origin + path
-        }
-      } else {
-        var langPath = '/' + lang + '/'
-        var pathStart = path.indexOf(langPath)
-
-        if (pathStart == 0) {
-          return origin + path
-        } else {
-          return origin + langPath + path.substr(1)
-        }
-      }
-    }
-  })();
-  </script>
   <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, 
fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
   <% if (theme.rss){ %>
     <link rel="alternate" href="<%- theme.rss %>" title="<%= config.title %>" 
type="application/atom+xml">

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/layout/index.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/index.ejs b/doc/themes/weex/layout/index.ejs
index d112ba7..01c964a 100644
--- a/doc/themes/weex/layout/index.ejs
+++ b/doc/themes/weex/layout/index.ejs
@@ -1,3 +1,30 @@
+<script>
+  ;(function(){
+    var currentOrigin = location.origin || 'https://weex-project.io',
+        currentPathname = location.pathname,
+        currentLang = navigator.language || navigator.browserLanguage || 'en',
+        selectedLang = '';
+
+    if (window.localStorage) {
+      selectedLang = window.localStorage.getItem('lang')
+      currentLang = selectedLang ? selectedLang : currentLang
+    }
+
+    if (/zh|cn/i.test(currentLang)) { // Chinese
+      if (currentPathname.indexOf('/cn/') != 0) {
+        location.href = currentOrigin + '/cn/'
+      }
+    } else if (/en/i.test(currentLang)) { // English
+      if (!/^\/$|^\/index/.test(currentPathname)) {
+        location.href = currentOrigin
+      }
+    } else { // Other
+      if (!/^\/$|^\/index/.test(currentPathname)) {
+        location.href = currentOrigin
+      }
+    }
+  })();
+</script>
 <div class="scene header" style="background: #00BDFF;">
   <div class="scene-container">
     <div class="galaxy left">
@@ -206,6 +233,6 @@ var swiper = new Swiper('.swiper-container', {
   loop: false,
   autoplay: false,
   autoplayDisableOnInteraction: false
-})
+});
 </script>
     
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/source/css/index.scss
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/css/index.scss 
b/doc/themes/weex/source/css/index.scss
index a11852c..8eb4e76 100644
--- a/doc/themes/weex/source/css/index.scss
+++ b/doc/themes/weex/source/css/index.scss
@@ -13,12 +13,12 @@
   height: 100%;
   height: calc(100% - 72px);
 
-  &:nth-child(odd) {
+  &:nth-child(even) {
     background: $bg-gray;
     color: $text-blue;
   }
 
-  &:nth-child(even) {
+  &:nth-child(odd) {
     background: $bg-blue; 
     color: $text-white;
   }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83bfe648/doc/themes/weex/source/js/common.js
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/js/common.js 
b/doc/themes/weex/source/js/common.js
index 1eddfc6..70dc2dc 100644
--- a/doc/themes/weex/source/js/common.js
+++ b/doc/themes/weex/source/js/common.js
@@ -73,34 +73,37 @@
   initSidebar()
 
   /**
-   * Pick lang
+   * Switch language
    */
   function initPickLang () {
-    var pick = document.querySelector('.pick-lang')
-    var elements = document.querySelectorAll('.pick-lang a')
+    document.addEventListener('DOMContentLoaded', function (e) {
+      var pick = document.querySelector('.pick-lang')
+      var elements = document.querySelectorAll('.pick-lang a')
 
-    pick.addEventListener('click', function (e) {
-      e.preventDefault()
-      e.stopPropagation()
+      pick.addEventListener('click', function (e) {
+        e.preventDefault()
+        e.stopPropagation()
 
-      var target = e.target;
-      if (pick.contains(target)) {
-        var lang = target.getAttribute('data-lang')
+        var target = e.target;
+        if (pick.contains(target)) {
+          var lang = target.getAttribute('data-lang')
 
-        if (window.sessionStorage) {
-          window.sessionStorage.setItem('lang', lang)
-        }
+          if (window.localStorage) {
+            window.localStorage.setItem('lang', lang)
+          }
 
-        location.href = target.href
-      }
+          location.href = target.href
+        }
+      })
     })
   }
+
   initPickLang()
 
   /**
    *  Search
    */
-  function initSearch() {
+  function initSearch () {
     var form = document.querySelector('.search-form')
     var inputElements = document.querySelectorAll('.search-input')
 

Reply via email to