* [doc] Update some en docs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/89dfb274 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/89dfb274 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/89dfb274 Branch: refs/heads/master Commit: 89dfb274443fb3b1b92bd39eb40832dd3cfc6695 Parents: f83ae19 Author: Yun Dong <[email protected]> Authored: Wed Feb 22 11:03:32 2017 +0800 Committer: Yun Dong <[email protected]> Committed: Wed Feb 22 11:03:32 2017 +0800 ---------------------------------------------------------------------- doc/source/references/ios-apis.md | 3 +- doc/source/references/modules/globalevent.md | 2 +- doc/themes/weex/source/js/common.js | 43 +++++++++++++++++------ 3 files changed, 34 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/89dfb274/doc/source/references/ios-apis.md ---------------------------------------------------------------------- diff --git a/doc/source/references/ios-apis.md b/doc/source/references/ios-apis.md index e2353ba..f6e7367 100644 --- a/doc/source/references/ios-apis.md +++ b/doc/source/references/ios-apis.md @@ -9,5 +9,4 @@ chapter_title: Common Options # iOS APIs -## Native APIs - +Work in progresss. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/89dfb274/doc/source/references/modules/globalevent.md ---------------------------------------------------------------------- diff --git a/doc/source/references/modules/globalevent.md b/doc/source/references/modules/globalevent.md index 2bb61a8..e102ea6 100644 --- a/doc/source/references/modules/globalevent.md +++ b/doc/source/references/modules/globalevent.md @@ -69,7 +69,7 @@ register global event. var globalEvent = require('@weex-module/globalEvent'); globalEvent.addEventListener("geolocation", function (e) { console.log("get geolocation") - }); +}); ``` ### removeEventListener(String eventName) http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/89dfb274/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 5af57fc..f130c0f 100644 --- a/doc/themes/weex/source/js/common.js +++ b/doc/themes/weex/source/js/common.js @@ -101,9 +101,10 @@ input.addEventListener('input', function (e) { var target = e.target, panel = target.parentElement && target.parentElement.nextElementSibling, - keywords = target.value.trim().split(/[\s\-\ï¼\\/]+/) + value = target.value.trim() + keywords = value.split(/[\s\-\ï¼\\/]+/) - if (target.value.trim() !== '') { + if (value !== '') { var matchingPosts = searchFromJSON(resp.pages, keywords) var html = '' @@ -149,7 +150,7 @@ if(postTitle !== '' && postContent !== '') { keywords.forEach(function(keyword, i) { - var regEx = new RegExp(keyword, "gi") + var regEx = new RegExp('(' + escapeReg(keyword) + ')', 'gi') var indexTitle = -1, indexContent = -1, indexTitle = postTitle.search(regEx), @@ -176,7 +177,7 @@ var matchContent = '...' + postContent .substring(start, end) - .replace(regEx, "<em class=\"search-keyword\">" + keyword + "</em>") + + .replace(regEx, '<em class="search-keyword">$1</em>') + '...' resultStr += matchContent @@ -203,14 +204,14 @@ return matchingResults } - function escapeHtml(string) { + function escapeHtml (string) { var entityMap = { - "&": "&", - "<": "<", - ">": ">", - '"': '"', - "'": ''', - "/": '/' + '&': '&', + '<': '<', + '>': '>', + '': '"', + '': ''', + '/': '/' } return String(string).replace(/[&<>"'\/]/g, function (s) { @@ -218,6 +219,26 @@ }) } + function escapeReg (string) { + var entityMap = { + '.': '\\.', + '^': '\\^', + '$': '\\$', + '*': '\\*', + '?': '\\?', + '|': '\\|', + '(': '\\(', + ')': '\\)', + '[': '\\[', + ']': '\\]', + '+': '\\+' + } + + return String(string).replace(/[\.\^\$\*\?\|\(\)\[\]\+]/g, function (s) { + return entityMap[s]; + }) + } + initSearch() /* * LANDINGPAGE
