Old calculator
How do I make an old calculator?
What is a old calculator? How do you make a old calculator? This script and codes were developed by Kevin on 13 October 2022, Thursday.
Old calculator - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>old calculator</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <head> <title>Calculator</title> <link rel="stylesheet" href="style.css" />
</head>
<body> <div id="calculator"> <div id="total"> </div> <div id="operators"> <a>+</a> <a>-</a> <a>/</a> <a>*</a> <a id="equals">=</a> </div> <div id="numbers"> <a id="#one">1</a> <a>2</a> <a>3</a> <a>4</a> <a>5</a> <a>6</a> <a>7</a> <a>8</a> <a>9</a> <a id="clear">C</a> <a>0</a> <a id="clearall">AC</a> </div> </div>
</body> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Old calculator - Script Codes CSS Codes
body,
div,
a { padding: 0; margin: 0; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
a { cursor: pointer;
}
#calculator { background-color: #999; width: 310px; height: 460px; border: 3px black solid; margin: 10px auto; padding: 5px; border-radius: 10px;
}
#total { height: 70px; width: 300px; margin: auto; background-color: white; margin-bottom: 5px; text-align: right; font-size: 60px; padding: 0 5px;
}
#numbers,
#operators { margin: auto;
}
#operators a { display: block; width: 45px; height: 45px; float: left; text-decoration: none; color: black; text-align: center; font-size: 39px; padding: 2px; margin: 5px 6px; background: -webkit-gradient(linear, left top, left bottom, from(#EDEDED), to(#DCDCDC)); background: -moz-linear-gradient(top, #EDEDED, #DCDCDC); border-radius: 10px;
}
#numbers a { display: block; width: 50px; height: 50px; float: left; text-decoration: none; color: black; text-align: center; font-size: 32pt; padding: 10px; margin: 5px 15px; background: -webkit-gradient(linear, left top, left bottom, from(#EDEDED), to(#DCDCDC)); background: -moz-linear-gradient(top, #EDEDED, #DCDCDC); border-radius: 10px;
}
Old calculator - Script Codes JS Codes
var round = function(text, pos) { function setCharAt(str, index, chr) { if (index > str.length - 1) return str; return str.substr(0, index) + chr + str.substr(index + 1); } if (text.length > pos) { for (i = 1; i < text.length; i++) { if (text[i] === ".") { i = text.length; if (parseFloat(text[pos], 10) >= 5) { text = (setCharAt(text, pos - 1, ((parseFloat(text[pos - 1], 10)) + 1).toString(10))).substr(0, pos); } else { text = text.substr(0, pos); } } } } return text;
};
var $ = jQuery.noConflict();
$(function() { var testNumLength = function(number) { if (number.length > 9) { totaldiv.text(number.substr(number.length - 9, 9)); if (number.length > 15) { number = ""; totaldiv.text("Err"); } } }; var number = ""; var newnumber = ""; var operator = ""; var totaldiv = $("#total"); totaldiv.text("0"); $("#numbers > a").not("#clear,#clearall").click(function() { number += $(this).text(); totaldiv.text(number); testNumLength(number); }); $("#operators > a").not("#equals").click(function() { operator = $(this).text(); newnumber = number; number = ""; totaldiv.text(operator); }); $("#clear,#clearall").click(function() { number = ""; totaldiv.text("0"); if ($(this).attr("id") === "clearall") { newnumber = ""; } }); $("#equals").click(function() { if (operator === "+") { number = (parseInt(number, 10) + parseInt(newnumber, 10)).toString(10); } else if (operator === "-") { number = (parseInt(newnumber, 10) - parseInt(number, 10)).toString(10); } else if (operator === "/") { number = (parseInt(newnumber, 10) / parseInt(number, 10)).toString(10); } else if (operator === "*") { number = (parseInt(newnumber, 10) * parseInt(number, 10)).toString(10); } totaldiv.text(number); testNumLength(number); number = ""; newnumber = ""; }); $(document).keydown(function(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode === 49) { $("#one").click(); } else if (keycode === 50) { $("#two").click(); } else if (keycode === 51) { $("#three").click(); } else if (keycode === 52) { $("#four").click(); } else if (keycode === 53) { $("#five").click(); } else if (keycode === 54) { $("#six").click(); } else if (keycode === 55) { $("#seven").click(); } else if (keycode === 56) { $("#eight").click(); } else if (keycode === 57) { $("#nine").click(); } else if (keycode === 48) { $("#zero").click(); } else if (keycode === 97) { $("#clearall").click(); } else if (keycode === 99) { $("#clear").click(); } else if (keycode === 61) { $("#equals").click(); } else if (keycode === 43) { $("#plus").click(); } else if (keycode === 45) { $("#minus").click(); } else if (keycode === 42 || keycode === 120) { $("#times").click(); } else if (keycode === 47) { $("#divide").click(); } });
});
Developer | Kevin |
Username | gnarfugh |
Uploaded | October 13, 2022 |
Rating | 3 |
Size | 2,815 Kb |
Views | 26,312 |
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 |
Flex dropdown nav | 3,962 Kb |
Image slider | 3,393 Kb |
Vertical rhythm less mixin | 2,318 Kb |
Understanding closures | 2,170 Kb |
Ajax Flickr Search | 7,084 Kb |
React Scoreboard | 3,912 Kb |
Highlight table | 90,049 Kb |
Fluid Typography | 2,797 Kb |
Recommended class | 2,640 Kb |
Timeline on scroll | 4,307 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 |
Bezier Animation with straight paths | Rhernando | 2,087 Kb |
Animated Donut Chart | Jplhomer | 3,808 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
Blog Concept - Single Post | Marionebl | 9,603 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Adding and Removing Element | Accimeesterlin | 2,119 Kb |
Swiftype Lower Third | Zumwalt | 4,796 Kb |
Ball bouncing loading animation | Adam2326 | 3,144 Kb |
Spilled Paint | Darrylhuffman | 3,894 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 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!