function feedItem(feedTitle, feedLink, feedDescription, itemTitle, itemLink, itemPubDate,itemDescription, itemGuid ) { this.feedTitle = feedTitle; this.feedLink = feedLink; this.feedDescription = feedDescription; this.itemTitle = itemTitle; this.itemLink = itemLink; this.itemPubDate = itemPubDate; this.itemDescription = itemDescription; this.itemGuid = itemGuid; } function ASfeedItem(feedTitle, feedLink, feedDescription, itemTitle, itemLink, itemPubDate,itemDescription, itemGuid, itemCategory ) { this.feedTitle = feedTitle; this.feedLink = feedLink; this.feedDescription = feedDescription; this.itemTitle = itemTitle; this.itemLink = itemLink; this.itemPubDate = itemPubDate; this.itemDescription = itemDescription; this.itemGuid = itemGuid; this.itemCategory = itemCategory; } function getLatestRSSFeeds(number, rssfeed, div_id, itemtitle, itempubdate, itemdescription ){ jQuery.get('/includes/rss/rssfunction.php', {rssfeed:rssfeed, nbitems:number}, function(response) { /* We make use of the eval function, which converts the properly formatted string from the server into a javascript object */ rss2json = eval('('+ response +')'); jsonfeeds = new Array(); for(var i = 0; i < number; i++) { jsonfeeds[i] = new feedItem(rss2json.channel.channel.title, rss2json.channel.channel.link, rss2json.channel.channel.description, rss2json.channel.channel.item[i].title, rss2json.channel.channel.item[i].link, rss2json.channel.channel.item[i].pubDate, rss2json.channel.channel.item[i].description, rss2json.channel.channel.item[i].guid ); } formatJsonFeeds(number, div_id, itemtitle, itempubdate, itemdescription); }); } function getLatestASRSSFeeds(number, rssfeed, div_id, itemtitle, itempubdate, itemdescription ){ jQuery.get('/includes/rss/rssfunction.php', {rssfeed:rssfeed, nbitems:number}, function(response) { /* We make use of the eval function, which converts the properly formatted string from the server into a javascript object */ rss2json = eval('('+ response +')'); asjsonfeeds = new Array(); var j = 0; for(var i = 0; ;i++) { var pattern = rss2json.channel.channel.item[i].link; if (pattern.indexOf('Itemid=31') != -1 | pattern.indexOf('Itemid=32') != -1 | pattern.indexOf('Itemid=34') != -1 ) { if (pattern.indexOf('Itemid=31') != -1) { category = "Politics"; } else if (pattern.indexOf('Itemid=32') != -1) { category = "Economics/Business"; } else if (pattern.indexOf('Itemid=34') != -1) { category = "Culture"; } category = " (" + category + ")"; asjsonfeeds[j] = new ASfeedItem(rss2json.channel.channel.title, rss2json.channel.channel.link, rss2json.channel.channel.description, rss2json.channel.channel.item[i].title, rss2json.channel.channel.item[i].link, rss2json.channel.channel.item[i].pubDate, rss2json.channel.channel.item[i].description, rss2json.channel.channel.item[i].guid, category ); j++; } if (j == number) { break; } } formatJsonASFeeds(asjsonfeeds, div_id, itemtitle, itempubdate, itemdescription); }); } function formatJsonFeeds(number, div_id, itemtitle, itempubdate, itemdescription) { var str = ''; str += '
'; for(var i = 0; i < jsonfeeds.length; i++) { str += '
'; if (itemtitle){ str += getJsonItemTitle(i, itempubdate, div_id); } str += '
'; } str += '
'; jQuery("div#"+div_id).html(str); jQuery("div#"+div_id).slideDown('slow'); } function formatJsonASFeeds(asjsonfeeds, div_id, itemtitle, itempubdate, itemdescription) { var str = ''; str += 'Asia Sentinel News'; str += '

'; jQuery("div#"+div_id).html(str); } /** * Returns the title of an item * @param {Object} i */ function getJsonItemTitle(i, itempubdate, div_id) { if (itempubdate) { return '
' + getJsonItemPubDate(i, div_id) + '' + jsonfeeds[i].itemTitle + '
'; } else { return '
' + jsonfeeds[i].itemTitle + '
'; } } /** * Returns the publication date of the item * @param {Object} i */ function getJsonItemPubDate(i, div_id) { if (div_id == "rss_ekathimerini") { return '' + jsonfeeds[i].itemPubDate.substring(0,9) + ' : '; } else if (div_id == "rss_dailystaregypt") { return '' + jsonfeeds[i].itemPubDate + ' : '; } else { return '' + jsonfeeds[i].itemPubDate.substring(5,11) + ' : '; } } /** * Returns the description of the item * @param {Object} i */ function getJsonItemDescription(i){ return '
' + jsonfeeds[i].itemDescription.substring(0,150) + '...()
Read on'; } // ensure that jQuery doesn't conflict with other libraries // but still uses short names for objects jQuery.noConflict();