Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

Multiple RSS Feed Widget

Author Message
jpgodlew



Joined: 25 Jul 2005
Posts: 1
Location: USA

Posted: Mon Jul 25, 2005 - 11:07 am    Post subject: Multiple RSS Feed Widget Reply with quote

Hey everyone,
I'm having some trouble with a widget I am working on right now. It's a simple little widget that uses XMLHttpRequest to get the current contents of a php file. The widget is working fine with 1 feed, but what I want to do is have a preference menu on the back where users can select one of 3 feeds they want to view. All my attempts thus far have failed, and I'm kinda at a loss for what to try next. All I need this thing to do is change a variable to the user-selected feed! Here's some of the code I have so far:

HTML File
Code:

<body onload="loadXMLDoc()">

      <div id="widget" onmousemove='mousemove(event);' onmouseout='mouseexit(event);'>
        <div id="switch"></div>
        <div id="T1" class="left_news"></div>
        <div id="right_rss" onclick="txtlink();"></div>
      <div class='flip' id='fliprollie'></div>
      <div class='flip' id='flip' onclick='showPrefs(event);' onmouseover='enterflip(event);' onmouseout='exitflip(event)';></div>
        </div>


        <div id="back_widget">
        <img span="backgroundImage" src="Backside.png">
         <form name='feedURL' action='javascript:saveURLPref();'>
         <select name="feedURL">
         <option value="http://www.feed.foo/widgetdata.php">News</option>
         <option value="http://www.feed.foo/widgetdata2.php">Articles</option>
         <option value="http://www.feed.foo/widgetdata3.php">Both</option>
         
         </select>
         </form>
        <img class="doneButton" src="Done.png" onclick='hidePrefs()' />
        </div>
      
</body>


JS File
Code:

function loadXMLDoc()
{

if(window.widget)
{
    var url = widget.preferenceForKey("rssFeedurl");
    if (url && url.length > 0)
    {
        urlText.innerText = urlString;
    }
}

    xmlhttp = new XMLHttpRequest();
    xmlhttp.overrideMimeType("text/xml");
    xmlhttp.onreadystatechange = processReqChange;
    xmlhttp.open("GET", url, true);
    xmlhttp.setRequestHeader("Cache-Control", "no-cache");
    xmlhttp.send(null);
   
}

function processReqChange() {
    // only if xmlhttp shows "loaded"
    if (xmlhttp.readyState == 4) {
        // OK
        if (xmlhttp.status == 200) {
            document.getElementById('T1').innerHTML=xmlhttp.responseText;
        } else {
            alert("Connection to the news server has failed:\n" + req.statusText);
        }
    }
}

widget.onshow = function() {

loadXMLDoc();

}

function saveURLPref(){
   if (window.widget){
      widget.setPreferenceForKey(document.feedURL.feedURL.value, rssFeedurl);
   }
}

loadXMLDoc is called when the <body> of the widget is opened.

Thanks a ton!
~Joe
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group