diff --git a/index.html b/index.html new file mode 100644 index 0000000..5662bc5 --- /dev/null +++ b/index.html @@ -0,0 +1,479 @@ + + +
+ + + +" + calcHistory[i].expression + "
= " + calcHistory[i].out + "
"); + + textii = calcHistory[i].out; + let textvi = calcHistory[i].out.toString(); + textiv="1248.64"; + console.log(textvi); + testi=textvi+",,,,I Repeat.,,,,"+textvi; + console.log(testi); + // responsiveVoice.speak(textvi,'UK English Female', parameters); + // responsiveVoice.speak(" I Repeat. ",'UK English Female', parameters); + responsiveVoice.speak( testi.toString(), 'UK English Female', {rate: 0.95, onend: () => location.reload()}); + + } + } + + // Adds a token to the token list and updates the display + function addToken(token) { + if(isNaN(token)) { + if((token === "bracket-left" || token === "num-pi") && !isNaN(tokenList[tokenList.length - 1])) { + tokenList.push("op-multiply"); + } + tokenList.push(token); + } else { + if(!isNaN(tokenList[tokenList.length - 1])) { + tokenList[tokenList.length - 1] = tokenList[tokenList.length - 1] + token; + } else { + if(!isNaN(token) && (tokenList[tokenList.length - 1] === "bracket-right" || tokenList[tokenList.length - 1] === "num-pi")) { + tokenList.push("op-multiply"); + } + tokenList.push(token); + } + } + + displayEquation(); + } + + // Updates the expression display's HTML + function displayEquation() { + var htmlString = ""; + for(var i = 0; i < tokenList.length; i++) { + if(isNaN(tokenList[i])) { + if(tokenList[i] === "bracket-left") { + htmlString += " ("; + } else if(tokenList[i] === "bracket-right") { + htmlString += ") "; + } else if(tokenList[i] === "num-pi") { + htmlString += " π "; + } else { + htmlString += getOperator(tokenList[i]).symbol; + } + } else { + htmlString += tokenList[i]; + } + } + $("#expression").html(htmlString); + } + + // Deletes the last entered token + function deleteLast() { + if(isNaN(tokenList[tokenList.length - 1])) { + tokenList.pop(); + } else { + tokenList[tokenList.length - 1] = tokenList[tokenList.length - 1].slice(0, -1); + if(tokenList[tokenList.length -1].length === 0) { + tokenList.pop(); + } + } + + displayEquation(); + } + + // Shows/hides the advanced operators panel + function toggleAdvanced() { + $("#advanced-buttons").toggle(); + if($("#advanced-buttons").is(":visible")) { + $("#toggle-advanced").removeClass("button-off"); + $("#toggle-advanced span").removeClass("glyphicon-triangle-bottom").addClass("glyphicon-triangle-top"); + } else { + $("#toggle-advanced").addClass("button-off"); + $("#toggle-advanced span").removeClass("glyphicon-triangle-top").addClass("glyphicon-triangle-bottom"); + } + } + + // Triggers the appropriate action for each button that can be pressed + function processButton(button) { + switch($(button).attr("id")) { + case "delete": + deleteLast(); + break; + case "clear": + if(tokenList.length === 0) { + // calcHistory.length = 0; + // $("#calc-history-box").html(""); + } else { + tokenList.length = 0; + displayEquation(); + } + break; + case "period": + if(isNaN(tokenList[tokenList.length - 1])) { + addToken("0."); + } else { + if(tokenList[tokenList.length - 1].indexOf(".") === -1) { + tokenList[tokenList.length - 1] += "."; + } + } + displayEquation(); + break; + case "equals": + calculate(); + break; + case "toggle-advanced": + toggleAdvanced(); + break; + case "num-pi": + addToken("num-pi"); + break; + default: + if($(button).hasClass("num")) { + addToken($(button).html()); + } else { + addToken($(button).attr("id")); + } + } + } + + // Catches all button clicks on the page + + $(".btn").off('click').click(function(event) { + event.stopPropagation(); + event.stopImmediatePropagation(); + $(event.target).blur(); + // console.log("i am called"); + processButton(event.target); + return false; + }); + + $(document).on("click", ".calc-history-eq", function(event) { + var tokens = calcHistory[parseInt($(event.target).attr("id").substring(2))].tokens; + console.log(parseInt($(event.target).attr("id").substring(2))); + console.log(calcHistory); + console.log(tokens); + tokenList = tokens; + displayEquation(); + }); + +}); + +/* +function mySave() { + myContent += document.getElementById("calc-history-box").innerHTML; + console.log(myContent); + localStorage.setItem("myContent", myContent); + // console.log('History Saved'); + } +*/ + +function speak() { +// $('#61')[0].play(); +console.log('i am called'); +document.getElementById('13').play(); +} + +var down = false; + + document.addEventListener("keydown", (e) => { + + if(down) return; + down = true; + +// console.log(e.key); + +if (e.key >= 0 && e.key <= 9) { + event.preventDefault(); + e.stopPropagation(); + document.getElementById("num-" + e.key).click(); + return false; +} else if (e.key == "Enter" || e.key == "=") { + event.preventDefault(); + // document.getElementById('61').play(); + // speak(); + // document.getElementById('13').play(); + + // var speech = new SpeechSynthesisUtterance("hello world"); + // Window.speechSynthesis.speak(speech); + + document.getElementById("equals").click(); + saveData(); + // window.location.reload(); + // document.getElementById("clear").click(); + +/* + document.onkeydown = function (e) { + return false; +} + + setTimeout(function() { + // Do something after 5 seconds + location.reload();//reload page + +document.onkeydown = function (e) { + return true; +} + +}, 10000); +*/ + + +} else if (e.key == ".") { + event.preventDefault(); + document.getElementById("period").click(); +} else if (e.key == "+") { + event.preventDefault(); + document.getElementById("op-add").click(); +} else if (e.key == "-") { + event.preventDefault(); + document.getElementById("op-subtract").click(); +} else if (e.key == "*") { + event.preventDefault(); + document.getElementById("op-multiply").click(); +} else if (e.key == "/") { + event.preventDefault(); + document.getElementById("op-divide").click(); +} else if (e.key == "Backspace") { + event.preventDefault(); + document.getElementById("delete").click(); +} +}, false); + +document.addEventListener('keyup', function () { + down = false; +}, false); diff --git a/sounds/100.mp3 b/sounds/100.mp3 new file mode 100644 index 0000000..801d58b Binary files /dev/null and b/sounds/100.mp3 differ diff --git a/sounds/101.mp3 b/sounds/101.mp3 new file mode 100644 index 0000000..d31f49b Binary files /dev/null and b/sounds/101.mp3 differ diff --git a/sounds/102.mp3 b/sounds/102.mp3 new file mode 100644 index 0000000..8e30699 Binary files /dev/null and b/sounds/102.mp3 differ diff --git a/sounds/103.mp3 b/sounds/103.mp3 new file mode 100644 index 0000000..2612efe Binary files /dev/null and b/sounds/103.mp3 differ diff --git a/sounds/104.mp3 b/sounds/104.mp3 new file mode 100644 index 0000000..6f7c9f3 Binary files /dev/null and b/sounds/104.mp3 differ diff --git a/sounds/105.mp3 b/sounds/105.mp3 new file mode 100644 index 0000000..2d18802 Binary files /dev/null and b/sounds/105.mp3 differ diff --git a/sounds/106.mp3 b/sounds/106.mp3 new file mode 100644 index 0000000..8df2bd6 Binary files /dev/null and b/sounds/106.mp3 differ diff --git a/sounds/107.mp3 b/sounds/107.mp3 new file mode 100644 index 0000000..686ba29 Binary files /dev/null and b/sounds/107.mp3 differ diff --git a/sounds/109.mp3 b/sounds/109.mp3 new file mode 100644 index 0000000..787e585 Binary files /dev/null and b/sounds/109.mp3 differ diff --git a/sounds/110.mp3 b/sounds/110.mp3 new file mode 100644 index 0000000..4e74575 Binary files /dev/null and b/sounds/110.mp3 differ diff --git a/sounds/111.mp3 b/sounds/111.mp3 new file mode 100644 index 0000000..dc74412 Binary files /dev/null and b/sounds/111.mp3 differ diff --git a/sounds/13.mp3 b/sounds/13.mp3 new file mode 100644 index 0000000..41babbf Binary files /dev/null and b/sounds/13.mp3 differ diff --git a/sounds/144.mp3 b/sounds/144.mp3 new file mode 100644 index 0000000..1b20706 Binary files /dev/null and b/sounds/144.mp3 differ diff --git a/sounds/39.mp3 b/sounds/39.mp3 new file mode 100644 index 0000000..656090e Binary files /dev/null and b/sounds/39.mp3 differ diff --git a/sounds/61.mp3 b/sounds/61.mp3 new file mode 100644 index 0000000..a0fe6f9 Binary files /dev/null and b/sounds/61.mp3 differ diff --git a/sounds/96.mp3 b/sounds/96.mp3 new file mode 100644 index 0000000..2f9a21a Binary files /dev/null and b/sounds/96.mp3 differ diff --git a/sounds/97.mp3 b/sounds/97.mp3 new file mode 100644 index 0000000..4f90fe6 Binary files /dev/null and b/sounds/97.mp3 differ diff --git a/sounds/98.mp3 b/sounds/98.mp3 new file mode 100644 index 0000000..d7d909c Binary files /dev/null and b/sounds/98.mp3 differ diff --git a/sounds/99.mp3 b/sounds/99.mp3 new file mode 100644 index 0000000..0da1a88 Binary files /dev/null and b/sounds/99.mp3 differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..628d08e --- /dev/null +++ b/style.css @@ -0,0 +1,140 @@ +body { + background-color: #121212; + color: white; +} + +h1 { + margin-bottom: 20px; + text-align: center; +} + +.btn { + box-shadow: 0px 5px 10px #222222; + font-size:18px; +} + +.btn:focus { + outline: none; +} + +.button-row div { + width: 60px; + height: 60px; + text-align: center; + line-height: 60px; + margin: 5px; +} + +.button-row .btn { + width: 60px; + height: 60px; + background-color: #636363; +} + +.button-row .btn:hover { + background-color: #858585; + color: white !important; +} + +.button-orange { + background-color: #FF8400 !important; +} + +.button-orange:hover { + background-color: #FFA647 !important; +} + +.button-blue { + background-color: #0099FF !important; +} + +.button-blue:hover { + background-color: #33ADFF !important; +} + +.button-off { + background-color: #454545 !important; +} + +.calc-history-eq { + color: #B0B0B0; + cursor: pointer; +} + +#container { + width: 600px; + background-color: #2E2E2E; + height: 100%; + border-radius: 10px; + margin-top: 8%; +} + +#expression { + height: 60px; + margin-bottom: 20px; + padding: 10px; + text-align: right; + background-color: #636363; + border-radius: 5px; + font-size: 30px; + box-shadow: 0px 5px 10px #444444 inset; +} + +#standard-buttons { + display: inline-block; + margin-left: -20px; + margin-bottom: 10px; +} + +#advanced-buttons { + display: inline-block; + display: none; + margin-left: -20px; +} + +#toggle-advanced:hover { + background-color: #858585 !important; +} + +#toggle-advanced span { + pointer-events: none; +} + +#calc-history { + float: right; + width: 200px; + height: 270px; + background-color: #636363; + border-radius: 5px; + margin-top: 6px; + padding: 10px; + box-shadow: 0px 5px 10px #444444 inset; + overflow:auto; + font-size:18px; +} + +#calc-history-box { + width: 180px !important; + height: 220px !important; + resize: none; + overflow: auto; + font-size:18px; +} + +#calc-history hr { + margin-top: 5px; + margin-bottom: 5px; +} + +#footer { + background-color: #262626; + margin-left: -15px; + margin-right: -15px; + margin-bottom: -15px; + margin-top: 15px; + padding: 10px; + padding-bottom: 1px; + color: #636363; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; +} \ No newline at end of file