Permalink
Browse files

added feed link, JS refactoring & made JSLint happy

  • Loading branch information...
1 parent ef863a1 commit 294c4e53cd5cc870c3d8b71d8c8460f7b56c6046 @livingston livingston committed Jul 14, 2011
Showing with 27 additions and 19 deletions.
  1. +27 −19 index.html
View
@@ -21,6 +21,7 @@
.posts ul { display:table-cell; width:100% }
.posts em { font-style:normal; color:#aaa; font-family:monotype; display:inline-block; text-align:right; width:25px; margin:0 5px 0 0 }
</style>
+ <link rel="alternate" type="application/rss+xml" title="C S Shyam Sundar's Thoughtpad Feed" href="http://thoughtpad.cs3.in/feed/" />
<script type="text/javascript">
var _gaq = [['_setAccount', 'UA-22637993-2'], ['_trackPageview']];
@@ -52,26 +53,33 @@ <h1 title='C S Shyam Sundar' class='page-title'>C S Shyam Sundar</h1>
<footer></footer>
<script>
- var feedData, feedHolder = document.getElementById('latest-posts'),
- dataHandler = function (data) {
- feedData = data.query.results.item;
- processFeed()
- },
- parseDate = function (date_str) {
- return date_str.match(/\w{3,}\,\s(\d{2,})\s(\w{3,})\s(\d{4,})/).slice(1)
- },
- processFeed = function () {
- var content = document.createElement('ul'), html_content = [];
- html_content.push('<h2>Thoughtpad Posts</h2>');
- feedData.forEach(function (item) {
- html_content.push('<li>');
- parseDate(item.pubDate).forEach(function (i) { html_content.push('<em>' + i + '</em> ') });
+ (function ( window, document ) {
+ 'use strict';
+ var feedData, feedHolder = document.getElementById('latest-posts'),
+ parseDate = function (date_str) {
+ return date_str.match(/\w{3,}\,\s(\d{2,})\s(\w{3,})\s(\d{4,})/).slice(1);
+ },
+ processFeed = function () {
+ var content = document.createElement('ul'), html_content = ['<h2>Thoughtpad Posts</h2>'];
+ feedData.forEach(function (item) {
+ html_content.push('<li>');
+ parseDate(item.pubDate).forEach(function (i) { html_content.push('<em>' + i + '</em> '); });
- html_content.push('&raquo; <a href="' + item.link + '">' + item.title + '</a></li>');
- });
- content.innerHTML = html_content.join('');
- feedHolder.appendChild(content);
- };
+ html_content.push('&raquo; <a href="' + item.link + '">' + item.title + '</a></li>');
+ });
+ content.innerHTML = html_content.join('');
+ feedHolder.appendChild(content);
+
+ html_content = null;
+ content = null;
+ feedData = null;
+ };
+
+ window.dataHandler = function (data) {
+ feedData = data.query.results.item;
+ processFeed();
+ };
+ }( window, document ));
</script>
<script src="http://query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%2C%20pubDate%20from%20feed%20where%20url%3D'http%3A%2F%2Fthoughtpad.cs3.in%2Ffeed%2F'&format=json&callback=dataHandler"></script>
</body>

0 comments on commit 294c4e5

Please sign in to comment.