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 Development

Gadget Creation Question

Author Message
Solsonic



Joined: 27 Mar 2005
Posts: 19
Location: California

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

Hello everyone,
I have created a konfabulator widget which allows you to see your Network IP as well as your External IP. I would like to make it work w/ Dashboard.The code to retrieve the IP's is a runCommand function for Unix, but its written in JS. I fiddled around a bit, trying to insert my code into the html document, but no luck my friends. I guess my question is how do I get it to Print the results of the command onto my UI. I'm a novice at programming, so I apalogise if this is a lame question. Any help would be awsome.

Steveo
View user's profile Send private message Send e-mail Visit poster's website Widgets
The Inn Keeper



Joined: 27 Mar 2005
Posts: 29
Location: Hawaii

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

Hi there Steveo - you said that you used the 'runCommand' function for Unix. And then you state that it is written in Javascript.

I could be wrong here, but I wasn't aware there was a runCommand javascript function. But if it is a javascript function, then it should work just fine in a gadget.

I think this would be a very useful gadget, so I hope you find the answer you are looking for!

PS: A more helpful subject may have gotten more posts Wink
View user's profile Send private message Widgets
Madmandan



Joined: 27 Mar 2005
Posts: 26

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

I did a quick Google search for you, and came up with this javascript to report an IP:

<script language="JavaScript"><!--
if (navigator.appName=='Netscape' && navigator.javaEnabled()) {
hn = java.net.InetAddress.getLocalHost().getHostName();
ha = java.net.InetAddress.getLocalHost().getHostAddress();
document.write('HostName: '+ hn + '<br>' + 'HostAddress: '+ ha );
}
//--></script>

However, it is stated that it only works with Netscape. I haven't had a chance to test this, but possibly it has been implemented by WebCore also.
View user's profile Send private message Widgets
Solsonic



Joined: 27 Mar 2005
Posts: 19
Location: California

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

Thanks for the fast reply guys, The "runCommand" function mabey exclusive to Konfabulator. Here is my code though so you guys can see what I mean.

[CODE]

function findIP() {
my_ip.data = runCommand("ipconfig getifaddr " + en0);

print ("ipconfig getifaddr " + en0 + " returned " + my_ip.data);
if (my_ip.data.slice(0, 11) == "get if addr")
my_ip.data = "No IP Found";
else {
name = runCommand('dig ' + my_ip.data + ' | grep Name: | sed "/Name: */s///g"');
if (name) my_ip.data = name;
}
}
[/CODE]

Thank again all.
View user's profile Send private message Send e-mail Visit poster's website Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

runCommand is just a Konfab thing as far as I know so the above wouldn't work. There's a couple of issues with IP addresses , though. ipconfig (why isn't ifconfig like on linux?) will only show you your local IP address, won't it - so if your connected via a LAN, you wont see your external one - which would probably be the one you wanted to see.
Here's my take on it:
Use a cocoa plug-in to the gadget to run ipconfig and get the IP address like that, then use XMLHTTPRequest to get the external IP address from somewhere like whatismyip.com, then compare the two. If they differ, then show a 'local IP: x.x.x.x, External IP: y.y.y.y' or something, if not, just have 'your IP is: z.z.z.z'.
What do you reckon?
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
Solsonic



Joined: 27 Mar 2005
Posts: 19
Location: California

Posted: Thu Jul 08, 2004 - 9:53 pm    Post subject: Imported from The Dashboader Reply with quote

I think thats the way to go. I just got to the part in the Gadgets Manual where it says:

" Gadgets alone cannot access applications directly,recieve distributed notifications, or read files from disk. To enable these interactions, you need to provide a plug-in."

So now I'll have to learn C to make the plug-in? Well, I'll keep at it. Thanks for the reply. .....Steveo
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