PDA

View Full Version : Dashcode (Beta) Officially Released




mduser63
Dec 21, 2006, 06:33 PM
It was leaked a long time ago and its existence was leaked even before that, but Dashcode is now officially available in beta from Apple. You have to have an ADC account (free membership is fine) to get it. It's on the ADC site under downloads. I just downloaded it. I've been wanting to create a widget to go with the app I'm developing. That'll give me a project to work on in order to learn how to use Dashcode.



steelphantom
Dec 21, 2006, 07:48 PM
Nice! Downloading it right now. I just hope I can make something that doesn't suck. :D

bronxbomber92
Dec 21, 2006, 08:05 PM
Yay. going to download right now :D

monke
Dec 21, 2006, 08:20 PM
Thanks for the heads up mduser63! Downloading now. :)

Chundles
Dec 21, 2006, 08:24 PM
Downloading now.

Let's see how well this works shall we? I wonder if it's the same version that shipped in the early MacBooks?

Chundles
Dec 22, 2006, 06:09 AM
Anybody know how to add an "Uptime" indicator to the gauge widget?

mduser63
Dec 22, 2006, 11:56 AM
Anybody know how to add an "Uptime" indicator to the gauge widget?

The way they're doing things in the default gauge is by running command line tools then processing the output to get the data they need. "uptime" is the command-line tool to find uptime. I don't know javascript really at all, so I'd have a hard time rewriting their code, but it's basically just a matter of modifying one of their handler functions to run uptime and process its output.

In the gauge prototype, check out CommandMonitor.js. For example, this is used to do the disk activity gauge:

function IOStatMonitor (frequency) {
this.commandLine = "/usr/sbin/iostat -d -C -w " + frequency;
}

IOStatMonitor.prototype = new CommandMonitor();

IOStatMonitor.prototype.processLine = function (line)
{
// KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id
// 20.06 5 0.09 9.70 0 0.00 10.67 0 0.00 4 3 92

// Take off leading and trailing spaces
line = line.replace(/^\s+/, "");
line = line.replace(/\s+$/, "");

// Look for a line of numbers
var match;
if ((match = line.match(/^(\s*[\d\.]+)+$/)) != null) {
var n = match[0].split(/\s+/);

if (n.length > 0 && n.length % 3 == 0) {
// Add up all the MB/s numbers
var mbps = 0.0;
for (var i = 2; i < n.length - 3; i += 3) {
mbps += parseFloat(n[i]);
}

// Grab the inverse of the CPU idle time and call it load
var load = 100 - parseInt(n[n.length - 1]);

// alert("disk io: " + mbps + ", load: " + load);
if (this.ioCallback != null) {
this.ioCallback(mbps);
}
if (this.loadCallback != null) {
this.loadCallback(load);
}
}
else {
alert("iostat format violation: expecting groups of three:");
alert(line);
}
}
}


Dashcode looks good. Easy to use and powerful. However, I think it's going to require a fairly good knowledge of JavaScript. Oh well, that gives me something new to learn!

Mac_Freak
Dec 22, 2006, 12:28 PM
...You have to have an ADC account (free membership is fine) to get it. ...

Free ADC membership account? It is the first time I hear of it. Where do you sign up for it? I can't find it.


EDIT: Nevermind, I found it. Thanks for sharing. :D