var tags = {};

function scrollToBody() {
	console.log("scrolling to body");
	$("html, body").animate({
		scrollTop: $("#body").offset().top
	}, 1000);
}

$(document).ready(function(){
	$(window).resize();

    showAllPostPreviews();
    var hash = decodeURI(window.location.hash);
    if (hash) {
        showPost(hash.substring(1, hash.length));
    }
});

$(window).resize(function(){
	if ($(this).width() < 1000) {
		$("#otherInfos").css("width", "90%");
		$("#content").css("width", "90%");
	} else {
		$("#otherInfos").css("width", "25%");
		$("#content").css("width", "60%");
	}
});

function showPostsPreviews(posts) {
	$("#shareLink").html("");
    if (posts != null) {
		// posts found
		$("#content").html("");
        for (i in posts) {
			var html = "";
			html += "<div class=\"postPreview\" id=\"";
			html += posts[i];
			html += "\"></div>"
			$("#content").append(html);
			var xhttp = new XMLHttpRequest();
			xhttp["postId"] = posts[i];
			xhttp.onreadystatechange = function() {
			    if (this.readyState == 4 && this.status == 200) {
					var info = JSON.parse(this.responseText);
		            if (info == null) {
		                return;
		            }

					var html = "";
		            html += "<h1 class=\"postTitle\">";
		            html += info.title;
		            html += "</h1><p class=\"postTimestamp\">";
		            html += info.timestamp;
		            html += "</p><p class=\"postExtract\">";
		            html += info.extract;
		            html += "<a onclick=\"showPost('";
		            html += this["postId"];
		            html += "')\"> Read more...</a></p><p class=\"postTag\">Tags: ";
		            for (j in info.tags) {
		                html += "<a onclick=\"showTagPostsPreviews('";
		                html += info.tags[j]
		                html += "'); scrollToBody()\">";
		                html += info.tags[j] + "</a>, ";

		                // add tags to tags
						if ($.inArray(this["postId"], tags[info.tags[j]]) == -1) {
							tags[info.tags[j]].push(this["postId"]);
						}
		                /*if (tags[info.tags[j]] == null) {
		                    tags[info.tags[j]] = [this["postId"]];
		                } else {

		                }*/
		            }
		            html = html.substring(0, html.length - 2);
		            html += "</p>";

			        $("#" + this["postId"]).html(html);
			    }
			};
            xhttp.open("GET", posts[i] + "/info.json", true);
			xhttp.timeout = 2000;
            xhttp.send();
        }
    } else {
        // no posts
		$("#content").html("No Posts. ");
    }
}

function showAllPostPreviews() {
	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
	    if (this.readyState == 4 && this.status == 200) {
			var posts = JSON.parse(this.responseText).posts;
			showPostsPreviews(posts);
		}
	};
    xhttp.open("GET", "postSum.json", true);
	xhttp.timeout = 2000;
    xhttp.send();
}

function showTagPostsPreviews(tagName) {
	showPostsPreviews(tags[tagName]);
	$("#content").prepend("<h1>Tag: " + tagName + "</h1>");
}

function showPost(name) {
	var html = "";
	html = $("<div />").append($("#" + name).clone()).html();
	$("#content").html(html);
	$("#" + name + ">.postTitle").css("font-size", "40px");

	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
	    if (this.readyState == 4 && this.status == 200) {
			if (this.responseText != null) {
				var escapedContent = this.responseText.replace(/&/g, "&amp;")
									.replace(/\n/g, "<br>")
									.replace(/        /g, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
									.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
									//.replace(/</g, "&lt;")
									//.replace(/>/g, "&gt;")
									//.replace(/"/g, "&quot;")
									.replace(/'/g, "&apos;")
									;

				$("#content>#" + name + ">.postExtract").html("<article class='postContent'>"+ escapedContent + "</article>");
				//$("#shareLink").html("Link to this page (URL does not work): <br>http://blog.zhukaihan.com/index.html#" + name + "<br>");
		    } else {
		        $("#content>#" + name + ">.postExtract").html("<p>No Such Article.</p>");
		    }
		}
	};
	xhttp.open("GET", name + "/content", true);
	xhttp.timeout = 2000;
	xhttp.send();

	scrollToBody();
}

@@ -1919,42 +1919,28 @@
 s%0A%09%09
-%09%09%09%09if ($.inArray(this%5B%22postId%22%5D, 
+                if (
 tags
@@ -1957,26 +1957,42 @@
 %5Bj%5D%5D
-)
  == 
--1
+null
 ) %7B%0A%09%09
-%09%09%09%09%09
+                    
 tags
@@ -2009,14 +2009,12 @@
 %5Bj%5D%5D
-.push(
+ = %5B
 this
@@ -2027,43 +2027,90 @@
 Id%22%5D
-)
+%5D
 ;%0A%09%09
-%09%09%09%09%7D%0A%09%09                /*if (
+                %7D else %7B%0A%09%09                    if ($.inArray(this%5B%22postId%22%5D, 
 tags
@@ -2119,32 +2119,31 @@
 nfo.tags%5Bj%5D%5D
+)
  == 
-null
+-1
 ) %7B%0A%09%09      
@@ -2148,32 +2148,36 @@
                 
+    
 tags%5Binfo.tags%5Bj
@@ -2170,36 +2170,38 @@
 gs%5Binfo.tags%5Bj%5D%5D
- = %5B
+.push(
 this%5B%22postId%22%5D%5D;
@@ -2190,33 +2190,33 @@
 h(this%5B%22postId%22%5D
-%5D
+)
 ;%0A%09%09            
@@ -2219,25 +2219,21 @@
         
+ 
-%7D else %7B%0A
+   %7D
 %0A%09%09     
@@ -2248,10 +2248,8 @@
    %7D
-*/
 %0A%09%09 

Update Code