Giter Club home page Giter Club logo

portfolio-web-terminal's Introduction

Web Terminal

This is a basic ubuntu based web terminal that serves as an interactive portfolio of mine. You are welcome to use it, I just ask for credit.

If you would like a live version, visit my portfolio: https://yasfu.net/

It features a command system, as well as an "auto typer" that automatically types out and enters commands from code. This is useful for visitors that are not familiar with CLIs and broadens the amount of people who can navigate it. To increase this further, files listed with "ls" and other places can be clicked on to automatically execute commands like cat

How-To setup

If you'd like to configure it for your own needs, any file in the terminalfiles folder are automatically available for the terminal to use. By default the commands cat welcome.txt and ls are automatically ran when the terminal starts. You can change welcome.txt to change the welcome message or change the commands themselves in terminal.js, line 27:

autowriteQueue.push("Command here with arguments");

Pushing anything to the queue will type out the command while locking user input as soon as input is ready.

If you would like to add custom commands you may add it to any script included after terminal.js. I recommend making a new file and add any custom commands to that instead of defaultcommands.js to make any git merges a little easier. You can look at any command in defaultcommands.js for more examples or reference the example below:

function myCommand(args) {
  terminalPrint("Message here");
  cmdDone(); // Required after finishing function. Useful for any asynchronous functions. (ie. AJAX)
}

function ready() {
  addCmd("mycommand", myCommand);
}

$(document).ready(ready);

the first argument passed to any command function is a list of arguments given by the user. It is seperated by spaces but ignores quotes For example: mycommand there are "some arguments" 'to pass' would yield there, are, some arguments, to pass.

Useful functions

terminalPrint is a simple print function. The first argument is the message to print, and the second optional argument is a boolean that, if true, adds a line break to the end. By default this value is true.

cmdDone resets the user's input, and must be called after a command execute is finished. This is needed to support Asynchronous functions like AJAX.

toggleInput disables or enables user input. true will block input and false will enable it. No argument will toggle it based on the current locked state.

addCmd adds the command to the terminal. The first argument is a string and is the keyword for the user to execute the command. The second is a function that is called with a table of arguments the user passed with the command

Contributing

You're welcome to submit pull requests if you want to, just try and keep code style consistent with the rest of the file. Try to submit bug fixes instead of major feature changes. If you feel like a feature change may make a good contribution to the main software then you are welcome to do so, however there is no guarantee that it will be merged. Any new commands must be 'general' commands and can be widely applicable to be merged with the main branch. Something like tail or an existing linux/unix command. I have been using camelCase for the most part, and K&R style for bracket positioning.

portfolio-web-terminal's People

Contributors

littlebigbug 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.