Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,615 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,979 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



RSS data source for ticker

 
Reply to this topicStart new topic

RSS data source for ticker

deejio
post 27 Jun, 2008 - 07:24 AM
Post #1


New D.I.C Head

*
Joined: 27 Jun, 2008
Posts: 2

I have obtained a free ticker from www.mioplanet.com.
My aim is to try and link the ticker to an RSS news data source (such as CNN), but I don't know how to go about doing this. Any help would be appreciated. The code for the ticker follows below.

Also, I'd like to use a javascript solution (not PHP, despite it's advantages - it's just something I'm not familiar with and would take ages to set up a solution to include PHP in an HTML document).

CODE


TICKER_CONTENT = document.getElementById("TICKER").innerHTML;
TICKER_RIGHTTOLEFT = false;
TICKER_SPEED = 2;
TICKER_STYLE = "font-family:Arial; font-size:12px; color:#444444";
TICKER_PAUSED = false;

ticker_start();

function ticker_start() {
    var tickerSupported = false;
    TICKER_WIDTH = document.getElementById("TICKER").style.width;
    var img = "<img src=ticker_space.gif width="+TICKER_WIDTH+" height=0>";

    // Firefox
    if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
        document.getElementById("TICKER").innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
        tickerSupported = true;
    }
    // IE
    if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
        document.getElementById("TICKER").innerHTML = "<DIV nowrap='nowrap' style='width:100%;'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'></SPAN>"+img+"</DIV>";
        tickerSupported = true;
    }
    if(!tickerSupported) document.getElementById("TICKER").outerHTML = ""; else {
        document.getElementById("TICKER").scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth : 0;
        document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
        document.getElementById("TICKER").style.display="block";
        TICKER_tick();
    }
}

function TICKER_tick() {
    if(!TICKER_PAUSED) document.getElementById("TICKER").scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
    if(TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft <= 0) document.getElementById("TICKER").scrollLeft = document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth;
    if(!TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft >= document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth) document.getElementById("TICKER").scrollLeft = 0;
    window.setTimeout("TICKER_tick()", 30);
}
User is offlineProfile CardPM

Go to the top of the page


level1
post 27 Jun, 2008 - 09:47 AM
Post #2


New D.I.C Head

*
Joined: 12 Jun, 2008
Posts: 34



Thanked 5 times
My Contributions


Here is a page that outlines a technique using ajax and 2 iframes to get an rss feed from an external server. I'm going to have to reread this one next week or so when I do my own project. Once you get the rss feed working you should be able to just pop it in to your TICKER div.

http://fettig.net/weblog/2005/11/28/how-to...in-your-domain/



ALternatively, if the rss feed has an xml style sheet you can just put an iframe inside of your TICKER div - assuming the feed you find is in the format you are looking for. Boy, that sure would help a lot - so, I'm guessing you will have to read that article.

Good luck!!!
User is offlineProfile CardPM

Go to the top of the page

deejio
post 28 Jun, 2008 - 09:44 AM
Post #3


New D.I.C Head

*
Joined: 27 Jun, 2008
Posts: 2

Thanks level1,

My situation has improved slightly since then. I've created a feed data source using a third party RSS aggregator called feedburner. I have the address of the feed source now, so as you say, stuck it between my ticker DIV tags (the ticker itself works fine). The problem now, is that the entire page of xml is being displayed in the ticker, so instead of one news item at a time, I get a massive chunk of text floating across the screen.

I've cut back on the feed to include only a few news items, the source can be seen here: http://feeds.feedburner.com/bannedmedia?format=sigpro

This is the bit of DIV code as it stands. Have I done something wrong?

CODE
<DIV ID="TICKER" STYLE="overflow:hidden; width:100px; height:100px" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false">
<script language="javascript" src="http://feeds.feedburner.com/bannedmedia?format=sigpro"></script>
</DIV>
User is offlineProfile CardPM

Go to the top of the page

shadowBean
post 8 Jul, 2008 - 09:18 PM
Post #4


New D.I.C Head

*
Joined: 14 Jun, 2008
Posts: 27


My Contributions


I am also working on the same thing.
It'd be interesting to see the solution.

Thank you deejio.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 11:58PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month