Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main>
<section id="home">
<h2>CLI - Command Line Interface Simulation</h2>
<p>A fun experiment for displaying simple info in a geeky manner.</p>
<p><span>Type 'help' + <kbd>Enter</kbd> -- for available commands.</span></p>
</section>

<section id="about">
<h2><span>&raquo;About</span></h2>
<p>This is an experiment built by <a href="http://syndicatefx.com" target="_blank">Paulo Nunes</a> for showcasing a user profile or cv in an unusual but original way by simulating a command line interface. It's nothing more than the usual hidden elements triggered by some JS to show/hide each section of content, based on input values.</p>
</section>

<section id="usage">
<h2><span>&raquo;Usage</span></h2>
<p>Using it is pretty straight forward. Create several(as much as you need) divs or &laquo;section&raquo; elements each with it's unique id to hold your content. Make sure to have an error section (id="error") with some information to warn the user when he/she mistypes a command or if there is no section with that name, think of it as a 404 page.</p>
<p>A section with id="help" is also required so you can list all the available sections and let your users know what words to write to access that particular content.</p>
<p>The input field must be a standalone element and must not be placed inside any of the content divs or sections, and make sure you give it a classname "command", if you want to name it anything else you need to edit the app.js and change all instances of .command in the script to match your chosen classname.</p>
<p>In short, just view the source code of this demo, copy/modify it to your liking making sure you include the error and help sections.</p>
</section>

<section id="download">
<h2><span>&raquo;Download</span></h2>
<p>Download/fork the source code: <a href="https://github.com/syndicatefx/cli">Github</a><br>
License: MIT</p>
</section>

<section id="error">
<p>Command not found!<p> 
<p><span>Type 'help' + <kbd>Enter</kbd> -- for available commands.</span></p>
</section>

<section id="help">
<h2><span>&raquo;Help?</span></h2>
<p><span>Type [command] + <kbd>Enter</kbd></span></p>
<ul>
	<li>'home' -- Thats obvious!</li>
	<li>'about' -- What's this for</li>
  <li>'usage' -- How to</li>
  <li>'download' -- Download + license</li>
	<li>'help' -- displays this list</li>
</ul>
</section>

<span class="command">syndicatefx:/$<input type="text"></span>
</main>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Inconsolata:400,700);
html {
  background: #fff;
  overflow-y: scroll; 
}

body {
  font: .875em/1.6 'Inconsolata', monospace;
  color: #181818;
  font-weight: 400;
  max-width: 28em;
  padding: 1em;
  margin: 5% 0; 
}
::selection{
  background: #eee
}
::-webkit-selection{
  background: #eee
}
::-moz-selection{
  background: #eee
}
a{
  color: #181818;
}
a:hover,a:focus{
  background: #181818;
  color:#fff;
}
h2{
  font-size: 1em;
  font-weight: 400;
}
p{
  margin-bottom:2em;
}
abbr{
  cursor: help;
}
ul{
  list-style: none;
  padding: 0;
}
li{
  margin:1em 0 0;
}
span{
  display: block;
  color:#999;
  line-height:1;
}

kbd{
  font-family: 'Inconsolata', monospace;
  border:1px solid #999;
  text-transform: uppercase;
  padding:0 .2em;
}
input[type="text"]{
  max-width: 10em;
  border: none;
  font-family: inherit;
  background: #fff;
  padding:0 .5em;
}
input[type="text"]:focus{
  background: #fff;
  color: #000;
  outline:none;
}
.command{
  display: none;
  max-width: 20em;
  color: #181818;
  font-weight: 700;
  margin: 2em 0;
}


section{
  display: none;
}
.open{
  display: block;
}

              
            
!

JS

              
                /*!
 * CLI
 * Simulating a command line interface with vanilla JS
 *
 * @version : 1.2.0
 * @author : Paulo Nunes (http://syndicatefx.com)
 * @demo : https://codepen.io/syndicatefx/pen/jPxXpz
 * @license: MIT
 */

/*
Modified/adapted from the original script by:
https://github.com/ckm100/typeWriter.js
*/
document.addEventListener("DOMContentLoad", typeWriter, false);

var typeWriter = function (selector, type, interval) {

    var el = document.querySelectorAll(selector), // Getting elements in the DOM
        i = 0,
        len = el.length, // Length of element on the page
        list = [], // List of elements on the page in the DOM
        a,
        all,
        text,
        start,
        end,
        nextText,
        sectionId = selector.replace(/^#/, ''),
        targetSection = document.getElementById(sectionId),
        sections = document.getElementsByTagName("section")[0],
        targetSiblings = [].slice.call(sections.parentNode.children).filter(function(v) { return v !== targetSection }),
        cmd = document.querySelector(".command"),
        clear;

    for (; i < len; i++) {

        list.push(el[i]); // Pushing the element in the list array
    }

    for (a in list) {

        all = list[a]; // List of all element
        text = all.innerHTML; // InnerHTML of the elements 
        start = 0; // Start index of the text in the elements 
        end = 0; // End index of the text in the elements


        //Setting the default interval to 100 when interval is not set by the user
        if (typeof interval === "undefined") {

            interval = 100;

        }

        if (arguments[1] === "true") {

        	setTimeout(function() {
        		targetSection.classList.add("open");
        	}, 200);

	       	for(var i = 0;i < targetSiblings.length;i++) {
	        	targetSiblings[i].classList.remove("open");
	        }

            clear = setInterval(function () { // Animation start
                var newText = text.substr(start, end);

                all.innerHTML = newText;

                end = end + 1; //loops through the text in the element

                if (newText === text) {

                    clearInterval(clear); // Animation end
                    cmd.classList.add("open");
                    input.focus();

                }

            }, interval);

        }

        return all;

    }

}

var input = document.querySelector("input"),
	block = document.getElementsByTagName("section");

window.onload = function() {
	typeWriter("#home","true",10);

	var sectionArray = [];
	for(var i = 0;i < block.length;i++) {
		sectionArray.push(block[i].id);
	}
	//console.log(sectionArray);

	input.addEventListener('keyup', function(e) {
		if((e.keyCode || e.which) == 13) {// ENTER key pressed
			var targetValue = input.value;
			var destination = "#" + targetValue;
			typeWriter(destination,"true",10);
			input.value = "";

			if(sectionArray.includes(targetValue) == false) {
				typeWriter("#error","true",10);
			}
		}
	});
};
              
            
!
999px

Console