JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="container-fluid"><!--calculator body-->
<div class="row">
<div class="col-xs-12">
<input id="screen" type="text" disabled>
</div>
</div>
<div class="row">
<div class="col-xs-8"><u>freeCodeCamp</u></div>
<div class="col-xs-4"><input class="btn btn-default m-op-btn" type="button" value="on/c" onclick="reset()"></div>
</div>
<div class="row">
<div class="col-xs-3"><input class="btn btn-default" type="button" value="7" onclick="keyEntry7()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="8" onclick="keyEntry8()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="9" onclick="keyEntry9()"></div>
<div class="col-xs-3"><input class="btn btn-default op-btn" type="button" value="/" onclick="division()"></div>
</div>
<div class="row">
<div class="col-xs-3"><input class="btn btn-default" type="button" value="4" onclick="keyEntry4()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="5" onclick="keyEntry5()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="6" onclick="keyEntry6()"></div>
<div class="col-xs-3"><input class="btn btn-default op-btn" type="button" value="X" onclick="multiplication()"></div>
</div>
<div class="row">
<div class="col-xs-3"><input class="btn btn-default" type="button" value="1" onclick="keyEntry1()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="2" onclick="keyEntry2()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="3" onclick="keyEntry3()"></div>
<div class="col-xs-3"><input class="btn btn-default op-btn" type="button" value="-" onclick="subtraction()"></div>
</div>
<div class="row">
<div class="col-xs-3"><input class="btn btn-default" type="button" value="0" onclick="keyEntry0()"></div>
<div class="col-xs-3"><input class="btn btn-default" type="button" value="." onclick="decimal()"></div>
<div class="col-xs-3"><input class="btn btn-default m-op-btn" type="button" value="=" onclick="equals()"></div>
<div class="col-xs-3"><input class="btn btn-default op-btn" type="button" value="+" onclick="addition()"></div>
</div>
</div>
body, html {
background-color: #666;
}
u {
font-family: "Ubuntu Mono";
font-size: 1.5em;
}
.btn {
width: 60px;
box-shadow: 1px 1px 5px #d2d2d2;
border-radius: 9px;
background-color: #e1ffef;
font-weight: bold;
font-size: 1.4em;
padding: 10px;
text-align: center;
}
.btn:hover {
background-color: #D7F5E5;
}
.op-btn {
width: 45px;
background-color: #BA1E38;
color: white;
}
.op-btn:hover {
background-color: #851729;
color: white;
}
.m-op-btn {
background-color: #5f9aa4;
color: white;
width: 75px;
margin-left: -7px;
}
.m-op-btn:hover {
background-color: #578d96;
color: white;
}
.container-fluid {
margin-top: 20px;
width: 300px;
height: auto;
background-color: #f2f2f2;
box-shadow: inset 0 4px 8px 0 rgba(0, 0, 0, 0.2), inset 0 6px 20px 0 rgba(0, 0, 0, 0.19);
padding: 15px;
border-radius: 25px;
}
.row {
padding-top: 5px;
padding-bottom:5px;
}
#screen {
background-color: grey;
font-family: "Inconsolata";
font-size: 2em;
width: 100%;
margin: auto;
height: 60px;
line-height: 60px;
text-align: right;
font-weight: bold;
padding: 10px;
box-shadow: inset 0 4px 8px 0 rgba(0, 0, 0, 0.2), inset 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
var screenDisplay = document.getElementById("screen");
var current = "";
var equation;
var a = "";
var b = 0;
var c;
function update() {
screenDisplay.value = current;
document.getElementById("screen").style.backgroundColor = "#8EFC5B";
}
function reset() {
current = "";
a = 0;
b = 0;
c = 0;
update();
}
function keyEntry0() {
current += "0";
update();
}
function keyEntry1() {
current += "1";
update();
}
function keyEntry2() {
current += "2";
update();
}
function keyEntry3() {
current += "3";
update();
}
function keyEntry4() {
current += "4";
update();
}
function keyEntry5() {
current += "5";
update();
}
function keyEntry6() {
current += "6";
update();
}
function keyEntry7() {
current += "7";
update();
}
function keyEntry8() {
current += "8";
update();
}
function keyEntry9() {
current += "9";
update();
}
function decimal() {
current += ".";
update();
}
function division() {
a += current + "/";
update();
current = "";
}
function multiplication() {
a += current + "*";
update();
current = "";
}
function subtraction() {
a += current + "-";
update();
current = "";
}
function addition() {
a += current + "+";
update();
current = "";
}
function equals() {
current = a + current;
current = eval(current);
update();
a = "";
}
Also see: Tab Triggers