I Never Think - Part 1: runCommand VS sendCommand

<button href=\"#\" name=\"SCRIPT-GENERATED-COMMAND-NAME\" onclick=\"sendCommand(this.name);\" class=\"custom-cmd-button\">SCRIPT-GENERATED-COMMAND-DISPLAYED-TEXT</button>

I have been using sendCommand(this.name), but it looks like I should be doing this:

$('#txtCommand').val(this.name); runCommand();

Here are the functions.

Using sendCommand directly is bypassing lots of good code.

function runCommand() {
    var command = $("#txtCommand").val();
    if (command.length > 0 && canSendCommand) {
        numCommands++;
        commandsList[numCommands] = command;
        thisCommand = numCommands + 1;
        sendCommand(command);
        $("#txtCommand").val("");
    }
}

// FROM desktopplayer.js
function sendCommand(text, metadata) {
    markScrollPosition();
    var data = new Object();
    data["command"] = text;
    if (typeof metadata != "undefined") {
        data["metadata"] = metadata;
    }
    UIEvent("RunCommand", JSON.stringify(data));
}


// FROM "WebPlayer\player.js"
function sendCommand(text, metadata) {
    if (_pauseMode || _waitingForSoundToFinish || _waitMode || !canSendCommand) return;
    canSendCommand = false;
    markScrollPosition();
    window.setTimeout(function () {
        $("#fldUITickCount").val(getTickCountAndStopTimer());
        var data = new Object();
        data["command"] = text;
        if (typeof metadata != "undefined") {
            data["metadata"] = metadata;
        }
        $("#fldUIMsg").val("command " + JSON.stringify(data));
        $("#cmdSubmit").click();
    }, 100);
    afterSendCommand();
}


Or how about this (which wouldn't have to mess with anything in the text input box)?

function runClickCommand(command) {
    if (command.length > 0 && canSendCommand) {
        numCommands++;
        commandsList[numCommands] = command;
        thisCommand = numCommands + 1;
        sendCommand(command);
    }
}

Now I can't find the code that controls the onclick for the verbs menu in the object links in the main text.

I know I've located it before, but I've been searching for over an hour and finally gave up.

I have the directional buttons and the panes' verb links adding the commands to the history (for when you use the up arrow to access your entered commands), but I can't find the code for the verbs in the object links. I keep thinking I've found it, but nope.


Log in to post a reply.

Support

Forums