penguin/AstroJS

Javascript framework for my blog

commit 39f4f086dfe54a62fee4838a45b54f498a82d8ad

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-12-13T09:47:55Z
subjectComment translate line breaks
commit 39f4f086dfe54a62fee4838a45b54f498a82d8ad
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-12-13T09:47:55Z

    Comment translate line breaks
---
 botanjs/src/Astro/Blog/Components/Comment.js | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/botanjs/src/Astro/Blog/Components/Comment.js b/botanjs/src/Astro/Blog/Components/Comment.js
index 953e56e..6ba8463 100644
--- a/botanjs/src/Astro/Blog/Components/Comment.js
+++ b/botanjs/src/Astro/Blog/Components/Comment.js
@@ -425,11 +425,17 @@
 		, hideSubmit = loggedIn
 		? /* Overload */ _hideSubmit
 		: /* Overload */ function ()
-			{
-				_hideSubmit();
-				captcha_wrapper.removeEventListener(captchaKey);
-			}
+		{
+			_hideSubmit();
+			captcha_wrapper.removeEventListener(captchaKey);
+		}
 
+		, __createContentText = function( text )
+		{
+			var e = wrapc( "c_text", text );
+			e.innerHTML = e.innerHTML.replace( /\n/g, "<br />" );
+			return e;
+		}
 
 		, generateCommentStack = function ( rObj, obj )
 		{
@@ -455,11 +461,11 @@
 			// Generate comment stack
 			, c_stack = rObj["comment_id"]
 				// Reply Structure
-				? wrapc("reply", wrapc("c_cont", [ c_ind = wrapc("r_indicator") , wrapc("c_text", rObj.content) , c_info ]))
+				? wrapc("reply", wrapc("c_cont", [ c_ind = wrapc("r_indicator") , __createContentText( rObj.content ) , c_info ]))
 				: wrapc("c_comm",
 					[
 						c_ind = wrapc("c_indicator")
-						, c_cont = wrapc("c_cont", [ cpole = wrapc("cpole") , wrapc("c_text", rObj.content) , c_info ])
+						, c_cont = wrapc("c_cont", [ cpole = wrapc("cpole") , __createContentText( rObj.content ) , c_info ])
 					]
 				)
 			;