# HG changeset patch # User Atul Varma # Date 1281679606 25200 # Node ID 182af9ac76fb787fcf389f9009866932671e18bd # Parent 35edfd76a3f703ef46f941e486d3c79d48eb7eee Moved a var declaration, formatting/indentation fixes. diff -r 35edfd76a3f7 -r 182af9ac76fb daily-edition.js --- a/daily-edition.js Fri Aug 13 06:04:28 2010 +0000 +++ b/daily-edition.js Thu Aug 12 23:06:46 2010 -0700 @@ -40,48 +40,50 @@ } function showContent(json) { - if (window.JSON) - info = JSON.parse(json); - else - info = eval("(" + json + ");"); - - $("#issue-no").text(info.id + 1); - $("#pub-date").text(info.pubDate.join(".")); + var info; - info.authors.forEach( - function(author) { - if (author in info.articles) - info.articles[author].forEach( - function(article) { - var div = $("#templates .article").clone(); - var date = article.pubDate.join("."); - var title = safeHtml(article.title); - div.find(".title .link").html(title); - div.find(".title .link").attr("href", article.url); - div.find(".author").text(author); + if (window.JSON) + info = JSON.parse(json); + else + info = eval("(" + json + ");"); + + $("#issue-no").text(info.id + 1); + $("#pub-date").text(info.pubDate.join(".")); - var html = []; - article.content.forEach( - function(content) { - if (content.type == "text/html") - html.push(safeHtml(content.value)); - }); + info.authors.forEach( + function(author) { + if (author in info.articles) + info.articles[author].forEach( + function(article) { + var div = $("#templates .article").clone(); + var date = article.pubDate.join("."); + var title = safeHtml(article.title); + div.find(".title .link").html(title); + div.find(".title .link").attr("href", article.url); + div.find(".author").text(author); + + var html = []; + article.content.forEach( + function(content) { + if (content.type == "text/html") + html.push(safeHtml(content.value)); + }); - if (html.length > 0) { - var content = div.find(".content"); - content.html(html[0]); - if (content.get(0).firstChild.nodeType == 3) - // The child isn't wrapped in a containing block - // element, so do that to ensure it has some - // padding from everything around it. - content.html("

" + html[0] + "

"); - } - div.find(".date").text(date); - $("#articles").append(div); - }); + if (html.length > 0) { + var content = div.find(".content"); + content.html(html[0]); + if (content.get(0).firstChild.nodeType == 3) + // The child isn't wrapped in a containing block + // element, so do that to ensure it has some + // padding from everything around it. + content.html("

" + html[0] + "

"); + } + div.find(".date").text(date); + $("#articles").append(div); }); + }); - $("#container").fadeIn("fast"); + $("#container").fadeIn("fast"); } $(window).ready( @@ -100,8 +102,6 @@ req.addEventListener( "load", function(event) { - var info; - if (req.status != 200) { showError(); return;