Calc - Dev?
How do I make an calc - dev??
What is a calc - dev?? How do you make a calc - dev?? This script and codes were developed by Steven on 31 July 2022, Sunday.
Calc - Dev? - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Calc - Dev?</title> <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <link href='https://fonts.googleapis.com/css?family=Roboto+Mono:700' rel='stylesheet' type='text/css'>
<div class="container calc text-center"> <div class="row"> <div class="col-md-12"> <p class="text-center brand">Volv</p> <p class="text-center title">Electronic Calculator</p> </div> </div> <div class="row"> <div class="col-md-12"> <p class="calcDisplay">1234567890</p> </div> </div> <div> <ul class="list-inline"> <li> <button class="btn btn-block cbut cbut-red">AC</button> </li> <li> <button class="btn btn-block cbut cbut-red">CE</button> </li> <li> <button class="btn btn-block cbut">%</button> </li> <li> <button class="btn btn-block cbut">÷</button> </li> </ul> </div> <div> <ul class="list-inline"> <li> <button class="btn btn-block cbut">7</button> </li> <li> <button class="btn btn-block cbut">8</button> </li> <li> <button class="btn btn-block cbut">9</button> </li> <li> <button class="btn btn-block cbut">x</button> </li> </ul> </div> <div> <ul class="list-inline"> <li> <button class="btn cbut">4</button> </li> <li> <button class="btn cbut">5</button> </li> <li> <button class="btn cbut">6</button> </li> <li> <button class="btn cbut">-</button> </li> </ul> </div> <div> <div> <ul class="list-inline pull-left" style="padding-left:2px;"> <li> <button class="btn cbut">1</button> </li> <li> <button class="btn cbut">2</button> </li> <li> <button class="btn cbut">3</button> </li> </ul> </div> <div> <ul class="list-inline pull-left" style="padding-left:2px;"> <li> <button class="btn cbut">0</button> </li> <li> <button class="btn cbut">.</button> </li> <li> <button class="btn cbut">=</button> </li> </ul> </div> <button class="btn cbut plusbut">+</button> </div>
</div>
<p style="text-align: center; margin-top: 30px; font-weight:bold; color: black; font-size:larger;" class="debug"></p> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Calc - Dev? - Script Codes CSS Codes
body { background: url("http://www.volv.org/images/schooldesk.jpg");
}
.calc { margin-top: 20px; width: 242px; padding-top: 5px; padding-bottom: 5px; box-shadow: 0px 0px 10px 5px; background-color: silver; border-top-left-radius: 200px 5%; border-top-right-radius: 200px 5%; border-bottom-left-radius: 200px 5%; border-bottom-right-radius: 200px 5%;
}
.brand { font-family: 'Roboto Mono'; font-size:28px; font-weight:700; letter-spacing: 2px; margin-bottom: -5px; color: black;
}
.title { font-size: 12px; opacity: 0.7; font-family: 'Roboto Mono'; font-weight:700; text-transform: uppercase; margin-bottom: 5px; color: black;
}
.calcDisplay { font-family: 'Roboto Mono'; font-size:28px; font-weight:700; letter-spacing: 2px; background-color: linen; box-shadow: inset 0px 0px 4px 1px; border-radius: 6px; text-align: right; padding-right: 12px;
}
.cbut { font-weight:600; background-color: #505050; box-shadow: 0px 0px 1px 2px black; color: white; padding: 0px; width: 40px; height: 40px;
}
.cbut-red { background-color: #bb3d4e;
}
.plusbut { height:90px;
}
Calc - Dev? - Script Codes JS Codes
var screen = [];
var calcExpression = [];
var curOp = "?";
var lastOp = "?";
var lastScreen = [];
var dotPressed=false;
var calcJustDone = false;
var SCREEN_SIZE=10;
var doDebug = false; ;
var onFirstDigit = true;
var lastKeyWasOp = false;
bugOut("Things to try:", false, true);
bugOut("", false, true);
bugOut("100 / 3", false, true);
bugOut("1.001 + 0.001", false, true);
bugOut("Do a sum. Then hit equals a lot.", false, true);
bugOut("Digit Operator Digit Operator", false, true);
bugOut("Try CE vs AC", false, true);
bugOut("Try huge numbers", false, true);
bugOut("Try % Operator in place of = Operator", false, true);
$(".cbut").click(function() { numPress($(this).html());
});
function numPress(num) { $(".calcDisplay").removeClass("faded"); switch (num) { case "AC": clearAll(); break; case "CE": if (calcJustDone) clearAll(); clearScreen(); break; case "÷": case "x": case "-": case "+": pushOp(num); dotPressed=false; onFirstDigit = true; break; case "%": switch(curOp) { case "+": case "-": screen = toArr((getNo(screen) / 100)*getNo(calcExpression[0])); break; case "÷": screen = toArr(getNo(screen)/100); break; case "x": screen = toArr(getNo(screen)/100); break; } calcResult(); dotPressed=false; break; case "=": calcResult(); dotPressed=false; break; case ".": if (dotPressed) return; if (onFirstDigit || calcJustDone) screen =[0]; // Add leading 0 to decimal as first input //if (!screen) dotPressed = true; default: //If Stack full & op empty & calcJustDone -> clear Stack. calcJustDone = false - OR just clearALL. if ((calcExpression[0]) && (curOp == "?") && (calcJustDone)) { clearAll(); } addToScreen(num); onFirstDigit = false; }
}
function clearAll() { screen = []; calcExpression = []; curOp = "?"; lastOp = "?"; dotPressed=false; calcJustDone=false; onFirstDigit = true; updateDisplay(); //bugOut("", true);
}
function clearScreen() { screen = []; updateDisplay();
}
function addToScreen(num) { if (screen.length < SCREEN_SIZE) screen.push(num); updateDisplay();
}
function pushOp(num) { if (calcExpression[0] && screen[0]) { curOp = num; calcResult(true); curOp = num; return; } //If theres something on the stack and on screen then calc result now. Preserve Operator. if (curOp == "?") { //No operator bugOut("pushOp. Operator DOES NOT already exist - Store Number - " +curOp, false); curOp = num; //Make it exist calcExpression[0] = (calcExpression[0]) ? calcExpression[0] :screen; //If no number on stack. put screen on stack. screen = []; // Empty but don't clear screen } else { if (!onFirstDigit) { //Chain sums - but not on first digit. Also means I can press (num * / +) and only have last op count bugOut("pushOp. Operator DOES INDEED already exist - Do Calc - " +curOp, false); calcResult(); } else { bugOut("pushOp. Operator DOES INDEED already exist - No Calc - Preserve latest OP - " +num, false); curOp = num; //Make last op count. } }
}
function calcResult(useLastOp) { var result = 0; var opToUse; if (lastOp =="?") {bugOut("lastOp EMPTY"); lastOp = curOp;} opToUse = (useLastOp) ? lastOp : curOp; if (useLastOp) { bugOut("Using Last OP!"); } firstNo = getNo(calcExpression[0]); // Stored No secondNo = getNo(screen); // Screen bugOut("firstNo - " +firstNo+ ", secondNo - " +secondNo+ ", curOp - " +curOp, false); switch(opToUse) { //1e10 fixes float issues up t 10 places. case "÷": result = (firstNo/secondNo); break; case "x": result = (firstNo*secondNo); break; case "-": result = (firstNo*1e10-secondNo*1e10)/1e10; break; case "+": result = (firstNo*1e10+secondNo*1e10)/1e10; break; case "?": // Repeat last calc if equals is pressed with nothing else. result = result; screen = lastScreen; curOp = lastOp; calcResult(); return; } lastScreen = screen; // Save screen for equals repeat screen = toArr(result); //to format screen expects calcExpression[0] = screen; // Stack now has result on it calcJustDone = true; updateDisplay(); //Output result screen = []; lastOp = curOp; curOp = "?"; bugOut("Calculation done. Operator removed. Screen variable emptied. Result Showing.", false)
}
function getNo(arr) { result = 0; result = parseFloat(arr.join("")); return (result) ? result : 0;
}
function toArr (num) { result = []; num.toString().split("").map(function(m) { result.push(m); }); return result;
}
function updateDisplay() { result = ""; var fullString; fullString = screen.join(""); bugOut("NUMBER BEFORE - " +fullString); if (fullString.length <= SCREEN_SIZE) { result = fullString; } else { result = parseFloat(fullString).toPrecision(SCREEN_SIZE-5).toString(); if (result.indexOf("e") == -1) { // If not exponent. Display full result = parseFloat(fullString).toPrecision(SCREEN_SIZE).toString(); } if ( (parseFloat(fullString) >= 1e100) || (parseFloat(fullString) <= 1e-100) ) { result = "FIZZBUZZ"; } } result = result.slice(0, 10); if (calcJustDone) { //Only after calc - leave user alone. if (result.indexOf(".")!= -1) { //Trim Zeroes off of decimals. while (result[result.length-1] == "0") { result = result.slice(0, result.length-1); } if (result[result.length-1] == ".") { //Remove trailing decimal. result = result.slice(0, result.length-1); } } } result = (result=="") ? "0" : result; $(".calcDisplay").html(result);
}
function bugOut(error, clear, override) { if (clear) $(".debug").html(""); if (doDebug || override) $(".debug").html($(".debug").html() + "<br>" + error);
}
/*
Number = add number to screen if pos.
Operator Store number [or result] Store operator Clear screen variable Number = add number to screen if pos Operator = evaluate. Screen + Old screen. Place Result Store 2nd Operator. Repeat
Equals = Evaluate.
CE = clear screen. Keep Stuff
AC = clear all
*/
Developer | Steven |
Username | volv |
Uploaded | July 31, 2022 |
Rating | 3 |
Size | 4,491 Kb |
Views | 42,504 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Weather | 4,445 Kb |
Camper News | 3,013 Kb |
Closure Example | 2,443 Kb |
Recursive Multiplication | 2,119 Kb |
Recursive Tree | 3,381 Kb |
Closure Examples | 2,792 Kb |
Reddit Spoiler Markdown | 2,077 Kb |
Heavy Snake - Level Editor - Dev | 5,348 Kb |
JSRange | 3,245 Kb |
Pet Stats | 10,939 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Animated SVG stroke-dasharray | Netsi1964 | 3,179 Kb |
Animate elements with fixed gradient | Badabam | 4,406 Kb |
Barber Shop | Bhlaird | 6,270 Kb |
Jstam.com Home Page | Jstam | 10,558 Kb |
BabyStore | Pablo-Ai | 3,807 Kb |
Twinner Spinner II | Katydecorah | 2,974 Kb |
Prototype Responsive Homepage | Heyitsolivia | 7,677 Kb |
Css color for svg | Ademilter | 2,392 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Exploring css spinners | Akagr | 3,569 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!