JavaScript - Rss Feed Catcher
I'm trying to get two RSS feeds to display on a page. I'm trying to be good about it and re-use the same code for each by calling the function twice using different parameters for the feed url, feed limit (number of posts to display), and which div to display the output in (cupcake-feed and pie-feed).
It works for either of the two feeds, but not both at the same time. If I try calling both, only the second one displays. If I pick just one to call, either one will display. I'm new to object-oriented concepts (if that's even what you would call this?). What am I doing wrong here? Code: function rssfeedsetup(feedurl, feedlimit, feeddivi) { var feedpointer=new google.feeds.Feed(feedurl) //Google Feed API method feedpointer.setNumEntries(feedlimit) //Google Feed API method feedpointer.load(displayfeed) //Google Feed API method feeddiv=feeddivi //sets output div name as a global variable for use below } function displayfeed(result) { if (!result.error) { var thefeeds=result.feed.entries //convert date to friendly format var date=new Date(thefeeds[0].publishedDate) var dateString=date.toLocaleDateString() //create output content and display it in div for (var i=0; i<thefeeds.length; i++) { var rssoutput='<div class="feed-date">' + dateString + '</div>' + '<div class="feed-title"><a href="' + thefeeds[i].link + '">' + thefeeds[i].title + '</a></div>' + '<div id="cupcake-menu" class="hidden">' + thefeeds[i].content + '</div>' document.getElementById(feeddiv).innerHTML=rssoutput } } else { alert("Error fetching feeds!") } } //call function on load for each feed to be displayed window.onload=function(){ rssfeedsetup("http://www.site1.com/feed/", 1, "cupcake-feed"); rssfeedsetup("http://www.site2.com/feed/", 1, "pie-feed"); } Similar TutorialsSorry, relative newbie here with what is probably a silly question. When I include the code to create a slideshow found here and then later in the page use the feed informer code to display posts from my blog ( <script type="text/javascript" src="http://app.feed.informer.com/digest3/39SQ9SPCHY.js">...) I am getting a syntax error message at the feedinformer code in dreamweaver and I can not figure out the problem. Any help would be appreciated, thank you I'm quite new to javascript programming, I basically want to parse a JSON string from an external URL. http://cashtrackr.com/piwik/index.ph...9d8d472cc9974a This is the json string URL and I just want to output the contents of "nb_visits" for example. I would also like to know the terms for a JSON string "?" : ? thanks for your time I have this piece of javascript code, which enables me to get my Picasa photos without link back feature, in my webpage. The issue is with the hardcoded RSS url feed. I want this to be dynamically passed as a variable to the java script. I use a PHP code, where this javascript is coded. In the below code, if I say var samples = <?php $url_code ?>, the javascript does not recognize. Can someone help on this, as I use the same PHP code, with different url feeds, to display different picasa photo albums ? Code: <script type="text/javascript"> function load() { var samples = "https://picasaweb.google.com/data/feed/base/user/......................../........./.........?alt=rss&kind=photo&authkey=.....................&hl=en_US" var options = { numresults: 2, scaleimages: true, maintainAspectRatio : false, displayTime: 1000, transistionTime: 300, //linkTarget : google.feeds.LINK_TARGET_BLANK }; new GFslideShow(samples, "slideshow", options); } google.load("feeds", "1"); google.setOnLoadCallback(load); </script> I'm a new app developer who's in the process of developing a simple Android application using Titanium Studio. I'm trying to implement an RSS feed in one of my windows, but I keep getting the following error messages when I run the app on my device: [ERROR] : TiExceptionHandler: (main) [107,107] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,107] - In ui/common/NewsWindow.js:1,69 [ERROR] : TiExceptionHandler: (main) [0,107] - Message: Uncaught TypeError: Cannot call method 'add' of null [ERROR] : TiExceptionHandler: (main) [0,107] - Source: fontSize:14},message:"Loading...",style:style,top:20,left:100});win.add(activi [ERROR] : V8Exception: Exception occurred at ui/common/NewsWindow.js:1: Uncaught TypeError: Cannot call method 'add' of null The code for my NewsWindow.js file is below. Any help would be greatly appreciated! Code: var win = Titanium.UI.currentWindow; var style; if (Ti.Platform.name === 'iPhone OS'){ style = Ti.UI.iPhone.ActivityIndicatorStyle.DARK; } else { style = Ti.UI.ActivityIndicatorStyle.DARK; } var activityIndicator = Ti.UI.createActivityIndicator({ color: 'black', font: {fontFamily:'Helvetica Neue', fontSize:14}, message: 'Loading...', style: style, top: 20, left: 100 }); win.add(activityIndicator); activityIndicator.show(); var xmlFeed = 'http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml?edition=uk#'; var xhr = Ti.Network.createHTTPClient(); xhr.onload = function() { activityIndicator.hide(); var xml = this.responseXML; Ti.API.info(this.responseText); var channelTitle = xml.documentElement.getElementsByTagName("title").item(0).textContent; var channelLabel = Ti.UI.createLabel({ top: 20, text: channelTitle, color: '#39f' }); win.add(channelLabel); var data = []; var itemsTable = Ti.UI.createTableView({ top: 70, left: 0 }); win.add(itemsTable); var items = xml.documentElement.getElementsByTagName("item"); for(var i = 0; i < items.length; i++) { // create a table row for each item var row = Ti.UI.createTableViewRow({ title: items.item(i).getElementsByTagName("title").item(0).textContent, link: items.item(i).getElementsByTagName("link").item(0).textContent, height: 'auto', hasChild: true }); data.push(row); } // bind the data to the itemsTable itemsTable.data = data; // when the user clicks on a row itemsTable.addEventListener('click', function(e) { // create and open a new window var webView = Titanium.UI.createWebView({ backgroundColor:'#fff', url: e.rowData.link }); var newWindow = Titanium.UI.createWindow({ backgroundColor:'#fff', backButtonTitle: 'Back', title: e.source.title, }); newWindow.add(webView); Ti.UI.currentTab.open(newWindow); }); }; xhr.onerror = function() { activityIndicator.hide(); alert(this.status + ': ' + this.statusText); return false; }; // open the remote feed xhr.open('GET', xmlFeed); // execute the call to the remote feed xhr.send(); I have a twitter feed on my site and although am generally happy with it, the time-stamp for each tweet is several hours ahead of my time zone. I've looked through the js files to see if there is anything that allows me to set the timezone but cannot find anything. Anyone know how to reset the time to pacific standard time? Here's the URL http://www.kitchenprose.com/gmtest/index.html Can't for the life of me see anything in the code that controls time zone (would like Pacific Standard time, US) Code: $(document).ready(function() { $.Juitter.start({ searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser" searchObject:"gillesmarini", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma. // The values below will overwrite the ones on the Juitter default configuration. // They are optional here. // I'm changing here as a example only lang:"en", // restricts the search by the given language live:"live-125", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates. placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div> loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif" total: 4, // number of tweets to be show - max 100 readMo "Read it on Twitter", // read more message to be show after the tweet content nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow" filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,****"... Be aware that the tweets will still be showed, only the bad words will be removed }); $("#aRodrigo").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"fromUser", searchObject:"mrjuitter,rodrigofante", live:"live-120" // it will be updated every 120 seconds/2 minutes }); }); $("#aIphone").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"iPhone,apple,ipod", live:"live-20" // it will be update every 20 seconds }); }); $("#aJuitter").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"Juitter", live:"live-180" // it will be updated every 180 seconds/3 minutes }); }); $("#juitterSearch").submit(function(){ $.Juitter.start({ searchType:"searchWord", searchObject:$(".juitterSearch").val(), live:"live-20", // it will be updated every 180 seconds/3 minutes filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" }); return false; }); $(".juitterSearch").blur(function(){ if($(this).val()=="") $(this).val("Type a word and press enter"); }); $(".juitterSearch").click(function(){ if($(this).val()=="Type a word and press enter") $(this).val(""); }); }); Many thanks! I have 10 feedburner feeds that are for different categories on a wordpress site. I would like to modify the subscribe form code feedburner supplies to include radio buttons to select which of the feeds to subscribe to. Code: <HTML> <HEAD> <TITLE> Radio Window </TITLE> <script> function OpenWindow(){ for(i=0;i<document.FormName["RB1"].length;i++){ if(document.FormName["RB1"][i].checked){ window.open(document.FormName["RB1"][i].value); break; } } } </script> </HEAD> <BODY> <form name="FormName" style="border:1px solid #ccc;padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="OpenWindow()";return true"> <p>Enter your email address:</p><p><input type="text" style="width:140px" name="email"/></p> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed1&loc=en_US">Option 1<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed2&loc=en_US">Option 2<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed3&loc=en_US">Option 3<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed4&loc=en_US">Option 4<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed5&loc=en_US">Option 5<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed6&loc=en_US">Option 6<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed7&loc=en_US">Option 7<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed8&loc=en_US">Option 8<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed9&loc=en_US">Option 9<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed10&loc=en_US">Option 10<BR> <input type="submit" value="Subscribe"> </form> </BODY> </HTML> This is the code I have put together searching the web, when hitting the subscribe button after entering a email address and selecting an option it load two new windows, one for the relevant feed but does not transfer the email address entered in the text box. The second for to http://feedburner.google.com/fb/a/mailverify All help would be greatly received. I have a twitter feed on my site and although am generally happy with it, the time-stamp for each tweet is hours and hours ahead of my time zone. I've looked through the js files to see if there is anything that allows me to set the timezone but cannot find anything. Anyone know how to reset the time to pacific standard time? I've searched through the values and don't see anywhere to assign the timezone (would like Pacific Time zone, US) Here's the URL http://www.kitchenprose.com/gmtest/index.html Here's the code: Code: $(document).ready(function() { $.Juitter.start({ searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser" searchObject:"gillesmarini", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma. // The values below will overwrite the ones on the Juitter default configuration. // They are optional here. // I'm changing here as a example only lang:"en", // restricts the search by the given language live:"live-125", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates. placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div> loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif" total: 4, // number of tweets to be show - max 100 readMo "Read it on Twitter", // read more message to be show after the tweet content nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow" filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,****"... Be aware that the tweets will still be showed, only the bad words will be removed }); $("#aRodrigo").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"fromUser", searchObject:"mrjuitter,rodrigofante", live:"live-120" // it will be updated every 120 seconds/2 minutes }); }); $("#aIphone").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"iPhone,apple,ipod", live:"live-20" // it will be update every 20 seconds }); }); $("#aJuitter").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"Juitter", live:"live-180" // it will be updated every 180 seconds/3 minutes }); }); $("#juitterSearch").submit(function(){ $.Juitter.start({ searchType:"searchWord", searchObject:$(".juitterSearch").val(), live:"live-20", // it will be updated every 180 seconds/3 minutes filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" }); return false; }); $(".juitterSearch").blur(function(){ if($(this).val()=="") $(this).val("Type a word and press enter"); }); $(".juitterSearch").click(function(){ if($(this).val()=="Type a word and press enter") $(this).val(""); }); }); Many thanks! Hello, first time poster here. I have very little understanding of Javascript and have a problem with some I'm using. It's a singleline twitter feed and you can see it top right he http://zest.explosiveapps.com/navigation.php Code: // Compatability with jQuery: jQuery.noConflict(); window.$ = function (element) { return document.getElementById(element); }; /* Header and footer JavaScript */ jQuery(document).ready(function() { var $ = jQuery; function scroll_tweet(li){ var post = li.children("div.post"), pWidth = post.width(); if (pWidth > parseInt(balloon.css('width'))){ var leftEnd = li.find('div.end'); if(leftEnd.length === 0){ leftEnd = $('<div class="end left" />').appendTo(li); } var offsX = parseInt(leftEnd.width()); post.animate({left: offsX - pWidth - 55}, 23000, 'linear', function(){post.css('left', offsX);}); } } function swap_tweets(current_tweet){ var next_tweet = (current_tweet + 1) % 5; /* max five tweets */ var li = $("li#tweet" + next_tweet); $("#tweet" + current_tweet).fadeOut(300); setTimeout(function(){ li.fadeIn(400); }, 400); setTimeout(function(){scroll_tweet(li);}, 3800); display_tweet = next_tweet; setTimeout(function(){swap_tweets(display_tweet);}, 11300); } var balloon = $("#twitterpost div.balloon"); display_tweet = 0; if($("div.balloon ul li#tweet1").html() !== null){ setTimeout(function(){swap_tweets(display_tweet);}, 12000); var firstli = $("li#tweet0"); setTimeout(function(){scroll_tweet(firstli);}, 7500); } }); As you can see from just watching, it has some problems. It doesn't fade out posts before displaying a new one. From what I understand it talks to the CSS to figure out the length. So maybe that's where the problem is. Code: /* twitter-bubble */ #navigation #twitterpost { position: relative; top: -33px; right: 95px; } #navigation #twitterpost .balloon { position: relative; float: right; width: 345px; height: 21px; overflow: hidden; margin-top: 0px; padding: 0; background: url(/navigation/images/bubble.png) 0 0 no-repeat; font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, sans-serif; } #navigation #twitterpost .balloon div { font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, sans-serif; color: #666666; padding: 0px 0px 12px 10px; font-size: 11px; } #navigation #twitterpost .end { position: absolute; top: 0; z-index: 1; height: 21px; background: url(/navigation/images/bubble.png) no-repeat; } #navigation #twitterpost .end.left { left: 0; width: 0px; background-position: 0 0; } #navigation #twitterpost .end.right { right: 0; width: 0px; background-position: 100% 0; } #navigation #twitterpost ul li .post { position: relative; } #navigation #twitterpost ul li .post { font-size: 11px; white-space: nowrap; position: absolute; top: 3px; } #navigation #twitterpost ul { padding-left: 0px; margin: 0px; list-style-type: none; } Or maybe it has something to do with using this script http://ajax.googleapis.com/ajax/libs.../jquery.min.js Thank you for take a look at my mess! Sorry for being such an amateur. And by the way, everything is wip on that site Cheers M. I pulled together a custom RSS twitter feed that uses javascript; however, when I tell the code to "callback" 3 posts, they all run together without line breaks. What is the best way to have breaks between the posts? This page shows the html code (in the right sidebar): http://www.westbrockdesign.com/twitter.html The javascript looks like this: Code: function twitterCallback2(C){var A=[];for(var D=0;D<C.length;D++){var E=C[D].user.screen_name;var B=C[D].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(F){return'<a href="'+F+'">'+F+"</a>"}).replace(/\B@([_a-z0-9]+)/ig,function(F){return F.charAt(0)+'<a href="http://www.twitter.com/'+F.substring(1)+'">'+F.substring(1)+"</a>"});A.push("<span>"+B+'</span> <a style="font-size:85%" href="http://twitter.com/'+E+"/statuses/"+C[D].id+'">'+relative_time(C[D].created_at)+"</a>")}document.getElementById("twitter_gretchen").innerHTML=A.join("")}function relative_time(C){var B=C.split(" ");C=B[1]+" "+B[2]+", "+B[5]+" "+B[3];var A=Date.parse(C);var D=(arguments.length>1)?arguments[1]:new Date();var E=parseInt((D.getTime()-A)/1000);E=E+(D.getTimezoneOffset()*60);if(E<60){return"less than a minute ago"}else{if(E<120){return"about a minute ago"}else{if(E<(60*60)){return(parseInt(E/60)).toString()+" minutes ago"}else{if(E<(120*60)){return"about an hour ago"}else{if(E<(24*60*60)){return"about "+(parseInt(E/3600)).toString()+" hours ago"}else{if(E<(48*60*60)){return"1 day ago"}else{return(parseInt(E/86400)).toString()+" days ago"}}}}}}}; Any insights would be much appreciated! Hello, I have this working js twitter feed on my site, but I am trying to generate the topsy retweet button through the .js file via an innerHTML call, but its not working. the innerHTML works if I put test or something in there, so there is something within this line of code that is breaking it. Code: document.getElementById('retweet-button').innerHTML = '<div class="topsy_widget_data"><!--{"url":"'+url+'","title":"inConcert Web Solutions, Inc."}--></div>'; This is the entire script, I really appreciate any help Code: //Twitter window.onload = function() { var ajax_load = "<img class='loader' src='/assets/templates/incon/twitterfeed/loader.gif' alt='Loading...' />"; var url = 'http://twitter.com/statuses/user_timeline/inConcertWeb.json?callback=twitterCallback2&count=1'; var script = document.createElement('script'); $("#twitter_feed").html(ajax_load); script.setAttribute('src', url); document.body.appendChild(script); } function twitterCallback2(twitters) { var statusHTML = []; for (var i=0; i<twitters.length; i++){ var username = twitters[i].user.screen_name; var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { return '<a href="'+url+'" rel="nofollow" target="_blank">'+url+'</a>'; }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; }); statusHTML.push('<li class="twitter_date"><a href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'" rel="nofollow" target="_blank">'+relative_time(twitters[i].created_at)+'</a></li> <li><p>'+status+'</p></li>'); } document.getElementById('twitter_update_list').innerHTML = statusHTML.join(''); //THIS IS WHERE IT IS BREAKING document.getElementById('retweet-button').innerHTML = '<div class="topsy_widget_data"><!--{"url":"'+url+'","title":"inConcert Web Solutions, Inc."}--></div>'; } function relative_time(time_value) { var values = time_value.split(" "); time_value = values[1] + " " + values[2] + " " + values[5] + " " + values[3]; var parsed_date = new Date(); parsed_date.setTime(Date.parse(time_value)); var months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); var m = parsed_date.getMonth(); var postedAt = ''; postedAt = months[m]; postedAt += " "+ parsed_date.getDate(); postedAt += "," postedAt += " "+ parsed_date.getFullYear(); return postedAt; } hey, i am trying to add events to my website...i have all the events stored in my google calender and i am trying to show only four events at the time for example: 10/01/2011 - John's Birthday 12/01/2011 - Party i found this example on google however i am having problems...the problem i am having is that it works fine on my computer however when i look at it on another computer nothing appears http://gdata-javascript-client.googl...le_sample.html thanks Hello, Ive used feed.informer to display recent updates to my blog but it only seems to allow for them to be displayed vertically. I am looking for a way to display my recent blog posts horizontally on my site in a manner similar to how feed.informer works. Thank you for your help! Hi, I have an .aspx page which the author claims to be an RSS feed (http://gcn.com/rss-feeds/state-local.aspx). It is simply a list of links with a description for each. I am trying to embed these links into an RSS feed on my own page. I am using code from http://www.mioplanet.com/rsc/newsticker_javascript.htm to create the scrolling ticker. Do I need to do something to convert the .aspx page to an RSS feed? Please help. Thanks. I'm using JavaScript (rssplayer.js) to display a feed from a Blogger blog. I want the feed to be displayed as plain text without the hyperlink to the original posts. Does anyone know how to do this? Thanks rssplayer: http://www.javascriptkit.com/dhtmltu...jaxfeed3.shtml Here's the code in my page: Code: <script type="text/javascript"> //USAGE SYNTAX: new rssdisplayer("divid", "rssurl", numberofitems, "displayoptions") new rssdisplayer("rssdiv", "http://jms8bscience-assignments.blogspot.com/feeds/posts/default?alt=rss", 6, "")</script> Here's the code for the rssdisplayer.js Code: google.load("feeds", "1") //Load Google Ajax Feed API (version 1) function rssdisplayer(divid, url, feedlimit, showoptions){ this.showoptions=showoptions || "" //get string of options to show ("date" and/or "description") var feedpointer=new google.feeds.Feed(url) //create new instance of Google Ajax Feed API feedpointer.setNumEntries(feedlimit) //set number of items to display document.write('<div id="'+divid+'">Loading feed...</div>') this.feedcontainer=document.getElementById(divid) var displayer=this feedpointer.load(function(r){displayer.formatoutput(r)}) //call Feed.load() to retrieve and output RSS feed } rssdisplayer.prototype.formatdate=function(datestr){ var itemdate=new Date(datestr) return "<span style='color:gray; font-size: 90%'>"+itemdate.toLocaleString()+"</span>" } rssdisplayer.prototype.formatoutput=function(result){ if (!result.error){ //if RSS feed successfully fetched var thefeeds=result.feed.entries //get all feed entries as a JSON array var rssoutput="<ul>" for (var i=0; i<thefeeds.length; i++){ //loop through entries var itemtitle="<a href=\"" + thefeeds[i].link + "\">" + thefeeds[i].title + "</a>" var itemdate=/date/i.test(this.showoptions)? this.formatdate(thefeeds[i].publishedDate) : "" var itemdescription=/description/i.test(this.showoptions)? "<br />"+thefeeds[i].content : "" rssoutput+="<li>" + itemtitle + " " + itemdate + itemdescription + "</li>" } rssoutput+="</ul>" this.feedcontainer.innerHTML=rssoutput } else //else, output error alert("Error fetching feeds: "+result.error.message) } //USAGE SYNTAX: new rssdisplayer("divid", "rssurl", numberofitems, "displayoptions") //new rssdisplayer("adiv", "http://www.cssdrive.com/index.php/news/rss_2.0/", 5, "date, description") Hi, I have a javascript app that works fine to parse my bb_feed.xml page pasted below this message. The problem is I need to link to the script instead of including it within the web page. When I try to create the page as a .js file and link to this script from another webpage, it doesn't work. Here's the code that I used to link the .js file that I have named bb_footer.js <script language="javascript" src="bb_footer.js" type="text/javascript"></script> Is there some other way this has to be done? Thanks for any and all possible help... <html> <body> <script type="text/javascript"> if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else // Internet Explorer 5/6 { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","bb_feed.xml",false); xhttp.send(""); xmlDoc=xhttp.responseXML; var x=xmlDoc.getElementsByTagName("item"); for (i=0;i<x.length;i++) { document.write("<ul><li><a href=\""); document.write(x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue); document.write("\">"); document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue); document.write("</a></li></ul>"); } </script> </body> </html> Hey there, I'm having difficulties writing a script that should do the following: 1. "visit"/connect to a website 2. search after rss feeds on the site 3. grab the rss link and make it useable for other scripts (array...) If anybody could guide me on how to do that I would be grateful.. thanks! Hi I'm looking for a simple ticker that scrolls horizontally across the top of the homepage of a site I'm working on. Ideally I would like one for both Twitter and RSS feeds, but either is good. If anyone knows where I can find one that's simple to implement that would be great. Kind Regards |