├── favicons ├── favicon.ico ├── favicon-16x16.png ├── favicon-32x32.png ├── apple-touch-icon.png ├── android-chrome-192x192.png ├── android-chrome-512x512.png └── site.webmanifest ├── LICENSE ├── css ├── contact.css └── index.css ├── CONTRIBUTING_GUIDELINES.md ├── README.md ├── contact.html ├── CODE_OF_CONDUCT.md ├── index.js └── index.html /favicons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/favicon.ico -------------------------------------------------------------------------------- /favicons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/favicon-16x16.png -------------------------------------------------------------------------------- /favicons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/favicon-32x32.png -------------------------------------------------------------------------------- /favicons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/apple-touch-icon.png -------------------------------------------------------------------------------- /favicons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/android-chrome-192x192.png -------------------------------------------------------------------------------- /favicons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arman-ali-khan-786/calculator/HEAD/favicons/android-chrome-512x512.png -------------------------------------------------------------------------------- /favicons/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ARMAN ALI KHAN 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /css/contact.css: -------------------------------------------------------------------------------- 1 | .card { 2 | position: relative; 3 | text-align: center; 4 | background-color: whitesmoke; 5 | width: 45%; 6 | height: 55%; 7 | border: none; 8 | border-radius: 0.5rem; 9 | box-shadow: rgba(0, 0, 0, 0.4) 0px 30px 90px; 10 | } 11 | 12 | .header-image { 13 | position: absolute; 14 | left: 0; 15 | right: 0; 16 | top: 5%; 17 | } 18 | 19 | .pic { 20 | width: 40%; 21 | border-radius: 100%; 22 | box-shadow: rgba(0, 0, 0, 0.4) 0px 30px 60px; 23 | 24 | } 25 | 26 | .footer { 27 | position: absolute; 28 | width: 100%; 29 | margin: auto; 30 | bottom: 7%; 31 | } 32 | 33 | a { 34 | color: black; 35 | } 36 | 37 | a:hover { 38 | color: black; 39 | } 40 | 41 | .fa-brands { 42 | padding: 5% 3% 0%; 43 | } 44 | 45 | @media screen and (max-width: 600px) { 46 | .card { 47 | width: 90%; 48 | } 49 | 50 | .pic { 51 | width: 45%; 52 | } 53 | } 54 | 55 | @media screen and (max-width: 800px) and (min-width: 600px) { 56 | .card { 57 | width: 70%; 58 | } 59 | 60 | .pic { 61 | width: 45%; 62 | } 63 | } 64 | 65 | @media screen and (max-width: 1000px) and (min-width: 800px) { 66 | .card { 67 | width: 50%; 68 | } 69 | 70 | .pic { 71 | width: 55%; 72 | } 73 | } -------------------------------------------------------------------------------- /CONTRIBUTING_GUIDELINES.md: -------------------------------------------------------------------------------- 1 | # Guidelines for making Contributions 2 | 3 | Welcome to the repository! This is a mobile-ui like calculator webapp. We really appreciate your contributions towards this project! 4 | 5 | This file contains a set of guidelines for everyone who wishes to contribute to this repository. Feel free to ask questions in case of any doubts and make sure you **read the whole 6 | guidelines** 7 | 8 | * Participants/contributors have to **comment** on issues they would like to work on, and mentors will assign you. 9 | * Issues will be assigned on a **first-come, first-serve basis.** 10 | * Participants/contributors can also **open their issues**, but it needs to be verified and labelled. 11 | * Before working on any issue, make sure it is assigned to you and don't work on issues already assigned to someone else. 12 | * Don't create already existing issues. 13 | * While making any UI changes, make sure to add screenshots in your Pull Request, showing the changes you've made. 14 | * Try to keep relevant file names and variable names and add relevant comments wherever necessary. 15 | * Pull requests will be merged after being **reviewed** by a mentor or PA. 16 | 17 | ## Steps to Contribute 18 | 19 |
20 | 21 | Following is a set of steps that will help you contribute to this repository, and it is appreciated if all the contributors follow the same! 22 | 23 | * **Star and Fork** the parent repository and then clone it to your local machine. 24 | * Add upstream link to main repository and **keep fetching changes** to avoid any merge conflicts. 25 | * Make sure you **create your feature branch** with name relevant to the changes you're making. 26 | * Commit your changes with a **relevant commit message**, breifly describing the changes you've made. 27 | * Finally push your changes and create a Pull Request! 28 | 29 | Happy Contributing !!! 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## WEB CALCULATOR 2 | A Beginner friendly project for Web Enthusiasts. This project performs mathematical computations for the users. 3 |

4 | 5 |
6 | 7 | ![GitHub contributors](https://img.shields.io/github/contributors/Arman-ali-khan-786/calculator?style=for-the-badge&color=blue) 8 | ![GitHub Closed issues](https://img.shields.io/github/issues-closed-raw/Arman-ali-khan-786/calculator?style=for-the-badge&color=brightgreen) 9 | ![GitHub PR Open](https://img.shields.io/github/issues-pr/Arman-ali-khan-786/calculator?style=for-the-badge&color=aqua) 10 | ![GitHub PR closed](https://img.shields.io/github/issues-pr-closed-raw/Arman-ali-khan-786/calculator?style=for-the-badge&color=blue) 11 | ![GitHub language count](https://img.shields.io/github/languages/count/Arman-ali-khan-786/calculator?style=for-the-badge&color=brightgreen) 12 | ![GitHub top language](https://img.shields.io/github/languages/top/Arman-ali-khan-786/calculator?style=for-the-badge&color=aqua) 13 | ![GitHub Maintained](https://img.shields.io/badge/Maintained%3F-yes-brightgreen.svg?style=for-the-badge) 14 | 15 |
16 | 17 |


18 | 19 |

Project Admin

20 | 21 | 22 | 24 | 25 |

Arman Ali Khan


23 |
26 | 27 |

28 | 29 | ## Our Contributors 30 | 31 | 32 | 33 | 34 | 35 |
36 | Show some ❤️ by starring this awesome repository! 37 |
38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /contact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Web Calculator 8 | 9 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 48 | 49 | 50 |
51 |
52 | My Image 53 |
54 | 64 |
65 | 66 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /css/index.css: -------------------------------------------------------------------------------- 1 | /* add proper comments before styling */ 2 | 3 | * { 4 | margin: 0%; 5 | box-sizing: border-box; 6 | scroll-behavior: smooth; 7 | } 8 | 9 | .container { 10 | width: 470px; 11 | margin: auto; 12 | padding: 1.2rem; 13 | padding-top: 0; 14 | text-align: center; 15 | } 16 | 17 | /* css for mobile ui body */ 18 | .outerbody { 19 | width: 80%; 20 | margin: 1.2rem auto; 21 | background-color: rgb(39, 37, 37); 22 | border: 5px solid silver; 23 | padding: 12px; 24 | border-radius: 2rem; 25 | box-shadow: 3px 2px 12px black; 26 | } 27 | /* Css for front camera */ 28 | .cam { 29 | max-width: 1.6rem; 30 | min-height: 1.6rem; 31 | border: 2px solid gold; 32 | border-radius: 50%; 33 | background-color: aliceblue; 34 | } 35 | .rem-cam { 36 | max-width: 1.2rem; 37 | min-height: 1.2rem; 38 | border-radius: 50%; 39 | margin: auto; 40 | background-color: grey; 41 | } 42 | 43 | /* --------------------- */ 44 | 45 | /* css for calculation area */ 46 | .cal-area { 47 | margin: 0%; 48 | min-height: 10rem; 49 | text-align: right; 50 | padding: 14px; 51 | padding-bottom: 0rem; 52 | font-size: 2.6rem; 53 | color: white; 54 | border-bottom: 2px solid gray; 55 | } 56 | 57 | /* --------------- */ 58 | 59 | /* css for buttons on calculator */ 60 | .cal-btns { 61 | background-color: rgb(39, 37, 37); 62 | display: flex; 63 | flex-direction: row !important; 64 | margin: 12px auto; 65 | cursor: pointer; 66 | } 67 | button { 68 | font-weight: 700; 69 | border: none; 70 | background-color: rgb(39, 37, 37); 71 | color: white; 72 | cursor: pointer; 73 | } 74 | button:hover { 75 | background-color: gray !important; 76 | border-radius: 50%; 77 | } 78 | .scientific-area { 79 | display: flex; 80 | flex-direction: row !important; 81 | flex-wrap: wrap !important; 82 | justify-content: center; 83 | margin: 12px auto; 84 | gap: 0.3em; 85 | } 86 | .scientific-btn { 87 | width: 2.5em; 88 | height: 2.5em; 89 | font-size: 1.4em; 90 | } 91 | .left-area { 92 | display: flex; 93 | flex-wrap: wrap !important; 94 | justify-content: center; 95 | } 96 | .left-btn { 97 | margin: auto 0.3em; 98 | width: 2em; 99 | height: 2em; 100 | 101 | font-size: 1.8rem; 102 | cursor: pointer; 103 | } 104 | .right-area { 105 | margin-right: 1.1em; 106 | display: flex; 107 | flex-direction: column !important; 108 | gap: 0.5rem; 109 | } 110 | .right-btn { 111 | width: 2em; 112 | height: 2em; 113 | font-size: 1.6rem; 114 | border-radius: 50%; 115 | background-color: grey; 116 | color: white; 117 | cursor: pointer; 118 | } 119 | .right-btn:hover { 120 | background-color: rgb(76, 72, 72) !important; 121 | } 122 | .equal-btn { 123 | background-color: rgb(68, 234, 23); 124 | cursor: pointer; 125 | } 126 | .equal-btn:hover { 127 | background-color: rgb(55, 181, 21) !important; 128 | } 129 | 130 | /* ----------------------- */ 131 | 132 | /* css for mobile ui footer */ 133 | .footer { 134 | width: 80%; 135 | margin: 12px auto auto auto; 136 | display: flex; 137 | justify-content: space-around; 138 | } 139 | 140 | /* ------------- */ 141 | .notification-bar { 142 | height: 1.2rem; 143 | } 144 | 145 | /* Result area */ 146 | .cal-area #result-str { 147 | overflow: auto; 148 | font-size: 1.2em; 149 | } 150 | .cal-area .answer-row { 151 | display: flex; 152 | align-items: center; 153 | justify-content: space-between; 154 | } 155 | .cal-area .answer-row #savedAnswer { 156 | font-size: 25px; 157 | opacity: 0.8; 158 | } 159 | .cal-area #answer { 160 | overflow: auto; 161 | font-size: 1em; 162 | } 163 | 164 | .cal-area #result-str::-webkit-scrollbar, 165 | #answer::-webkit-scrollbar { 166 | width: 5px; /* width of the entire scrollbar */ 167 | height: 10px; 168 | } 169 | .cal-area #result-str::-webkit-scrollbar-track, 170 | #answer::-webkit-scrollbar-track { 171 | background: silver; /* color of the tracking area */ 172 | } 173 | .cal-area #result-str::-webkit-scrollbar-thumb, 174 | #answer::-webkit-scrollbar-thumb { 175 | background-color: grey; /* color of the scroll thumb */ 176 | border-radius: 20px; /* roundness of the scroll thumb */ 177 | border: 1px solid darkgrey; /* creates padding around scroll thumb */ 178 | } 179 | 180 | #result-str .superscript { 181 | vertical-align: super; 182 | font-size: 2.2rem; 183 | } 184 | 185 | @media only screen and (max-width: 600px) { 186 | .container { 187 | width: 100%; 188 | padding: 0; 189 | } 190 | .right-btn { 191 | font-size: 1.2rem; 192 | } 193 | .left-btn { 194 | font-size: 1.2rem; 195 | } 196 | .scientific-btn { 197 | font-size: 1.2rem; 198 | } 199 | .outerbody { 200 | width: 100%; 201 | } 202 | .footer { 203 | margin-top: 2rem; 204 | width: 100%; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement. 63 | All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series 85 | of actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or 92 | permanent ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within 112 | the community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.0, available at 118 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 119 | 120 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 121 | enforcement ladder](https://github.com/mozilla/diversity). 122 | 123 | [homepage]: https://www.contributor-covenant.org 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | https://www.contributor-covenant.org/faq. Translations are available at 127 | https://www.contributor-covenant.org/translations. -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Add functionalities for all buttons here 2 | // and can also add more functionalities with proper Comments 3 | 4 | //global variables 5 | // these variables are used for implementing x^y button 6 | var normal = "#result-str .normal"; // selector 7 | var superscript = "#result-str .superscript"; // selector 8 | var isSuper = false; // superscript 9 | var normalText = "0"; // normal text 10 | var superscriptText = "0"; // superscript text 11 | var timesClicked = 0; // number of times x^y button was clicked 12 | 13 | function typed(value, element) { 14 | if (isSuper) element = superscript; 15 | else element = normal; 16 | let n = document.querySelector(element).innerText; 17 | if (n == "0" && n.length == 1) 18 | //to prevent typing 0 in beginning 19 | document.querySelector(element).innerText = value; 20 | else document.querySelector(element).innerText += value; 21 | } 22 | function displayAnswer(ans) { 23 | if (!isNaN(ans)) { 24 | document.getElementById("answer").innerHTML = ans; 25 | } else { 26 | document.getElementById("answer").innerHTML = "Incorrect Expression"; 27 | document.querySelector("#answer").style.fontSize = ".6em"; // getElementById also works 28 | document.querySelector("#answer").style.fontWeight = "bold"; // getElementById also works 29 | } 30 | } 31 | function trigo(func) { 32 | let n = document.querySelector(normal).innerHTML; 33 | let n_rad = n * (Math.PI / 180); // convert to radians 34 | let ans = ""; 35 | if (func == "sin") { 36 | ans = Math.sin(n_rad); 37 | document.querySelector(normal).innerHTML = `sin(${n})`; 38 | } else if (func == "cos") { 39 | ans = Math.cos(n_rad); 40 | document.querySelector(normal).innerHTML = `cos(${n})`; 41 | } else if (func == "tan") { 42 | ans = Math.tan(n_rad); 43 | document.querySelector(normal).innerHTML = `tan(${n})`; 44 | } 45 | displayAnswer(ans); 46 | } 47 | function logarithm(func) { 48 | let n = document.querySelector(normal).innerHTML; 49 | let ans = ""; 50 | if (func == "log") { 51 | ans = Math.log10(n); 52 | document.querySelector(normal).innerHTML = `log(${n})`; 53 | } else if (func == "ln") { 54 | ans = Math.log(n); 55 | document.querySelector(normal).innerHTML = `ln(${n})`; 56 | } 57 | displayAnswer(ans); 58 | } 59 | function pow(func) { 60 | let n = document.querySelector(normal).innerHTML; 61 | let ans = ""; 62 | if (func == "sqrt") { 63 | ans = Math.pow(n, 1 / 2); 64 | document.querySelector(normal).innerHTML = `√(${n})`; 65 | } else if (func == "cbrt") { 66 | ans = Math.pow(n, 1 / 3); 67 | document.querySelector(normal).innerHTML = `∛(${n})`; 68 | } else if (func == "squared") { 69 | ans = Math.pow(n, 2); 70 | document.querySelector(normal).innerHTML = `(${n})^2`; 71 | } else if (func == "cubbed") { 72 | ans = Math.pow(n, 3); 73 | document.querySelector(normal).innerHTML = `(${n})^3`; 74 | } 75 | displayAnswer(ans); 76 | } 77 | function reset() { 78 | isSuper = false; 79 | normalText = "0"; 80 | superscriptText = "0"; 81 | timesClicked = 0; 82 | } 83 | 84 | function displaySavedAnswer() { 85 | const answer = localStorage.getItem("answer"); 86 | if (answer) { 87 | document.getElementById("savedAnswer").innerHTML = answer; 88 | } 89 | } 90 | 91 | function save(ans) { 92 | localStorage.setItem("answer", ans); 93 | } 94 | 95 | window.onload = function () { 96 | /* display previous answer at start */ 97 | displaySavedAnswer(); 98 | /* Clear */ 99 | document.getElementById("clear").onclick = function () { 100 | document.querySelector(normal).innerHTML = "0"; 101 | document.querySelector(superscript).innerHTML = ""; 102 | document.getElementById("answer").innerHTML = "0"; 103 | reset(); 104 | }; 105 | /* del */ 106 | document.getElementById("del").onclick = function () { 107 | if (isSuper) element = superscript; 108 | else element = normal; 109 | let s = document.querySelector(element).innerHTML; 110 | let length = s.length; 111 | if (length == 1) document.querySelector(element).innerHTML = 0; 112 | else document.querySelector(element).innerHTML = s.slice(0, length - 1); 113 | }; 114 | /* equal */ 115 | document.getElementById("equal-btn").onclick = function () { 116 | reset(); 117 | ans = eval(document.querySelector(normal).innerHTML); 118 | displayAnswer(ans); 119 | displaySavedAnswer(); 120 | save(ans); 121 | }; 122 | /* percent */ 123 | document.getElementById("percent").onclick = function () { 124 | let ans = document.querySelector(normal).innerHTML / 100; 125 | typed("%", normal); 126 | displayAnswer(ans); 127 | }; 128 | document.getElementById("sin").onclick = function () { 129 | trigo("sin"); 130 | }; 131 | document.getElementById("cos").onclick = function () { 132 | trigo("cos"); 133 | }; 134 | document.getElementById("tan").onclick = function () { 135 | trigo("tan"); 136 | }; 137 | document.getElementById("log").onclick = function () { 138 | logarithm("log"); 139 | }; 140 | document.getElementById("ln").onclick = function () { 141 | logarithm("ln"); 142 | }; 143 | document.getElementById("sqrt").onclick = function () { 144 | pow("sqrt"); 145 | }; 146 | document.getElementById("cbrt").onclick = function () { 147 | pow("cbrt"); 148 | }; 149 | document.getElementById("x-pow-y").onclick = function () { 150 | ++timesClicked; 151 | const normalElement = document.querySelector(normal); 152 | const superElement = document.querySelector(superscript); 153 | if (timesClicked == 1) { 154 | superElement.innerHTML = "0"; 155 | normalElement.style.border = "1px solid white"; 156 | } else if (timesClicked == 2) { 157 | normalText = normalElement.innerHTML; 158 | isSuper = true; 159 | normalElement.style.border = "0px"; 160 | superElement.style.border = "1px solid white"; 161 | } else if (timesClicked == 3) { 162 | isSuper = false; 163 | superscriptText = superElement.innerHTML; 164 | superElement.style.border = "0px"; 165 | ans = Math.pow(normalText, superscriptText); 166 | displayAnswer(ans); 167 | timesClicked = 0; 168 | } 169 | }; 170 | document.getElementById("squared").onclick = function () { 171 | pow("squared"); 172 | }; 173 | document.getElementById("cubbed").onclick = function () { 174 | pow("cubbed"); 175 | }; 176 | }; 177 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Web Calculator 7 | 8 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 32 | 38 | 44 | 45 | 46 | 47 | 48 | 49 | 86 | 87 |
88 | 89 |
90 | 91 |
92 |
93 |
94 |
95 |
96 | 97 |
98 |
99 | 101 |
102 |

103 | 0 104 |

105 |

106 | 0 107 | 0 108 |

109 |
110 | 111 |
112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 |
124 |
125 | 126 | 127 | 128 | 135 | 142 | 149 | 156 | 163 | 170 | 177 | 184 | 191 | 198 | 205 | 212 |
213 |
214 | 221 | 228 | 235 | 242 | 243 |
244 |
245 | 246 | 254 |
255 |
256 | 257 | 262 | 263 | 264 | --------------------------------------------------------------------------------