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,299 |
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 |
Responsive Table | 2,303 Kb |
Highlight table | 90,049 Kb |
Sticky nav | 5,206 Kb |
Columns flex medicare | 3,195 Kb |
Hamburger | 2,396 Kb |
Timeline on scroll | 4,307 Kb |
Image slider | 3,393 Kb |
Small fizzbuzz | 1,412 Kb |
Final responsive typography forever | 2,478 Kb |
A Pen by kevin | 3,018 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 |
Print element on a page | Mrs_snow | 2,081 Kb |
Cant get enough icecream in pure css3 | Melawire | 4,322 Kb |
Ghost | Mghayour | 11,738 Kb |
Roman Numerical Converter | Vhall_io | 2,102 Kb |
TimelineMax Circular loader | Nicolund | 2,649 Kb |
Fullscreen audio play button | 72 | 2,148 Kb |
Polygon Dodecahedron in CSS | Vennsoh | 7,606 Kb |
Review test | Otro_user_gil | 4,054 Kb |
Basic HTML5 Structure | YuvarajTana | 1,289 Kb |
Navcube | Wbarlow | 4,775 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!