Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 19, 2007, 09:33 PM   #1
macrumors 6502
Join Date: Apr 2005
Location: London, UK
Send a message via AIM to fitinferno
Help w/Dashcode Widget: Ping & Refresh to Indicate Status

Hello all. Wondering if anyone can help me out w/this as I've been googling and learning all the js I can, but still can't seem to figure things out

Basically, I am trying to make a widget that will show the status of 9 computers on my network I am required to monitor. I have a feeling that by pinging the computers every 5 minutes or so and seeing if it gives a response that will let me know whether it's funcitioning properly or not (my job is just to make sure they stay connected to the network).

So, I've gone into the custom widget on Dashcode. I've gotten far enough to make a widget that has the 9 indicator buttons and then let them know that at a certain range in value 0 I want it to go green or red. However, I have no idea what to tell it so that I can have the ping status reflected as that green or red indication.

Here's my js code for the widget. At the bottom is the silly attempt I've made at adding in a refresh, but I don't think it's what I'm looking for (to be honest, I just cut it from another widget ). I really feel thick as this sounds so simple!

// This file was generated by Dashcode from Apple Computer, Inc.
// You may edit this file to customize your Dashboard widget.

function load()

function remove()
// your widget has just been removed from the layer
// remove any preferences as needed
// widget.setPreferenceForKey(null, createInstancePreferenceKey("your-key"));

function hide()
// your widget has just been hidden stop any timers to
// prevent cpu usage

function show()
// your widget has just been shown. restart any timers
// and adjust your interface as needed

function showBack(event)
// your widget needs to show the back

var front = document.getElementById("front");
var back = document.getElementById("back");

if (window.widget)


if (window.widget)
setTimeout('widget.performTransition();', 0);

function showFront(event)
// your widget needs to show the front

var front = document.getElementById("front");
var back = document.getElementById("back");

if (window.widget)


if (window.widget)
setTimeout('widget.performTransition();', 0);

if (window.widget)
widget.onremove = remove;
widget.onhide = hide;
widget.onshow = show;
function show ()
document.getElementById("indicator").object.setValue(1);document.getElementById("indicator1").object .setValue(1);document.getElementById("indicator2").object.setValue(1);document.getElementById("indic ator3").object.setValue(1);document.getElementById("indicator4").object.setValue(1);document.getElem entById("indicator5").object.setValue(1);document.getElementById("indicator6").object.setValue(1);do cument.getElementById("indicator7").object.setValue(1);document.getElementById("indicator8").object. setValue(1);

function refreshState() {
if(refreshBlocked) {
countdownCalledWhileBlocked = true;
seconds_left = 0;
countdownCalledWhileBlocked = false;

currentlyRefreshingState = true;
setTimer("in progress...");
the_timeout = null;

// get Location

// setup internal and external IPs (calls checkWAN() on itself)

// call if refresh ended
function refreshEnded(seconds_already_set) {
lastRefresh = new Date();
getObj("lastRefresh").innerHTML = formatDate(lastRefresh, true);

currentlyRefreshingState = false;
if(!seconds_already_set) {
seconds_left = original_timer;

setTimeout("adjustTotalSize(-1)", ANIM_DEF_TIME);
setTimeout("countdown()", 10);
fitinferno is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
GCD, runloop & background app refresh ChristianJapan iPhone/iPad Programming 0 Mar 19, 2014 07:20 AM
Status bar app that display network ping? yalag OS X Mavericks (10.9) 5 Dec 9, 2013 07:36 PM
Extremely high ping & low speed with Time Capsule The.316 Mac Basics and Help 0 Sep 19, 2013 03:25 PM
iPhone: Dashboard X Weather Widget Refresh Time? joshwithachance Jailbreaks and iOS Hacks 3 Feb 23, 2013 06:30 PM

Forum Jump

All times are GMT -5. The time now is 05:17 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC