How to change JQuery Terminal prompt from another function? -


i using http://terminal.jcubic.pl/ create jquery terminal.

i want change prompt after user logged in. example. want change prompt root@mac #:

i bit new jquery. please help.

// how create terminal

var terminal = $('#jq_terminal').terminal(function(command, term) {         term.echo("you typed " + command);     }, {           login: f_login,          greetings: "you authenticated",         prompt: '#',         name: 'shell',             onblur: function() {                     return false;                 }     });  // login  function f_login(user, password, callback) {         // make soket.io call here. socketio call f_login_response }  // login response here function f_login_response(user, password, callback) {        // how change terminal prompt here ?     // tried      terminal.prompt = '$'; // not work } 

the prompt can function:

var login = false; var terminal = $('#jq_terminal').terminal(function(command, term) {     term.echo("you typed " + command); }, {       login: f_login,      greetings: "you authenticated",     prompt: function(callback) {        callback(login ? '#' : '$');     },     name: 'shell',     onblur: function() {         return false;     } }); 

you can use terminal.set_prompt('#');. can't access terminal in login function code code should authenticate.apply(self, ....) can this.set_prompt (i need fix that) should able access terminal if assing var did (and in example code). should work:

function f_login_response(user, password, callback) {    terminal.set_prompt('$');    //or    login = true; } 

also if want have 2 type of commands logged in users , guests can like:

function(commad, term) {    var cmd = $.terminal.parsecommand(command); // parsecommand helper process command line (you have splitcommand don't convert numbers , regexes    if (cmd.name == 'login') {        term.push(function(command) {           term.echo("you type normal command");        }, {            prompt: '#'            // need add login option `push` can term.push('foo.php', {login:true});        }).login(function(user, password, callback) {           if (<< user ok >>) {              callback('token');            } else {              callback(null); // callback have second parameter if use true not give error message           }        });    } else {        term.echo("you type guest command");    } } 

ps: in unix $ normal users , # root.

edit: version 0.8.3 can call:

term.push('rpc_service.php', {login: true}); 

and

login(user, pass, callback) {    this.set_prompt('#'); } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -