View Full Version : Swell Widget Development

27th May 2005, 11:17 AM
I'm currently in the design and development stage of a NEW swell widget. So far I've got a simple design, and have a rough idea what I want it to do. But need a little help on making the rest happen. I've only had my new PB for 3 weeks and I'm a first time mac user. So at the moment don't really know much.

So Far:
- Got a basic layout for the widget.
- Can flip it over and select state and it changes the front information.

Still to do:
- Add swell lines to the background...something to make it look good.
- Add a more glassy feel to the widget.
- Link data to either swellnet.com.au or coastalwatch.com.au (both have no rss feed - does that make it too hard to do?)
- Additional information for current conditions (swell size, wind direction, weather)
- Add a 5 day outlook graph or table in the space under currect conditions.
- Make it the BEST swell widget....actually it'll be the ONLY swell widget.

Swell Widget Front View (http://home.iprimus.com.au/cmreid/3.png)
Swell Widget Back View (http://home.iprimus.com.au/cmreid/1.png)
Swell Widget States View (http://home.iprimus.com.au/cmreid/2.png)

So what do you think? Can you give me any help on development? Possibly on how to get the data from either sites so its updated dynamically? What could I do better? Or would should I leave out?

Please don't steal my idea!



27th May 2005, 11:26 AM
Great idea (it's ok, I'm not going to steal it though!).

I'm not sure where you'd find the data. iSlayer may be able to help on what you'll be looking for, but I think XML feeds from the BOM would be your best bet. I'm not a coder, so I don't really know too much about it.

I think it's coming along nicely. My one suggestion would be to make the front a bit smaller... I think widgets should only take up as much space as they need to convey the data.

Good luck.

27th May 2005, 11:52 AM
Yeah I have a bit of space allocated at the bottom of the widget for when I put in the 5 day outlook part. Once I know what that will look like I will cut down the size if need be.

But its a good point. I was even thinking of making the current conditions smilar to the weather widget and then once you clicked on it the 5 day out look would slide down. But I'm not sure how hard that is to achieve.

27th May 2005, 01:27 PM
iSlayer do you have any tips for gathering data from either swellnet.com.au or coastalwatch.com.au. Both have no rss feeds. Can you grab data from a specified html page and dispaly it?

27th May 2005, 07:05 PM
have NO idea of you could use the data from www.surfit.com.au but thats alllways got a great bunch a reports. reliable, accurate and simple yet comprehensive. and they report on specific beaches, although maybe too detailed for what youre looking to use?

also check out the link they have on that site to "virtual buoys 3 day forecast", i tried to copy the link but didnt work, its a site that gives a good prediction of swell height and direction in 6 hr blocks for the next half a week, for different locations. once again dunno if you could use that data...

spose tho i rekon if u manage to score the data off swellnet you wouldnt need much more...

good luck, i would massively use this if u manage to get it up and running. all i need is tiger and a broadband connection :(

27th May 2005, 08:10 PM
In my Konfabulator widget I grab info from iiNet's website using regular expressions as implemented in javascript.

They're not exactly fun, and I only barely understand them, but managed to work it out with some trial and error.

Just look at surfit.com.au's website source to work out what text you're searching for, then use trial and error (and a book on regexp) to come up with your search pattern.

27th May 2005, 09:27 PM
There are a few ways you can get the data, provided you ensure you are not breaching copyright.

If in theory you ran a swf decompiler you may find that the data in the flash movie on the swellnet.com.au site is loaded in a text file, such as:


Of course you may want to ask for permission.

Alternatively you could screen scrape the data from coastalwatch.com.au, but I wouldn't recommend this from a data integrity perspective.

30th May 2005, 10:32 AM
Being so new to Mac and development in Mac does anybody have any example of how to create a Widget Plugin for what I want to do?

I'm assuming I will need a Widget Plugin (developed in cocoa) that can be connected to my Swell widget to grab all my information from a text file. As you can't open and read from a text file in js.

Does anyone have a guide of creating these widget plugins?

And also a guide to opening files in cocoa, filtering them and then returning the data?


nathn - inexperienced in mac :)

ps. I have contacted ben at swellnet and he is quite interested in what I can do.

30th May 2005, 11:17 AM
If you can't rip it from their page using a scripting language, then you'll need to see to those ppl at swellnet.

If he's keen, you should get them to publish a text file with the data, so your script can work from that.

edit: grammar

30th May 2005, 11:26 AM
If he's keen, you should get them to publish a text file with the data, so your script can work from that.

The site already has a link to the data in a text file. Here Swellnet QLD Swell Data (http://swellnet.com.au/qld.txt).

But I'm not too sure how to go about grabing that data now, and returning it to my javascript. You can't read from a text file in javascript...I'm pretty sure you can't.

That's the only part I'm stuck on. Displaying it is no worries, but retrieving it to my js is a problem.

30th May 2005, 11:41 AM
Yeh Javascript is such a crap language in that respects ...

There's a couple of ways of doing it ...

Use PHP and get the Output returned

var Data = widget.system("/usr/bin/php myscript.php", null).outputString;

Use JS with XMLHttpRequest
http://developer.apple.com/internet/webcon...xmlhttpreq.html (http://developer.apple.com/internet/webcontent/xmlhttpreq.html)

Let us know if you get stuck.

30th May 2005, 12:04 PM
I tried using JS with XMLHttpRequest on the weekend, but couldn't get anything returned. Followed through the same link you posted, but it didn't help. Haven't tried using PHP though, would that be a hassel when trying to package the widget up so others can use it?

Will have another go tonight, once I return from work with the JS XMLHttpRequest. But I don't like my chances.

I'll let you know what the status asap.


30th May 2005, 01:06 PM
I'm using the PHP method in my SEQLDLT widget, mainly because, the image on their web site has a randomly changing name, so you couldn't just link the image.

The PHP script is used to "look" into the html file, find the bit I want and display that.

If you need to download the file to your local system first ... then work on it, you can use the unix command "curl" to download the file.

Also, this stumped me for ages ... in your plist file if you reference local files in your widget, you need to have AllowFullAccess as Yes. I've done that on a new widget I'm currently working on, hopefully, I'll have it finished this week.

7th June 2005, 11:52 PM
I'm looking forward to this widget - good luck mate

What I really wanna see though is a Sydney surf cam widget... that'd flick between different beaches (preferably those which you choose it too)..!! That'll always be the dream though I'm thinkin..

3rd August 2005, 02:28 AM
any news on this one?

im ready and waiting now!!