$(function(){if($("article#blogpost").length)return;$.each($(".hascomments[id]"),function(i,e){var x=$(e);x.before("<div class='paragraph-link'><a href='#"+x.attr("id")+"'>&#x00B6;</a></div>");var id=x.attr("id");$.getJSON("http://www.yesodweb.com/comments/count",{element:id},function(z){var c=z.count==1?"comment":"comments";x.append(" <a class='commentlink'> "+z.count+"\u00a0"+c+"</a>");var notLoaded=true,open=function(){if(notLoaded){notLoaded=false;x.after("<div class='comments'>Loading...</div>");$.getJSON("http://www.yesodweb.com/comments",{element:id},function(comments){var html=["<dl>"];$.each(comments.comments,function(i,comment){html.push("<dt><img src='");html.push(comment.gravatar);html.push("'> ");html.push(comment.name);html.push(" <i>");html.push(comment.date);html.push("</i></dt><dd>");html.push(comment.content);html.push("</dd></dt>")});html.push("</dl>");if(comments.loggedin=="true"){html.push("<form method='post' action='http://www.yesodweb.com/comments?element="+id+"'>");html.push("<input type='hidden' name='source' value='"+document.location+"'>");html.push("<textarea name='content' placeholder='Enter your comment here'></textarea>");html.push("<input type='submit' value='Add comment'>");html.push("</form>")}else html.push("<p>You must be <a href='http://www.yesodweb.com/auth/login'>logged in</a> to comment.</p>");x.next().html(html.join(""))})}else x.next().toggleClass("hidden")};x.children("a.commentlink").click(open);if(document.location.hash=="#"+x.attr("id"))open()})})});$(function(){$("nav.collapse li").addClass("closed");$("nav.collapse li ul").parent().prepend("<span class='openclose'/>");$("nav.collapse li.current").parents("li").andSelf().removeClass("closed");$("span.openclose").click(function(){$(this).parent().toggleClass("closed")})})
