开发者

console-like interface on a web page using javascript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

I very like MySQLs mysql cli tool and I don't like phpMyAdmin. [IMHO]It's a nice thing for a Windows user, but its not so good when you've used to console.[/IMHO].

What I want is to build a web page containing element with console-like input (for example something like this) which should get input from user, send it to PHP script on back-end and show back-end response.

Back-end script is done (it was the easiest part), but I can't find any library for JavaScript implementing console-like input.

I've tried to examine and modify for my needs example I've provided, but it's too bloated (because doesn't use any libraries) and implements specific thing. Also I would like this element to provide some auto-completion for input.

Any ideas on such JS librar开发者_StackOverflow社区y?


I think you are looking for this: jQueryTerminal


there is shellinabox - javascript terminal.

EDIT:

There is also library xterm.js that's real terminal emulator.

EDIT 2:

My jQuery Terminal library is useful when you need custom behavior and you can write your code in JS or as backend code, but backend need to be simple input -> output, if you want to run for instance interactive backend commands, like vi or emacs, you need proper tty, for this use xterm.js (or implement that in JavaScript) for any other usage jQuery Terminal is better. It have lot of features and you don't need to run process on the server (listen on a port) which usually is forbidden on shared hostings or GitHub pages.


instead of using console.log() use document.write()

It will write text on the webpage just like console.log would in the console


I've made a console library called Simple Console (I'll probably rename it because simple-console is taken on npm)

It handles command history and such for you, and you can use it to implement any kind of console.

var handleCommand = (command)=> {
    var req = new XMLHttpRequest();
    req.addEventListener("load", ()=> {
        con.log(req.responseText);
        // TODO: use con.error for errors and con.warn for warnings
        // TODO: maybe log a table element to display rows of data
    });
    // TODO: actually pass the command to the server
    req.open("GET", "mysql.php");
    req.send();
};
var con = new SimpleConsole({
    handleCommand,
    placeholder: "Enter MySQL queries",
    storageID: "mysql-console"
});
document.body.appendChild(con.element);

Check out the documentation on GitHub for more information.


hmm firebug console ?

http://getfirebug.com/commandline

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜