PDA

View Full Version : gAjax RSS Pausing Scroller Date/Time function



FionaSpence
10-31-2007, 02:25 AM
1) Script Title: gAjax RSS Pausing Scroller (hosted)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxpausescroller.htm

3) Describe problem: Date/time is dumb

Hi all

After developing and integrating this script on my site, I've found that the only glitch to this awesome little tool is that the date/time function displays incorrectly. By that - I mean, the dates I am inputting show up as the next day! So I am assuming somewhere it is referencing the US timezone, seeing as it's hosted by Google. Is that correct? If so, is there any way of specifying our timezone, in Australia, as well as modifying the properties of the date display so it displays as 10:00am instead of 1:00:00...

Many thanks for all your assistance

Mrs Spence

ddadmin
10-31-2007, 05:39 AM
The only description I found from Google's doc on the RSS date format:


publishedDate: The string date on which the entry was published of the form "13 Apr 2007 12:40:07 -0700". You can parse the date with new Date(entry.date). Corresponds to the <published> element in Atom and the <pubDate> element in RSS.

You may want to look into all the valid syntax for the pubDate element in RSS. I believe you may be able to specify timezone and other info within it.

Strangeplant
10-31-2007, 05:35 PM
I think something else is wrong. If I do a search in google news and save it as a bookmark, it gives me a list of links, however when the rss link is used in this scroller, only the first item appears. With yahoo and others, multiple links appear in the scroller. So, I assume that the error is in the DD scroller.

ddadmin
10-31-2007, 08:27 PM
Do you mean a RSS feed based on a Google search result? Do you have a sample RSS feed URL?

FionaSpence
11-01-2007, 02:00 AM
HI DDadmin,

Do you have the link to this info by any chance?

Many thanks

Mrs Spence

ddadmin
11-01-2007, 04:00 AM
Here you go: http://code.google.com/apis/ajaxfeeds/documentation/

Strangeplant
11-01-2007, 03:38 PM
DDadmin, yes I have a search result, but it seems to happen with, at least, everything from Google, and maybe others, too. I can see the results when I use the code provided by Google:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google AJAX Feed API - Simple Example</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAQbQUbf-dyICxJd0dlqJU_xQLoWoI2H279niKOwg7OooTRHa47hT0V4c38X9vhAiK31UxiMKr7mcHRw"></script>
<script type="text/javascript">

google.load("feeds", "1");

function initialize() {
var feed = new google.feeds.Feed("http://news.google.com/news?hl=en&ned=us&q=modis+image&ie=UTF-8&output=rss");
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
div.appendChild(document.createTextNode(entry.title));
container.appendChild(div);
}
}
});
}
google.setOnLoadCallback(initialize);

</script>
</head>
<body>
<div id="feed"></div>
</body>
</html>And if you run the DD script, adding the line from Google:
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAQbQUbf-dyICxJd0dlqJU_xQLoWoI2H279niKOwg7OooTRHa47hT0V4c38X9vhAiK31UxiMKr7mcHRw"></script>
Only one appears.......

ddadmin
11-02-2007, 05:45 AM
I just tested the script using your RSS feed (http://news.google.com/news?hl=en&ned=us&q=modis+image&ie=UTF-8&output=rss), and it works fine for me. For example:


<script type="text/javascript">

var socialfeed=new gfeedpausescroller("example2", "example2class", 3000, "")
socialfeed.addFeed("Google", "http://news.google.com/news?hl=en&ned=us&q=modis+image&ie=UTF-8&output=rss") //Specify "label" plus URL to RSS feed
socialfeed.displayoptions("label datetime") //show the specified additional fields
socialfeed.setentrycontainer("li") //Display each entry as a DIV
socialfeed.filterfeed(15, "label") //Show 15 entries, sort by label
socialfeed.entries_per_page(3)
socialfeed.init() //Always call this last

</script>

Make sure you're calling the gAjax script correctly.

Strangeplant
11-02-2007, 01:53 PM
Thanks for the test.....I discovered something strange about the way the DD script works. If the feed before Google has only one item, then that Google feed will show only one item. If the feed before Google has 4 items, then the Google line will show four items, etc. If I put it in as the first line, it will display 6 items. I haven't been able to figure out what's going on, but there is definitely something controlling the number of elements retrieved from the feed and apparently by the number of elements in the previous line. The lines that I'm using for testing are:
socialfeed.addFeed("NASA", "http://www.nasa.gov/rss/image_of_the_day.rss")
socialfeed.addFeed("A", "http://modis.gsfc.nasa.gov/rss/rss.xml")
socialfeed.addFeed("B", "http://earthobservatory.nasa.gov/eo.rss")
socialfeed.addFeed("C", "http://www.nasa.gov/rss/NASAcast_video.rss")
socialfeed.addFeed("D", "http://feeds.foxnews.com/foxnews/science")
socialfeed.addFeed("E", "http://news.google.com/news?hl=en&ned=us&q=modis+image&ie=UTF-8&output=rss")
socialfeed.addFeed("F", "http://news.google.com/news?hl=en&ned=us&q=modis+fire&ie=UTF-8&output=rss")
socialfeed.addFeed("G", "http://news.google.com/news?hl=en&ned=us&q=modis+dust&ie=UTF-8&output=rss")
socialfeed.addFeed("H", "http://rss.news.yahoo.com/rss/oped")
socialfeed.addFeed("I", "http://rss.news.yahoo.com/rss/climatechange")
socialfeed.addFeed("J", "http://rss.news.yahoo.com/rss/pollution")
socialfeed.addFeed("K", "http://rss.news.yahoo.com/rss/environment")
This isn't the order that I had them in originally, but try it out and you will see that the number of elements displayed for the different topics change with the order in the script.....

ddadmin
11-02-2007, 11:50 PM
Hmm I'm still not quite sure what I should be looking for in terms of an error. I tried the feeds code you posted above, and even altered some of their positions- the script manages to display them correctly. That is to say, 3 per page.

Note that how many entries show up are controlled by the lines:


socialfeed.filterfeed(15, "label") //Show 15 entries, sort by label
socialfeed.entries_per_page(3)

In the above case, it means 3 entries per page, 5 pages total. However, consider if instead of 15, you had entered 8. Since 8 doesn't divide into 3 exactly, what you end up with is 3 entries for the first 2 pages, then 2 entries on the final. Not sure if this is the issue you're talking about.

Strangeplant
11-06-2007, 03:49 PM
OK, I'll deal with it, but its strange.

If I have 9 feeds, A, B, C, D, E, F, G, H, I and specify 60 entries, I get 6, 6, 4, 1, 6, 6, 6, 6, 12 items - total 49.

If I have the same 9 feeds in a different order, B, C, D, E, F, G, H, I, A and specify 60 entries, I get 6, 4, 1, 6, 6, 6, 6, 6, 10 items - total 51.

If I have the same 9 feeds in the first order, A, B, C, D, E, F, G, H, I and specify 40 entries, I get 4, 4, 4, 1, 4, 3, 4, 4, 8 items - total 38.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, my real problem is this: If I have a news feed search that sometimes has content, but not always, then the whole script hangs on loading when there are no items returned. The reason: I want to try to narrow the search down so it won;t return too much irrelevant junk, but still show content. (The whole news topic is atmospheric science - not weather, so I have to do multiple searches by keywords that are not always in the news.)

(Of course there is still the annoying problem that some feed dates don't show - error, as at http://modis.gsfc.nasa.gov/rss/rss.xml They must use some other date format.)