Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

widget.system asynchronous use from javascript object not working



I'm trying to call widget.system asynchronously from a _javascript_ object but I cannot get it to work properly.
It does work if I specify null instead of an endhandler but since we are not supposed to use null anymore I would like to do it "the proper way" even from within an object.

Here is the problematic section of my source code (_temporaryGetUserName crashes the widget):

function XmltvBack() {
    this._userID = "";
    this._temporarySystemCall;

    this._doneButton = new AppleGlassButton( document.getElementById("backDoneButton"),"Done",this.doneButtonPressed());
    this._usersChannels = new Array();
    this._usersChannelsHash = new Array();
    this._channelsXmlIsReady = false;
    this._channelsXml;
   
    this._temporaryInstaller();
   
}

var globalXmltvPath;

XmltvBack.prototype._temporaryInstaller = function(){
    document.getElementById("debug").innerHTML = "_temporaryInstaller körs";
    if(window.widget){
        document.getElementById("debug").innerHTML = "username = "+widget.system("/usr/bin/id -un", null).outputString; // Works!
        this._temporarySystemCall = widget.system("/usr/bin/id -un", this._temporaryGetUserName()); // Does start the endHandler but this._temporarySystemCall is undefined - why? :-(
    } else
        this._temporaryGetUserName();
}

XmltvBack.prototype._temporaryGetUserName = function(){
    document.getElementById("debug").innerHTML = "_temporaryGetUserName running";
    if(window.widget){
        document.getElementById ("debug").innerHTML = "_temporaryGetUserName is about to save this._userID";
        this._userID = ""+this._temporarySystemCall.outputString; // Row 29. Crashes the widget since this._temporarySystemCall is undefined
        document.getElementById("debug").innerHTML = "userID= "+this._userID;
    } else {
        this._userID = "gusax840";
        alert("_continueStartup running");
    }
    globalXmltvPath = "/Users/"+this._userID+"/Library/Xmltv/";
    this._channelsXml = new XmltvChannelsXml(globalXmltvPath+"server/channels.xml",this);
}

I've attached the widget as a zip file. The above code can be found in _javascript_/XmltvBack.js starting on row 1. Please note that the widget will crash on row 29 if you open it in Dashboard. It works in Safari though, if you want to see how it should look like.

Gustav

Attachment: Xmltv 2.zip
Description: Zip archive

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.