Coder Social home page Coder Social logo

reeceyang / webconsole Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 28 KB

Provides a web console HTML page with print and input functions for JavaScript.

Home Page: https://reeceyang.github.io/webconsole/demo.html

License: MIT License

HTML 16.38% CSS 23.82% JavaScript 59.80%
webconsole asynchronous javascript

webconsole's Introduction

webconsole

Provides a web console HTML page with print and input functions for JavaScript. A demonstration with a simple number-guessing game is available on this repository's github-pages.

Usage

  1. Copy webconsole.js and webconsole.css (optional, but required if you want to use dark mode) into your project (I'm working on setting up a CDN---you can try using https://reeceyang.github.io/webconsole/webconsole.js for now). You can also add this repository as a git submodule.

  2. Include webconsole.js and webconsole.css in your .html file. Call Webconsole.addTo(element); to append Webconsole to the contents of element, where element is a JS DOM object. For example,

Webconsole.addTo(document.body);

adds Webconsole to the document body. Call Webconsole.addDarkModeTo(element); to add a dark mode toggle button to the start of the contents of element.

  1. Write your code in an asynchronous main function:
async function main() {
  // do stuff
}
  1. Call the main function to run your program:
main();

Functions

print(arg1, arg2, ...)

Prints all arguments to the console, one after another.

println(arg1, arg2, ...)

Prints all arguments to the console, one after another, with a line break at the end.

clear()

Clears the content of the console output.

await input(arg1, arg2, ...)

Prints all arguments to the console, then waits for the user to input a value. Then prints a line break at the end, and returns that value. Note: you must place a await in front because input() is an asynchronous function.

webconsole's People

Contributors

reeceyang avatar

Stargazers

 avatar

Watchers

 avatar  avatar

webconsole's Issues

sanitize inputs

so you can't insert html like (<script> tags) into the div

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.