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

Displaying internet content in Dashboard?

Author Message
skyhawkrider



Joined: 06 Jul 2005
Posts: 20
Location: Boulder, CO

Posted: Wed Jul 13, 2005 - 3:51 pm    Post subject: Displaying internet content in Dashboard? Reply with quote

I'm trying to find out a way to display content from the Internet and put it in Dashboard (ex: The Wikipedia widget). I have absolutely no idea how to do it, but does anyone how to do it, or show me a site that does know how?

Thanks.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
snyvlboi



Joined: 16 May 2005
Posts: 20
Location: Sunnyvale, CA

Posted: Wed Jul 13, 2005 - 7:48 pm    Post subject: Mac OS X Technology Guide to Dashboard, Danny Goodman Reply with quote

Answers your question, and about 90% of the other questions in this forum.
View user's profile Send private message Send e-mail AIM Address Widgets
sean



Joined: 22 Apr 2005
Posts: 67
Location: Duluth, MN

Posted: Wed Jul 13, 2005 - 8:34 pm    Post subject: Reply with quote

If you aren't interested in buying a book, take a look inside a couple of the widgets that have already accomplished this. Open up the Wikipedia.wdgt bundle, and look in the Main.js file. I'll quickly walk you through the basic steps it goes through to grab pages from wikipedia.org and display them: (I won't go into the technical details, but I can clarify if anything isn't quite clear)

1. requestArticle() requests the page from wikipedia.org, and triggers checkRequestResponse() each time the 'readyState' changes. (read more about xmlhttprequest at http://developer.apple.com/internet/webcontent/xmlhttpreq.html )

2. When checkRequestResponse sees that the readyState is 4 (i.e. 'complete'), and the status code returned by the web server is '200' (OK), it passes the responseText to the processRawHTML() function.

3. processRawHTML() clips the html source to just the part that appropriate to display - in wikipedia's case, everything between '<h1 class="firstHeading">' and '<!-- end content -->'. What you do here on what information you're grabbing from where, and what their html looks like.

4. The clipped html is passed to displayContent(), which basically just does this: document.getElementById('content').innerHTML = input;
There's a div with the id "content" in the wiki.html file, where everything is displayed.


Well, I hope this helps at least a bit. It's really not that complicated once you familiarize yourself with xmlhttprequest. You're welcome to use any code from the Wikipedia widget (I wrote it), if you would like. I admit, the code has become a bit of a mess, but you might be able to weed through it Wink. If you have any questions, post here and I'll do my best to answer them.
View user's profile Send private message Send e-mail Visit poster's website 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