Fun Calculator
Nov 21, 2023
v.0
A fun and colorful single page calculator web app with a glossy black design. Calculator Math Black Operations Single page Glossy

Versions  

Bugs  
None!

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                
<html>
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Fun Calculator</title>
<meta name="description" content="A fun and colorful single page calculator web app with a glossy black design.">
<meta name="keywords" content="calculator, glossy, black, single page, web app, math, operations">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<style>
body, html {
height: 100%;
margin: 0;
font-family: 'Roboto', sans-serif;
background-color: #121212;
color: white;
}

#main-container {
display: flex;
flex-direction: column;
height: 100%;
align-items: center;
justify-content: center;
background-color: #121212;
}

#output {
width: 100%;
padding: 20px;
background-color: #333;
text-align: right;
border-radius: 10px 10px 0 0;
overflow: hidden;
word-wrap: break-word;
word-break: break-all;
animation: fadeIn 0.5s ease-in-out;
}

#calculator {
width: 100%;
background-color: #333;
border-radius: 0 0 10px 10px;
}

.button-row {
display: flex;
justify-content: space-around;
}

.calc-button {
flex: 1;
padding: 20px;
text-align: center;
border: none;
background-color: #a9a9a9;
color: #d81b60;
font-size: 24px;
transition: background-color 0.3s ease;
cursor: pointer;
}

.calc-button:hover,
.calc-button:active {
background-color: #000;
}

.number {
color: white;
}

.operator {
color: #d81b60;
}

@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
</style>

<link rel="canonical" href="https://calculator.tools/app/fun-calculator-775/">
<meta charset="utf-8">

</head>
<body>
<div id="main-container">
<div id="output">0</div>
<div id="calculator">
<div class="button-row">
<button class="calc-button operator">√</button>
<button class="calc-button operator">AC</button>
<button class="calc-button operator">&#10060;</button>
<button class="calc-button operator">%</button>
<button class="calc-button operator">÷</button>
</div>
<div class="button-row">
<button class="calc-button operator">∛</button>
<button class="calc-button number">7</button>
<button class="calc-button number">8</button>
<button class="calc-button number">9</button>
<button class="calc-button operator">X</button>
</div>
<div class="button-row">
<button class="calc-button operator">^</button>
<button class="calc-button number">4</button>
<button class="calc-button number">5</button>
<button class="calc-button number">6</button>
<button class="calc-button operator">-</button>
</div>
<div class="button-row">
<button class="calc-button operator">( )</button>
<button class="calc-button number">1</button>
<button class="calc-button number">2</button>
<button class="calc-button number">3</button>
<button class="calc-button operator">+</button>
</div>
<div class="button-row">
<button class="calc-button operator">π</button>
<button class="calc-button number">00</button>
<button class="calc-button number">.</button>
<button class="calc-button number">0</button>
<button class="calc-button operator">=</button>
</div>
</div>
</div>

<script type="text/javascript">
try {
const output = document.getElementById('output');
let currentInput = '';
let bracketToggle = false;

function calculateResult() {
try {
output.textContent = eval(currentInput.replace(/X/g, '*').replace(/÷/g, '/').replace(/π/g, Math.PI)
.replace(/√/g, 'Math.sqrt').replace(/∛/g, 'Math.cbrt').replace(/\^/g, '**'));
} catch (error) {
output.textContent = 'Error';
}
}

function addToInput(value) {
if (/(^|[^0-9)])[-+X÷%]+$/.test(currentInput) && /[-+X÷%]/.test(value)) {
if (value === '-' && !currentInput.endsWith('-')) {
currentInput += value;
} else {
currentInput = currentInput.replace(/[-+X÷%]+$/, value);
}
} else if (!currentInput.length && /[-+X÷%]/.test(value)) {
if (value === '-') currentInput += value;
} else {
currentInput += value;
}
output.textContent = currentInput;
}

function addBracket() {
if (bracketToggle) {
currentInput += ')';
} else {
currentInput += '(';
}
bracketToggle = !bracketToggle;
output.textContent = currentInput;
}

function clearAll() {
currentInput = '';
output.textContent = '0';
}

function deleteLast() {
if (currentInput.endsWith('(') || currentInput.endsWith(')')) {
bracketToggle = !bracketToggle;
}
currentInput = currentInput.slice(0, -1);
if (currentInput === '') {
output.textContent = '0';
} else {
output.textContent = currentInput;
}
}

$('.calc-button').click(function() {
const value = $(this).text();
switch (value) {
case 'AC':
clearAll();
break;
case '√':
case '∛':
case '^':
case 'π':
case '+':
case '-':
case 'X':
case '÷':
case '%':
case '.':
case '00':
addToInput(value);
break;
case '( )':
addBracket();
break;
case '=':
calculateResult();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
addToInput(value);
break;
case '&#10060;':
deleteLast();
break;
}
});
} catch (error) {
throw error;
}
</script>
<script type="text/javascript"> var localStoragePrefix = "ct-775"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>

NEW APPS

These are apps made by the community!

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.