Giter Site home page Giter Site logo

ajhasa / ng-terminal-emulator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vtortola/ng-terminal-emulator

0.0 2.0 0.0 1.72 MB

AngularJS Terminal Emulator

Home Page: http://vtortola.github.io/ng-terminal-emulator/

License: MIT License

CSS 9.39% JavaScript 87.48% HTML 3.13%

ng-terminal-emulator's Introduction

ng-terminal-emulator

AngularJS Terminal Emulator.

Visit : http://vtortola.github.io/ng-terminal-emulator/ for a live demo.

Quick start

ng-terminal-emulator is a directive that emulates a command terminal in Javascript.

<div ng-controller="console">
    <terminal> </terminal>
</div>

The directive can transclude, so whatever content you put inside, will be shown as part of the component:

<div ng-controller="console">
    <terminal>
        <p class="click-me">Click me to start commanding !</p>
    </terminal>
</div>

In order to input and output text, you must communicate using .$broadcast()and .$emit() from the wrapper controller.

Send output to terminal

$scope.$broadcast('terminal-output', {
    output: true,
    text: ['Welcome to vtortola.GitHub.io',
           'This is an example of ng-terminal-emulator.',
           '',
           "Please type 'help' to open a list of commands"],
    breakLine: true
});

Get input from terminal

$scope.$on('terminal-input', function (e, consoleInput) {
        var cmd = consoleInput[0];
        
        // do stuff
});

Configuration

CSS

In order to customize the terminal look and feel, it is possible to configure the CSS class that the terminal element will have using the terminal-class attribute:

<terminal terminal-class="vintage-terminal">

</terminal>

Behaviour

In order to customize the terminal behaviour, it is possible to configure some behaviours in the terminal like:

  • Delay in ms between output chars.
  • Disable input while output is being print.
  • Set a sound that plays when the output is printing.
  • Set a sound that plays at the start.
.config(['terminalConfigurationProvider', function (terminalConfigurationProvider) {
    terminalConfigurationProvider.outputDelay = 10;
    terminalConfigurationProvider.allowTypingWriteDisplaying = false;
    terminalConfigurationProvider.typeSoundUrl ='example/content/type.wav';
    terminalConfigurationProvider.startSoundUrl ='example/content/start.wav';
}])

It is possible to use named configurations:

.config(['terminalConfigurationProvider', function (terminalConfigurationProvider) {
    terminalConfigurationProvider.config('vintage').outputDelay = 10;
    terminalConfigurationProvider.config('vintage').allowTypingWriteDisplaying = false;
    terminalConfigurationProvider.config('vintage').typeSoundUrl ='example/content/type.wav';
    terminalConfigurationProvider.config('vintage').startSoundUrl ='example/content/start.wav';
}])

And apply that configuration using the terminal-config attribute in the directive:

<terminal terminal-config="vintage">

</terminal>

Example

You can find a live exampe at: http://vtortola.github.io/ng-terminal-emulator/

You may also want to take a look at the Terminal Server application done with WebSocketListener.

ng-terminal-emulator's People

Contributors

vtortola avatar

Watchers

James Cloos avatar ajhasa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.