Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

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.

HTML

            
              <div class="container">
	<div class="everything shadow">
		<p id="only">CASIO CopyCat</p>
		<div id="theOuterBorder">
			<div class="well well-md">
				<p id="theCalculation"></p>
				<p id="theResult"></p>
			</div>
		</div>

	<div class="row">
		<button class="btn btn-default" id="del">DEL</button>
		<button class="btn btn-default" id="AC">AC</button>
	</div>	
	<div class="row">
		<button class="btn btn-default" id="exp">^</button>	
		<button class="btn btn-default theXters">π</button>
		<button class="btn btn-default theXters">sin</button>
		<button class="btn btn-default theXters">cos</button>
		<button class="btn btn-default theXters">tan</button>
	</div>
	<div class="row">
		<button class="btn btn-default theNumbers">7</button>
		<button class="btn btn-default theNumbers">8</button>
		<button class="btn btn-default theNumbers">9</button>
		<button class="btn btn-default theXters">(</button>
		<button class="btn btn-default theXters">)</button>
	</div>	
	<div class="row">
		<button class="btn btn-default theNumbers">4</button>
		<button class="btn btn-default theNumbers">5</button>
		<button class="btn btn-default theNumbers">6</button>
		<button class="btn btn-default" id="theDif">x</button>
		<button class="btn btn-default theXters">/</button>
	</div>	
	<div class="row">
		<button class="btn btn-default theNumbers">1</button>
		<button class="btn btn-default theNumbers">2</button>
		<button class="btn btn-default theNumbers">3</button>
		<button class="btn btn-default theXters">+</button>
		<button class="btn btn-default theXters">-</button>
	</div>	
	<div class="row">
		<button class="btn btn-default theNumbers">0</button>
		<button class="btn btn-default theXters">.</button>
		<button class="btn btn-default" id="exe">EXE</button>
	</div>

	</div>
</div>
            
          
!

CSS

            
              body {
	background-color: #757462; 
}

#theOuterBorder {
	border: 2px solid black;
	padding-top: 15px; 
	margin: 10px;
	border-radius: 5%;

} 

#only {
	margin-top: 5px;
	color: black;
	font-family: 'Lobster', cursive;
}

.btn {
  	margin-bottom: 5px;
  	border: 1px solid black;
  	width: 50px;
  	display: inline;
	box-shadow: 0 8px 6px -6px black;
	border-radius: 10px;
	font-weight: 600;
}

#exe {
	width: 50%;
}

#theResult {
	text-align: right;
}

#theCalculation {
	text-align: left;
}

.well {
	height: 100px;
	border: 2px rgb(10, 10, 10) solid;
	width: 90%;
	margin-left: 5%;
   	box-shadow: inset 0 0 10px #000000;
}

.everything {
	margin-left: auto;
	margin-right: auto;
	display: block;
    border-radius: 5px;
    border: 1px solid black;
    width: 300px;
    text-align: center;
    margin-top: 10%;
    padding: 5px 5px;
    background-color: #9898a0;
    border-radius: 6%;
    box-shadow:  7px 10px 24px 1px #000000;
} 

#exe, #AC, #del {
	background-color: black;
	color: white;
}


            
          
!

JS

            
              var TheMathCalculation = "";
var previousTarget = "<h1><h1>"; // assigned a random tag to it to avoid it being null

$(".theNumbers").on("click", function() {
	if ($("#theCalculation").html().length <= 25) {
		var i = $(this).text();
		if (previousTarget.innerHTML === ("sin" || "cos" || "tan")) {
			TheMathCalculation += i + ")";
			$("#theCalculation").html($("#theCalculation").html() + "(" + i + ")");		
		} else {
			TheMathCalculation += i;
			$("#theCalculation").html($("#theCalculation").html() + i);
		}
		previousTarget=this;
	}
})

$(".theXters").on("click", function() {
	var i = $(this).text();
	if ($("#theCalculation").html().length <= 25) {
		$("#theCalculation").html($("#theCalculation").html() + i);
		switch(i){
			case "π": 
				TheMathCalculation += "Math.PI";
				break;
			case "sin": 
				TheMathCalculation += "Math.sin(";
				break;
			case "cos":
				TheMathCalculation += "Math.cos(";
				break;
			case "tan":
				TheMathCalculation += "Math.tan(";
				break;
			default:
				TheMathCalculation += i;
		}
		previousTarget = this;
	}
})

var theAboveToString = "";
var indexes = [];

$("#exe").on("click", function() {
	var theMathResult = "";
	indexes = [];
	try {
		if (TheMathCalculation === "Math.PI") {
			theMathResult = eval(TheMathCalculation);
			$("#theResult").html(theMathResult);
		} else {
			//console.log(TheMathCalculation)
			theMathResult = eval(TheMathCalculation);
			$("#theResult").html(theMathResult.toPrecision(2));
			//the below code i used to deal with the decimals but it doesn't work so well
			//theAboveToString = theMathResult.toString().split("");
			//if (theAboveToString.indexOf(".") !== -1) {
			//	var idx = theAboveToString.indexOf("0");
			//	while (idx !== -1) {
  			//		indexes.push(idx);
  			//		idx = theAboveToString.indexOf("0", idx + 1);
  			//		if (true) {}
  			//		var newResult = theAboveToString.slice(0, indexes[1]).join("")
  			//		$("#theResult").html(newResult);
			//	}
			//} //else {
			//	$("#theResult").html(theMathResult);
			} 
			//console.log(theAboveToString)
		}
	catch(err) {
    $("#theResult").html("Syntax ERROR");
	}

})

$("#del").on("click", function(){
	$("#theResult").empty();

	var theSpec = $("#theCalculation").html().length-1;
	var theCalHtml = $("#theCalculation").html();
	var theResultemov = "";

	if (theCalHtml[theSpec] == "^") {
		TheMathCalculation = TheMathCalculation.slice(0, -2);
		$("#theCalculation").html(theResultemov);
	} else if (theCalHtml[theSpec] === ("n" || "s")) {
		TheMathCalculation = TheMathCalculation.slice(0, -8);
		theResultemov = theCalHtml.slice(0, -3);
		$("#theCalculation").html(theResultemov);
	} else if (theCalHtml[theSpec] === "π") {
		TheMathCalculation = TheMathCalculation.slice(0, -7);
		theResultemov = theCalHtml.slice(0, -1);
		$("#theCalculation").html(theResultemov);
	} else {
		TheMathCalculation = TheMathCalculation.slice(0, -1);
		theResultemov = theCalHtml.slice(0, -1);
		$("#theCalculation").html(theResultemov);
	}	
})

$("#AC").on("click", function(){
	$("#theCalculation").empty();
	$("#theResult").empty();
  TheMathCalculation = "";
})

$("#exp").on("click", function(){
	if ($("#theCalculation").html().length <= 25) {
		TheMathCalculation += "**";
		$("#theCalculation").html($("#theCalculation").html() + "^")
	}
})

// dealing with xx returning ** 
$("#theDif").on("click", function() {
	if ($("#theCalculation").html().length <= 25) {
		$("#theCalculation").html($("#theCalculation").html() + "x")
		if (previousTarget === this ) {
	 		TheMathCalculation += "x"
		} else {
			TheMathCalculation += "*";
		}
		previousTarget = this;	
	}
})


            
          
!
999px

Console