penguin/AstroJS

Javascript framework for my blog

commit 5d2029dd544971dcb97c3a1ec544ddd7235ab36c

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-05-25T04:13:24Z
subjectArticleContent should display article title
commit 5d2029dd544971dcb97c3a1ec544ddd7235ab36c
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-05-25T04:13:24Z

    ArticleContent should display article title
---
 .../src/Astro/Blog/AstroEdit/SmartInput/_this.js   |  4 +--
 .../Visualizer/Snippet/ArticleContent.css          |  7 +++++
 .../AstroEdit/Visualizer/Snippet/ArticleContent.js | 33 +++++++++++++++++++---
 .../src/Astro/Blog/AstroEdit/Visualizer/_this.js   |  6 ++--
 botanjs/src/Astro/Blog/Components/Comment.js       |  2 +-
 5 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
index 4aabb63..9a669d0 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
@@ -178,12 +178,12 @@
 			{
 				if( incoming )
 				{
-					IDOMElement( Dand.wrap() ).lootChildren( __stage[1] );
+					IDOMElement( __stage[1] ).clear();
 
 					var ThisCands = ModLevels.Cands().Get();
 					if( ThisCands.length )
 					{
-						IDOMElement( __stage[1] ).lootChildren( Dand.wrape( ThisCands ) );
+						IDOMElement( __stage[1] ).loot( Dand.wrape( ThisCands ) );
 					}
 				}
 
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.css b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.css
new file mode 100644
index 0000000..c2dafa0
--- /dev/null
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.css
@@ -0,0 +1,7 @@
+.v_boundary[data-type="ArticleContent"] {
+	color: #999;
+}
+
+.v_boundary[data-type="ArticleContent"] span.info  {
+	color: #f15a24;
+}
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.js
index 310d024..c086258 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/ArticleContent.js
@@ -23,6 +23,8 @@
 	var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
 	var compileProp = ns[ NS_INVOKE ]( "compileProp" );
 
+	var postData = __import( "System.Net.postData" );
+
 	/** @type {_AstConf_.AstroEdit} */
 	var config = null;
 
@@ -72,26 +74,33 @@
 				id = this.id.value;
 			}
 
+			var ACInfo = [ "ArticleContent[ ", Dand.wrap( "span", null, "info", id ), " ]" ];
 			if ( submitted && id )
 			{
 				// Visualize component
 				if (!stage)
 				{
 					temp =  Dand.wrapne( "span"
-						, "ArticleContent[" + id + "]"
+						, ACInfo
 						, new DataKey( "value", id )
 					);
 
 					insertSnippet(
-						j = snippetWrap( "ArticleContent", temp, false, "span" )
+						j = snippetWrap(
+							"ArticleContent"
+							, temp
+							, false, "span"
+						)
 						, !!override
 					);
 				}
 				else
 				{
-					stage.firstChild.textContent = "ArticleContent[" + id + "]";
+					var stg = IDOMElement( stage );
 
-					IDOMElement( stage ).setAttribute( new DataKey( "value", id ) );
+					stg.clear();
+					stg.loot( Dand.wrape( ACInfo ) );
+					stg.setAttribute( new DataKey( "value", id ) );
 				}
 
 				i = {
@@ -99,6 +108,22 @@
 					, _stage: temp
 				};
 
+				// Get title of this article
+				postData(
+					config.paths.get_article
+					, { article_id: id }
+
+					/** @param {_AstJson_.AJaxGetArticle} */
+					, function( e )
+					{
+						ACInfo[1].firstChild.textContent = e.entry.title;
+					}
+					, function()
+					{
+						ACInfo[1].firstChild.textContent = "ERROR";
+					} );
+
+
 				// Set context menu
 				createContext( i, j, handler );
 			}
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
index ab2eb3f..0e85f6c 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
@@ -272,8 +272,8 @@
 				// innerText does not work in firefox:(
 				temp = Dand.wrape( raw.substr( lastOffset, offset - lastOffset ) );
 				// innerHTML will escape html entities, now replace linebreaks to br
-				temp.innerHTML = temp.innerHTML.replace(/[\r\n]/g, "<br>");
-				IDOMElement( contentDiv ).lootChildren( temp );
+				temp.innerHTML = temp.innerHTML.replace( /[\r\n]/g, "<br>" );
+				IDOMElement( contentDiv ).loot( temp );
 			}
 
 			lastOffset = offset + match.length;
@@ -477,7 +477,7 @@
 				temp = Dand.wrape( raw.substr( lastOffset, raw.length - lastOffset ) );
 				// innerHTML will escape html entities, now replace linebreaks to br
 				temp.innerHTML = temp.innerHTML.replace( /[\r\n]/g, "<br>" );
-				IDOMElement( contentDiv ).lootChildren( temp );
+				IDOMElement( contentDiv ).loot( temp );
 			}
 			temp = null;
 			raw = null;
diff --git a/botanjs/src/Astro/Blog/Components/Comment.js b/botanjs/src/Astro/Blog/Components/Comment.js
index cc1bd1e..dffd731 100644
--- a/botanjs/src/Astro/Blog/Components/Comment.js
+++ b/botanjs/src/Astro/Blog/Components/Comment.js
@@ -515,7 +515,7 @@
 		: function ()
 		{
 			// Remove capcha
-			new IDOMElement().lootChildren( Dand.id( "recaptcha_field" ) );
+			Dand.id( "recaptcha_field", true ).clear();
 			try
 			{
 				Recaptcha.render( "recaptcha_field", {