jQuery Plugin: jQRSS

by Intesar Haider

HTML

<script src="https://rawgit.com/JDMcKinstry/jQRSS/master/jQRSS.min.js"></script>
<h2>Now hosted @ <a href="https://github.com/JDMcKinstry/jQRSS" target="_blank">//github.com/JDMcKinstry/jQRSS</a></h2>
<h3>Also, the link i used for example here is now dead, but i left the code so for examples.</h3>
<div id="crazy">
<div id="TopFeaturesBlock" class="features-wrapper"></div>
<div id="NewsBlock" class="news-block">
    <h2 class="title">
        News
        <span>
            <a id="btnUpdateNewsBlock" href="javascript:void(0)">Update</a>
            <a href="https://www.facebook.com/feeds/page.php?format=rss20&id=158374897554468" target="_blank" class="rss">
                <img src="http://www.defense.gov/images/2.1/icons/icon_14px_rss.png" alt="" />
            </a>
            <a href="http://www.defense.gov/news/" class="more">More »</a>
        </span>
    </h2>
    <div class="content"></div>
</div>
</div>

CSS

#crazy { display: none; }

.news-block
{
    position: relative;
}
.news-block .title
{
    background: rgb(229, 233, 237) url("http://www.defense.gov/images/2.1/background_contentblocktitle1.gif") repeat-x scroll left top;
    border: 1px solid #D7DDE3;
    clear: both;
    font-size: 1.1em;
    margin: 0px;
    padding: 4px 10px;
    position: relative;
}
.news-block .title span
{
    border: medium none;
    position: absolute;
    right: 0px;
    top: 3px;
}
.news-block .title a 
{
    color: #084476;
    font-weight: normal;
    margin: 0px 10px 0px 0px;
    padding: 0px;
    text-decoration: none;
    vertical-align: middle;
}
.news-block .title .rss
{
    
}
.news-block .title .rss img
{
    border: medium none;
    margin: 0px;
    padding: 0px;
    position: relative;
    right: 0px;
    top: -1px;
    vertical-align: middle;
}
.news-block .title .more
{
    
}
.news-block .content
{
    margin: 0px;
    padding: 6px 10px 10px 10px;
    position: relative;
}
.news-block .content .expanded 
{
    clear: both;
    border-bottom: 1px solid #CACACA;
    margin: 0px 0px .6em 0px;
    padding: 0px 0px .6em 0px;
}
.news-block .content .expanded span
{
    color: #8d8d8d;
    font-size: .9em;
}
.news-block .content .expanded h4
{
    font-size: 1.1em;
    margin: 0px;
    padding: 0px;
}
.news-block .content .expanded h4 a
{
    color: #084476;
    text-decoration: none;
}
.news-block .content .expanded p
{
    margin: 0px;
    padding: 0px;
}
.news-block .content .expanded p a
{
    color: #084476;
    text-decoration: none;
    white-space: nowrap;
}
.news-block .content ul 
{
    font-size: 1.1em;
    margin: .6em 0px 0px 0px;
    padding: 0px;
    list-style-image: none;
    list-style-type: none;
}
.news-block .content li 
{
    background: transparent url("http://www.defense.gov/images/2.1/bullet_square1.gif") no-repeat scroll 0px .43em;
    margin: 0px 0px .6em 0px;
    padding: 0px 0px 0px 10px;
}
.news-block .content li a
{
    color: #084476;
   ...

JavaScript

/* - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - BEGIN PLUGIN- - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - NOW HOSTED AT - - - - - - - - */
/* - - -https://github.com/JDMcKinstry/jQRSS - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - - -END PLUGIN - - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - */

function getFeedNewsBlock() {
	var url = 'https://news.google.com/rss/search?q=gov-job&hl=en-IN&gl=IN&ceid=IN:en',
		props = { count: 8 };
	$.jQRSS(url, props, function (newsFeed) {
		if (!newsFeed) return false;
		$.jQRSS.debug('[getFeedNewsBlock()]', newsFeed);
		var nbc = $(".news-block .content").empty().append($("<div/>").addClass("expanded"), $("<div />").css("clear", "both"), $("<ul/>"));
		if ( newsFeed && newsFeed.entries ) for (var i = 0; i < newsFeed.entries.length; i++) {
			var entry = newsFeed.entries[i];

			var author = entry['author'] ? entry['author'] : "",
				categories = entry['categories'] ? entry['categories'] : new Array(),
				content = entry['content'] ? entry['content'] : "",
				contentSnippet = entry['contentSnippet'] ? entry['contentSnippet'] : "",
				link = entry['link'] ? entry['link'] : "",
				publishedDate = entry['publishedDate'] ? entry['publishedDate'] : "",
				title = entry['title'] ? entry['title'] : "";

			/*  author, categories, content, contentSnippet, link, publishedDate, title  */
			if (i == 0) {
				var patt = new RegExp(' [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [-|+][0-9][0-9][0-9][0-9]');
				nbc.children(".expanded").prepend($("<span />").text(publishedDate.replace(patt, "")));

				nbc.children(".expanded").append(
					$("<h4 />").append($("<a />", { href: link, target: "_blank" }).text(title)),
					$("<p />").text(content)
				);

				nbc.children(".expanded").find("p").last().append($("<a />", { href: link, target: "_blank" }).text(" Story »"));
			}
			else...