From a429d5c0f45390ec807018d0f463c8935dc62116 Mon Sep 17 00:00:00 2001
From: cph <stegben.benjamin@gmail.com>
Date: Fri, 29 Apr 2016 11:48:52 +0800
Subject: [PATCH 1/2] chinese and english mixture word count done

---
 js/editor.js | 15 +++++++++------
 js/utils.js  | 12 ++++++------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/js/editor.js b/js/editor.js
index 1e6af8b..f637a67 100755
--- a/js/editor.js
+++ b/js/editor.js
@@ -105,8 +105,8 @@ ZenPen.editor = (function() {
 
 
 		if ( (event.target.className === "url-input" ||
-		    event.target.classList.contains( "url" ) ||
-		    event.target.parentNode.classList.contains( "ui-inputs" ) ) ) {
+			event.target.classList.contains( "url" ) ||
+			event.target.parentNode.classList.contains( "ui-inputs" ) ) ) {
 
 			currentNodeList = findNodes( selection.focusNode );
 			updateBubbleStates();
@@ -199,7 +199,7 @@ ZenPen.editor = (function() {
 		var selection = window.getSelection();
 
 		// if( selection.containsNode( document.querySelector('b'), false ) ) {
-		// 	nodeNames[ 'B' ] = true;
+		//  nodeNames[ 'B' ] = true;
 		// }
 
 		while ( element.parentNode ) {
@@ -334,7 +334,7 @@ ZenPen.editor = (function() {
 			// Insert HTTP if it doesn't exist.
 			if ( !url.match("^(http|https)://") ) {
 
-				url = "http://" + url;	
+				url = "http://" + url;  
 			} 
 
 			document.execCommand( 'createLink', false, url );
@@ -349,12 +349,15 @@ ZenPen.editor = (function() {
 	function getWordCount() {
 		
 		var text = ZenPen.util.getText( contentField );
-
+		
 		if ( text === "" ) {
 			return 0
 		} else {
-			return text.split(/\s+/).length;
+			var splitWords = text.match(/[^\x00-\xff]|\S+/g)			
+			// console.log(splitWords.length)
+			return splitWords.length;
 		}
+		
 	}
 
 	function onCompositionStart ( event ) {
diff --git a/js/utils.js b/js/utils.js
index 786a941..70cdc3b 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -17,12 +17,12 @@ ZenPen.util = (function() {
 		    var node = el.childNodes[i];
 		    if(node.nodeType != 8) {
 
-			if ( node.nodeType != 1 ) {
-			    // Strip white space.
-			    ret += node.nodeValue;
-			} else {
-			    ret += getText( node );
-			}
+				if ( node.nodeType != 1 ) {
+				    // Strip white space.
+				    ret += node.nodeValue;
+				} else {
+				    ret += getText( node );
+				}
 		    }
 		}
 		return ZenPen.util.trim(ret);

From 7e6191dabd0bd073c7411d4afc1ea9dc20e5888d Mon Sep 17 00:00:00 2001
From: cph <stegben.benjamin@gmail.com>
Date: Fri, 29 Apr 2016 11:53:20 +0800
Subject: [PATCH 2/2] unify indents

---
 js/editor.js | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/js/editor.js b/js/editor.js
index f637a67..e64692d 100755
--- a/js/editor.js
+++ b/js/editor.js
@@ -105,8 +105,8 @@ ZenPen.editor = (function() {
 
 
 		if ( (event.target.className === "url-input" ||
-			event.target.classList.contains( "url" ) ||
-			event.target.parentNode.classList.contains( "ui-inputs" ) ) ) {
+		  event.target.classList.contains( "url" ) ||
+		  event.target.parentNode.classList.contains( "ui-inputs" ) ) ) {
 
 			currentNodeList = findNodes( selection.focusNode );
 			updateBubbleStates();
@@ -199,7 +199,7 @@ ZenPen.editor = (function() {
 		var selection = window.getSelection();
 
 		// if( selection.containsNode( document.querySelector('b'), false ) ) {
-		//  nodeNames[ 'B' ] = true;
+		//	nodeNames[ 'B' ] = true;
 		// }
 
 		while ( element.parentNode ) {
@@ -334,7 +334,7 @@ ZenPen.editor = (function() {
 			// Insert HTTP if it doesn't exist.
 			if ( !url.match("^(http|https)://") ) {
 
-				url = "http://" + url;  
+				url = "http://" + url;
 			} 
 
 			document.execCommand( 'createLink', false, url );
@@ -349,7 +349,6 @@ ZenPen.editor = (function() {
 	function getWordCount() {
 		
 		var text = ZenPen.util.getText( contentField );
-		
 		if ( text === "" ) {
 			return 0
 		} else {
@@ -357,7 +356,6 @@ ZenPen.editor = (function() {
 			// console.log(splitWords.length)
 			return splitWords.length;
 		}
-		
 	}
 
 	function onCompositionStart ( event ) {