Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sunnyboi14

macrumors newbie
Original poster
May 29, 2008
1
0
Im making a widget that opens any application when you type it in. I would like to know what is wrong with my widget, considering when i type in the text field, and press open, nothing happens. Here is my code.

Code:
/* 
 This file was generated by Dashcode.  
 You may edit this file to customize your widget or web page 
 according to the license.txt file included in the project.
 */

//
// Function: load()
// Called by HTML body element's onload event when the widget is ready to start
//
function load()
{
    dashcode.setupParts();
}

//
// Function: remove()
// Called when the widget has been removed from the Dashboard
//
function remove()
{
    // Stop any timers to prevent CPU usage
    // Remove any preferences as needed
    // widget.setPreferenceForKey(null, dashcode.createInstancePreferenceKey("your-key"));
}

//
// Function: hide()
// Called when the widget has been hidden
//
function hide()
{
    // Stop any timers to prevent CPU usage
}

//
// Function: show()
// Called when the widget has been shown
//
function show()
{
    // Restart any timers that were stopped on hide
}

//
// Function: sync()
// Called when the widget has been synchronized with .Mac
//
function sync()
{
    // Retrieve any preference values that you need to be synchronized here
    // Use this for an instance key's value:
    // instancePreferenceValue = widget.preferenceForKey(null, dashcode.createInstancePreferenceKey("your-key"));
    //
    // Or this for global key's value:
    // globalPreferenceValue = widget.preferenceForKey(null, "your-key");
}

//
// Function: showBack(event)
// Called when the info button is clicked to show the back of the widget
//
// event: onClick event from the info button
//
function showBack(event)
{
    var front = document.getElementById("front");
    var back = document.getElementById("back");

    if (window.widget) {
        widget.prepareForTransition("ToBack");
    }

    front.style.display = "none";
    back.style.display = "block";

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

//
// Function: showFront(event)
// Called when the done button is clicked from the back of the widget
//
// event: onClick event from the done button
//
function showFront(event)
{
    var front = document.getElementById("front");
    var back = document.getElementById("back");

    if (window.widget) {
        widget.prepareForTransition("ToFront");
    }

    front.style.display="block";
    back.style.display="none";

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

if (window.widget) {
    widget.onremove = remove;
    widget.onhide = hide;
    widget.onshow = show;
    widget.onsync = sync;
}




function OpenButton(event)
{
    // Values you provide
var textFieldValue = document.getElementById("Appwhat");	// replace with ID of text field

    // Text field code
textFieldValue = textFieldValue.value;

    // // Values you provide
var applicationIdentifier = "com.apple.(textFieldValue)";	// replace with the identifier of the application to show

// Show website code
widget.openApplication(applicationIdentifier);
}

}

Note - I think the problem is at the bottom.
 

BrianSullivan

macrumors newbie
Dec 26, 2008
8
0
PA
i would try something like this:

Get the value, and then use that value to set something else. Merge it with the open application code in the code section of dashcode's library.
<start code>
function myfunctionname(event)
{
// GET
var textFieldValue = document.getElementById("appnameinput"); // replace with ID of text field (type in)

// field code
textFieldValue = textFieldValue.value;

// SET
var textFieldToChange = document.getElementById("HOMESCORE"); // replace with ID of text field
var appCode /*REPLACE THE VAR __________ AS THE CODE OF THE APPLICATION CODE FOUND IN THE LIBARARY */ = document.getElementById("homescoretextfield"); // replace with ID of text field

// field code
textFieldToChange.value = appCode.value; //REPLACE THIS AS THE ABOVE VARIABLE

}


<end code>
I hope that helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.