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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <html>

<head>
<!--
*This redesigned version was started, in part, to Dylan Israel's great youtube tutorial on his Coding Tutorials 360. 
*The JS for this project is heavily influenced by his. 
*https://www.youtube.com/watch?v=24UvjYFDID0&list=PLHdCowjFIBmJ4KfgqZlvEOiRAZUHmD_cZ 
-->
	<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Black+Ops+One|Orbitron|Bowlby+One+SC" />
</head>

<body>
	<!--HEADER-->
	<div class="header col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<a href="http://www.spazcool.com/">
			<div class="well" type="button" id="home">home</div>
		</a>
	</div>

	<div class="workspace well col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-6 col-md-offset-4 col-lg-4 col-lg-offset-4">
		<div class="newTitle col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<a href="https://www.freecodecamp.com/challenges/build-a-javascript-calculator" target="blank">MATHMASTER</a>
		</div>
		<!--SCREEN-->
		<div class="screenHold">
			<div class="" id="screen">
			</div>
		</div>
		<!--BUTTONS-->
		<div class="calculator col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<div class="col-lg-12">
				<div class="acce">
					<center>
						<button class="power well buts" id="ac">AC</button>
						<button class="power well buts" id="ce">CE</button>
					</center>
				</div>
				<div class="sevenEightNineTimes">
					<center>
						<button class="well buts" id="7">7</button>
						<button class="well buts" id="8">8</button>
						<button class="well buts" id="9">9</button>
						<button class="ops well buts" id="*">x</button>
					</center>
				</div>
				<div class="fourFiveSixDivide">
					<center>
						<button class="well buts" id="4">4</button>
						<button class="well buts" id="5">5</button>
						<button class="well buts" id="6">6</button>
						<button class="ops well buts" id="/">&divide;</button>
					</center>
				</div>
				<div class="oneTwoThreePlus">
					<center>
						<button class="well buts" id="1">1</button>
						<button class="well buts" id="2">2</button>
						<button class="well buts" id="3">3</button>
						<button class="ops well buts" id="+">+</button>
					</center>
				</div>
				<div class="dotZeroEqualMinus">
					<center>
						<button class="well buts" id=".">.</button>
						<button class="well buts" id="0">0</button>
						<button class="power well buts" id="equal">=</button>
						<button class="ops well buts" id="-">-</button>
					</center>
				</div>
			</div>
			<!--END OF BUTTONS-->
		</div>
		<!--END OF CALCULATOR-->
		<div class="foot col-xs-10 col-xs-offset-1">
			<center>
				Created by me, <a href="https://codepen.io/SpazCool/" target="blank">Doug</a>.
			</center>
		</div>
	</div>
	<!--END OF WORKSPACE-->
</body>

</html>
              
            
!

CSS

              
                body {
	width: 100%;
	height: 100vh;
/* 	background-color: #000000;
	background-image: radial-gradient(ellipse farthest-corner at 45px 45px, #4f4f4f 0%, rgba(0, 0, 255, 0) 50%, #1A1A1A 95%); */
	background-color:	#603311;
	background-image: url("https://www.transparenttextures.com/patterns/dark-wood.png");
	color: black;
	font-size: 1.5em;
}

.header {
	text-align: left;
	max-height: 70%;
}

a {
	color: inherit;
}

a:hover {
	color:white;
	text-decoration: none;
}

#home{
	width: 100px;
	margin:1em;
	text-align: center;
	background-color: black;
	color: white;
	border-top: 0px solid #171717;
	border-bottom: 4px solid #171717;
	border-left:  3px solid #171717;
	border-right:  0px solid #171717;
}

.workspace{
	margin-top: 3%;
	margin-bottom: 1%;
	padding-top: 1%;
	padding-left: 1%;
	padding-right: 1%;
	padding-bottom: 1%;
	background-color: #5c5c5c;
	background-image: url("https://www.transparenttextures.com/patterns/light-aluminum.png");
	border-top: 0px solid #363636;
	border-bottom: 8px solid #363636;
	border-left:  5px solid #363636;
	border-right:  0px solid #363636;
}

.newTitle{
	text-shadow: 0px 0px 0 #000, 0px 0px 0 #000, -2px 2px 0 #000, 0px 0px 0 #000;
	font-family: "Bowlby One SC", "sans-serif";
	text-align: center;
	font-size: 170%;
	color: #999999;
}

.calculator{
/* 	border: 3px dotted blue; */
}
.screenHold {
	width: 80%;
	height: 5.5em;
	margin: 15% 5% 5% 10%;
	padding-top: 1.5em;
	background-color: #000011;
	border-top: 4px solid #171717;
	border-bottom: 3px solid #171717;
	border-left:  3px solid #171717;
	border-right:  4px solid #171717;
}

#screen {
	height: auto;
	width: 100%;
	padding-right: 3px;
	color: red;
	font-family: "Orbitron", "sans-serif";
	font-size: 2em;
	text-align: right;
	line-height: 1em;
	overflow-wrap: break-word;
	white-space: nowrap;
	overflow:hidden;
	display: inline-block;
}

/*BUTTONS*/
.buts {
	width: 21%;
	margin: 0.75%;
	padding-top: 4%;
	background-color: #FF00AA;
	background-image: url("https://www.transparenttextures.com/patterns/rough-cloth-light.png");
	font-family: "Black Ops One", "sans-serif";
	font-weight: bold;
	border-top: 0px solid #8B2252;
	border-bottom: 4px solid #8B2252;
	border-left:  3px solid #8B2252;
	border-right:  0px solid #8B2252;
}

.buts:focus {
	outline:0;
}
.buts:hover {
	filter:brightness(75%);
}
.buts:active {
	filter:brightness(150%);
	border-top: 0px solid #8B2252;
	border-bottom: 0px solid #8B2252;
	border-left:  0px solid #8B2252;
	border-right:  0px solid #8B2252;
}

.ops{
	background-color: #099FFF;
	border-top: 0px solid #2F4F4F;
	border-bottom: 4px solid #2F4F4F;
	border-left: 3px solid #2F4F4F;
	border-right: 0px solid #2F4F4F;
}

.power{
	background-color: #FF0000;
	border-top: 0px solid #660000;
	border-bottom: 4px solid #660000;
	border-left:  3px solid #660000;
	border-right:  0px solid #660000;
}

#ac,#ce{
	width: 45%;
}
.acce{
/*border: 3px dotted green;*/
}
.sevenEightNineTimes{
/*border: 3px dotted red;*/
}
.fourFiveSixDivide{
/*border: 3px dotted blue;*/
}
.oneTwoThreePlus{
/*border: 3px dotted yellow;*/
}
.dotZeroEqualMinus{
	/*border: 3px dotted black;*/
}

.foot{
	padding-top: 1%;
	font-family: "Orbitron";
}
              
            
!

JS

              
                $(document).ready(function() {
	var inputs = [""],
		toScreen = "",
		opers = ["+", "-", "/", "*"],
		dotCount = 0,
		equalled = 0,
		nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

	function robotToHuman() {
		var replaced = "";
		for (var y = 0; y < toScreen.length; y++) {
			if (toScreen[y] === "*") {
				replaced = toScreen.replace("*", " x ");
			} else if (toScreen[y] === "/") {
				replaced = toScreen.replace("/", " &divide; ");
			}
		}
		return replaced;
	}

	function updateScreen() {
		toScreen = inputs.join("");
		if (toScreen.includes("*") || toScreen.includes("/")) {
			$("#screen").html(robotToHuman());
		} else {
			$("#screen").html(toScreen);
		}
	}

	function equalizer() {
		var ans = eval(toScreen).toFixed(2);
		equalled = 1;
		toScreen = inputs.join("");
		inputs = [ans];
		dotCount = 1;
		if (ans.length > 7) {
			$("#screen").html(Number(ans).toExponential());
		} else {
			$("#screen").html(ans);
		}
	}

	function filter(input) {
		// STOPS 2 DOTS IN A ROW
		if (inputs[inputs.length - 1] === "." && input === ".") {
			console.log("Too many dots.......");
			//IF EQUAL HAS BEEN HIT && INPUT IS NOT AN OPER HAVE THE ANSWER BE WIPED for a now operation to take place
		} else if (equalled === 1 && nums.includes(Number(input))) {
			inputs = [""];
			inputs.push(input);
			//STOPS NONCONSECUTIVE DOTS
		} else if (inputs.includes(".") && input === ".") {
			if (inputs.includes(opers[0]) === true || inputs.includes(opers[1]) === true || inputs.includes(opers[2]) === true || inputs.includes(opers[3]) === true) {
				if (dotCount < 1) {
					inputs.push(input);
					dotCount += 1;
				}
			} else {
				console.log("Still too many dots");
			}
			//START WITH A NUMBER NOT AN OPERATOR
		} else if (inputs.length === 1 && opers.includes(input) === false) {
			inputs.push(input);
			//STOPS 2 OPERATIONS IN A ROW
		} else if (opers.includes(inputs[inputs.length - 1]) === false) {
			inputs.push(input);
			//MAKE SURE ITS A NUM
		} else if (nums.includes(Number(input)) === true) {
			inputs.push(input);
		}
		equalled = 0;
		updateScreen();
	}

	//STARTS HERE WITH THE INPUTS
	$("button").click(function() {
		if (this.id === "ac") {
			inputs = [""];
			dotCount = 0;
			equalled = 0;
			updateScreen();
		} else if (this.id === "ce") {
			inputs.pop();
			updateScreen();
		} else if (this.id === "equal") {
			equalizer();
		} else {
			if (inputs[inputs.length - 1].indexOf("+", "-", "*", "/") === -1) {
				filter(this.id);
			} else {
				filter(this.id);
			}
		}
	});
});
              
            
!
999px

Console