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="moveright" align="right">
<div class="calculator">
<p id="title">FreeCodeCamp</p>
<p id="tagline">HandCoded Calculator</p>
<input type="text" disabled="disabled" id="display"/>
<div class="row">
<button class="ctrl" onClick="allClearAC()">AC</button>
<button class="ctrl" onClick="clearCE()">CE</button>
<button onClick="operate('/100')">%</button>
<button onClick="operate('/')">÷</button>
</div>
<div class="row">
<button onClick="addDigit(7)">7</button>
<button onClick="addDigit(8)">8</button>
<button onClick="addDigit(9)">9</button>
<button onClick="operate('*')">x</button>
</div>
<div class="row">
<button onClick="addDigit(4)">4</button>
<button onClick="addDigit(5)">5</button>
<button onClick="addDigit(6)">6</button>
<button onClick="operate('-')">-</button>
</div>
<div class="row">
<button value=1 onClick="addDigit('1')">1</button>
<button onClick="addDigit('2')">2</button>
<button onClick="addDigit('3')">3</button>
<button class="tall" onClick="operate('+')">+</button>
</div>
<div class="row">
<button onClick="addDigit('0')">0</button>
<button onClick="addDigit('.')">.</button>
<button onClick="workout()">=</button>
</div>
</div>
</div>
@import url(https://fonts.googleapis.com/css?family=Pacifico|Open+Sans|Montserrat);
body, html {
background:url("https://images.unsplash.com/photo-1453733190371-0a9bedd82893?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=bcfa2aedb65f1d4bda7ee0cfd7f6932c")no-repeat fixed;
background-size:cover;
margin-top: 8%;
margin-left:40%;
}
.calculator {
width: 250px;
height: 335px;
background-color: #F3EEE7;
margin: 0 auto;
border-top-left-radius: 80% 20px;
border-top-right-radius: 80% 20px;
border-bottom-left-radius: 80% 20px;
border-bottom-right-radius: 80% 20px;
box-shadow: inset 5px 0 10px -5px #635e61, inset -5px 0 10px -5px #635e61, inset 0px -5px 10px -2px #635e61, 0 0 1px 2px #635e61, 0 10px 20px 0 #494547;
text-align: center;
}
.calculator p#title {
padding-top: 10px;
margin-bottom: -10px;
color: #7d777b;
font-family: 'Pacifico';
}
.calculator p#tagline {
text-transform: uppercase;
color: #969194;
font-family: 'Open Sans';
font-size: .7em;
}
.calculator input[type='text'] {
background-color: #C7C7B0;
border: 1px solid #b2b292;
line-height: 40px;
width: 80%;
font-size: 2em;
text-align: right;
font-family: 'Montserrat';
padding-right: 10px;
margin-bottom: 20px;
border-radius: 5px;
box-shadow: inset 0px -2px 10px #b2b292;
}
.calculator input[type='text']:focus {
outline: none;
}
.calculator .row {
display: block;
}
.calculator .row button {
width: 40px;
height: 30px;
border: 1px solid #4B4657;
border-top: 2px solid #7c748f;
background-image: -webkit-linear-gradient( top , #4B4657, #332f3b);
background-image: linear-gradient(to bottom, #4B4657, #332f3b);
color: white;
font-size: 1.1em;
border-radius: 20%;
border-top-left-radius: 80% 10px;
border-top-right-radius: 80% 10px;
border-bottom-left-radius: 100% 10px;
border-bottom-right-radius: 100% 10px;
margin-left: 5px;
margin-right: 5px;
margin-bottom: 8px;
box-shadow: inset 0 1px 4px #7c748f, inset 0 -4px 20px #332f3b, 0 3px 1px 0 #332f3b;
}
.calculator .row button:focus {
outline: 0;
}
.calculator .row button:active {
background-image: -webkit-linear-gradient( bottom , #4B4657, #332f3b);
background-image: linear-gradient(to top, #4B4657, #332f3b);
}
.calculator .row .ctrl {
border: 1px solid #CC4E5F;
border-top: 2px solid #e39da7;
background-image: -webkit-linear-gradient( top , #CC4E5F, #b33445);
background-image: linear-gradient(to bottom, #CC4E5F, #b33445);
box-shadow: inset 0 1px 4px #e39da7, inset 0 -4px 20px #b33445;
}
.calculator .row .ctrl:active {
background-image: -webkit-linear-gradient( bottom , #CC4E5F, #b33445);
background-image: linear-gradient(to top, #CC4E5F, #b33445);
}
.calculator .row .tall {
height: 65px;
float: right;
margin-right: 24px;
margin-left: -8px;
}
// Caculator
var memory = '';
var current = '';
var MAX = '10';
var op = '';
var display = document.getElementById("display");
var lasData = [];
function allClearAC(){
memory = '';
current = '';
op = '';
display.value = current;
} // Clear all the digits on screen
function clearCE(){
memory = memory.substr(0, memory.length-1);
display.value = memory;
}
function addDigit(dig){
if ( current.length > MAX) {
current = "Too Large"
display.value = current;
} else {current = dig;}
memory = memory + current;
display.value = memory;
}
function operate(op){
memory = memory + op;
current = '';
display.value = memory;
}
function workout(){
current = eval(memory);
display.value = current;
oper = 0;
memory= '';
}
Also see: Tab Triggers