Why does this jqueryterminal cmd function not work?

632 views Asked by At

I have this, which I edited from the latest zip of the JQueryTerminal code:

<html>
<head>
  <meta charset="utf-8" />
  <title>JQuery Terminal Emulator Demo</title>
  <script src="../js/jquery-1.7.1.min.js"></script>
  <script src="../js/jquery.mousewheel-min.js"></script>
  <script src="../js/jquery.terminal.min.js"></script>
  <link href="../css/jquery.terminal.css" rel="stylesheet"/>
    </head>

    <body>
    <div id="some_id"></div>
</body>


    <script>

    $('#some_id').cmd({
        prompt: '> ',
        width: '100%',
        commands: function(command) {
            //process user commands
        }
    });

</script>
</html>

The .cmd was taken directly from the website at http://terminal.jcubic.pl/api_reference.php#cmd. Why am I getting this in Firefox's Javascript console:

TypeError: $ is undefined[Learn More] jquery.terminal.min.js:36:23429

Thanks!

Edit:

I shouldn't be getting a 404. I based that on the tilda-demo.html file in the examples folder and put it in the same folder. And I just checked Developer Tools. No 404. Could there be any other reason?

Edit:

Here's more of the error message:

ke file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656/js/jquery.terminal.min.js:36:23429 dispatch file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656>/js/jquery-1.7.1.min.js:3:4299 i file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656/js/jquery-1.7.1.min.js:3:311

Just for the record, I get this in Chrome Canary when I type 'ASDSF':

jquery.terminal.min.js:36 binded jquery.terminal.min.js:36 true jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'A' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'S' > of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'D' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'S' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'F' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3)

1

There are 1 answers

2
Arnaldo Montoya On

Thanks for your post, @jcubic. I found the solution. I needed to add keymap. Now it works perfectly. The code now looks like this:

$('#some_id').cmd({
    prompt: '> ',
    width: '100%',
    keymap: function(command) {
    },
    commands: function(command) {
            console.log(command);
    }
});