diff --git a/README.en.md b/README.en.md deleted file mode 100644 index f6aabebb5bb1e75f9157e52429a8504b6f31f3d2..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# Front-practice2 - -#### Description -前端第二次作业 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/cal.css b/cal.css new file mode 100644 index 0000000000000000000000000000000000000000..09619cb5c4f7c0f98859d92e272ba20d541fa6ca --- /dev/null +++ b/cal.css @@ -0,0 +1,159 @@ +/* * { + margin: 0; + padding: 0; + border: none; +} +.container { + background-color: #fff; + border-radius: 50%; + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + -ms-border-radius: 50%; + -o-border-radius: 50%; + height: 500px; + margin: auto; + width: 600px; +} +h1 { + color:#495678; + font-size: 30px; + margin-top: 20px; + padding-top: 50px; + text-align: center; + text-decoration: none; +} +form { + background-color: #495678; + box-shadow: 4px 4px #3d4a65; + margin: 40px 0 30px 40px; + width: 280px; +} +.btn { + outline: none; + cursor:pointer; + font-size: 20px; + height: 45px; + margin: 5px 0 5px 10px; + width: 45px; +} +.btn:first-child { + margin: 5px 0 5px 10px; +} +.btn,#display,form { + border-radius: 25px; + -webkit-border-radius: 25px; + -moz-border-radius: 25px; + -ms-border-radius: 25px; + -o-border-radius: 25px; +} +#display { + outline: none; + background-color: #98d1d3; + box-shadow: inset 6px 6px 0px #3facc0; + color:#dededc; + font-size: 20px; + height: 47px; + text-align: right; + width: 165px; + padding-right: 10px; + margin-left: 10px; +} */ +/* Basic Reset */ +* { + border: none; + padding: 0; +} + +.center { + background-color: #fff; + border-radius: 50%; + height: 600px; + margin: auto; + width: 600px; +} +h1 { + color: #495678; + font-size: 30px; + margin-top: 20px; + padding-top: 50px; + display: block; + text-align: center; + text-decoration: none; +} + +form { + background-color: #495678; + box-shadow: 4px 4px #3d4a65; + margin: 40px auto; + padding: 40px 0 30px 40px; + width: 280px; +} +.btn { + outline: none; + cursor: pointer; + font-size: 20px; + height: 45px; + margin: 5px 0 5px 10px; + width: 45px; +} +.btn:first-child { + margin: 5px 0 5px 10px; +} +.btn, #display, form { + border-radius: 25px; +} +#display { + outline: none; + background-color: #98d1dc; + box-shadow: inset 6px 6px 0px #3facc0; + color: #dededc; + font-size: 20px; + height: 47px; + text-align: right; + width: 80%; + padding-right: 10px; + margin-left: 10px; +} +.number { + background-color: #72778b; + box-shadow: 0 5px #5f6680; + color: #dededc; +} +.number:active { + box-shadow: 0 2px #5f6680; + transform: translateX(5px) ; + -webkit-transform: translateX(5px) ; + -moz-transform: translateX(5px) ; + -ms-transform: translateX(5px) ; + -o-transform: translateX(5px) ; +} +.op { + background-color: #dededc; + box-shadow: 0 5px #bebebe; + color: #72778b; +} +.op:active { + box-shadow: 0 2px #bebebe; + transform: translateY(2px); + -webkit-transform: translateY(2px); + -moz-transform: translateY(2px); + -ms-transform: translateY(2px); + -o-transform: translateY(2px); +} +.sp { + background-color: #e3844c; + box-shadow: 0 5px #e76a3d; + color: #dededc; +} +.sp:active { + box-shadow: 0 2px #e76a3d; + transform: translateY(2px); + -webkit-transform: translateY(2px); + -moz-transform: translateY(2px); + -ms-transform: translateY(2px); + -o-transform: translateY(2px); +} +footer { + font-size: 12px; + text-align: center; +} \ No newline at end of file diff --git a/cal.html b/cal.html new file mode 100644 index 0000000000000000000000000000000000000000..51a52b1167543e1a3566efbab971702f67235b57 --- /dev/null +++ b/cal.html @@ -0,0 +1,63 @@ + + + + + + + + 计算器 + + + + + +
+

简易计算器lorem

+
+ +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ +
+ + + + + + \ No newline at end of file diff --git a/cal.js b/cal.js new file mode 100644 index 0000000000000000000000000000000000000000..6537116ada910ad76c94050bf5f55b5b98b3faeb --- /dev/null +++ b/cal.js @@ -0,0 +1,74 @@ +/*jshint esversion: 11 */ +document.getElementById("clear").addEventListener("click", function () { + document.getElementById("display").value = ""; +}); + +function get(value) { + // alert("你好"); + document.getElementById("display").value += value; +} + +function calculates() { + var result = 0; + result = document.getElementById("display").value; + document.getElementById("display").value = ""; + document.getElementById("display").value = eval(result); +} +function back() { + let r = document.getElementById("display").value; + r = r?.substring(0, r?.length - 1); + document.getElementById("display").value = r; +} +function log_() { + let r = document.getElementById("display").value; + document.getElementById("display").value = ""; + document.getElementById("display").value = Math.log(parseInt(r)); +} +function pow() { + document.getElementById("display").value += "**"; +} +function fac() { + let r = document.getElementById("display").value; + r = parseInt(r); + let result = 1; + while (r) { + result *= r; + r--; + } + document.getElementById("display").value = result; +} +function sq() { + let r = parseInt(document.getElementById("display").value); + document.getElementById("display").value = Math.sqrt(r); +} +function tri(value) { + let r = parseInt(document.getElementById("display").value); + if (value == "sin") document.getElementById("display").value = Math.sin(r); + else if (value == "cos") + document.getElementById("display").value = Math.cos(r); + else if (value == "tan") + document.getElementById("display").value = Math.tan(r); + else { + document.getElementById("display").value = "Error!"; + } +} +function add() { + let r = parseInt(document.getElementById("display").value); + if (r) { + if (r > 0) { + if (document.getElementById("display").value.indexOf("+") > -1) + document.getElementById("display").value = document + .getElementById("display") + .value.replace("+", "-"); + else + document.getElementById("display").value = + "+" + document.getElementById("display").value; + } else if (r < 0) { + document.getElementById("display").value = document + .getElementById("display") + .value.replace("-", "+"); + } + } else { + document.getElementById("display").value = "Error"; + } +} diff --git a/calcu.css b/calcu.css new file mode 100644 index 0000000000000000000000000000000000000000..7719e72ed1fa777b6d2ac45bc37790592d7fef02 --- /dev/null +++ b/calcu.css @@ -0,0 +1,91 @@ +#show-info { + background-color: rgba(240, 248, 255, 0.8); + margin: 100px auto 0; + width: 30% ; + height: 250px; + text-align: end; + text-overflow: ellipsis; + word-wrap: break-word; + font-size: 25px; + border-radius: 10px; + -webkit-border-radius: 20%; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + -o-border-radius: 10px; + -webkit-border-radius: 10px; + box-shadow: 2px 2px 1px 1px #888888;; +} + + +.left{ + display: flex; + flex-flow: row wrap; + justify-content: space-around; + align-content: space-around; + +} +.op { + background-color: rgba(0, 191, 255, 0.8); +} +#equal { + background-color: rgba(143, 188,143,0.8); +} +#equal:hover{ + background-color: rgba( 152,251,152,0.7); +} +button { + background-color: rgba(245, 245, 245, 0.8); +} +.left button{ + margin: 2px ; + border-radius: 10px; + flex-basis: 80px; + min-height: 60px; + flex-grow: 1; + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + -o-border-radius: 10px; +} +.right{ + display: flex; + flex-direction: column; +} +.right button{ + flex-basis: 60px; + min-width: 90px; + margin: 2px; + border-radius: 10px ; + -webkit-border-radius: 10px ; + -moz-border-radius: 10px ; + -ms-border-radius: 10px ; + -o-border-radius: 10px ; +} +.keys { + margin: 0 auto; + /* border: 1px solid ; */ + display: flex; + justify-content: center; + min-height: 300px; + width: 30%; + +} +footer { + position: relative; + left: 50px; + bottom: 250px; +} +button:active{ + transform: translate(5px,3px); + -webkit-transform: translate(5px,3px); + -moz-transform: translate(5px,3px); + -ms-transform: translate(5px,3px); + -o-transform: translate(5px,3px); +} +button.num:hover,.opbtn:hover{ + background-color: rgba( 240,248,255,0.7); +} +button.op:hover{ + background-color: rgba(135,206,250,0.7); +} + diff --git a/calcu.html b/calcu.html new file mode 100644 index 0000000000000000000000000000000000000000..e0e8232cd54b515c18009da022ad943e01aae743 --- /dev/null +++ b/calcu.html @@ -0,0 +1,57 @@ + + + + + 计算器 + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + +
+
+ + + + \ No newline at end of file diff --git a/calcu.js b/calcu.js new file mode 100644 index 0000000000000000000000000000000000000000..970b8ea586d471a4f78fffce9329a36374257f59 --- /dev/null +++ b/calcu.js @@ -0,0 +1,92 @@ +/*jshint esversion: 11 */ +var pre = "2"; +function show(val) { + let item = val.innerHTML; + if (val.value) { + item = val.value; + document.getElementById("show-info").innerHTML += item; + } else { + document.getElementById("show-info").innerHTML += item; + } +} +function cal(val) { + if (val.id) { + let result = document + .getElementById("show-info") + .innerHTML.replace(/π/, "Math.PI"); + result = eval(result.replace(/e/, "Math.E")); + if (result) { + document.getElementById("show-info").innerHTML = result.toFixed(+pre); + } else { + // alert("fuck"); + document.getElementById("show-info").innerHTML = "ERROR!"; + } + } else { + let result; + if (val.value) { + let value = val.value; + + if (value === "double") { + result = eval(document.getElementById("show-info").innerHTML); + document.getElementById("show-info").innerHTML = Math.pow(result, 2); + } else if (value === "clear") { + document.getElementById("show-info").innerHTML = ""; + } else if (value === "sqrt") { + result = eval(document.getElementById("show-info").innerHTML); + document.getElementById("show-info").innerHTML = Math.sqrt(result); + } else { + let r = document.getElementById("show-info").innerHTML; + document.getElementById("show-info").innerHTML = r?.substring( + 0, + r?.length - 1 + ); + if (r.length == 1) { + document.getElementById("show-info").innerHTML = ""; + } + } + } else { + let value = val.innerHTML; + result = eval(document.getElementById("show-info").innerHTML); + switch (value) { + case "sin": + document.getElementById("show-info").innerHTML = Math.sin(result); + break; + case "cos": + document.getElementById("show-info").innerHTML = Math.cos(result); + break; + case "tan": + document.getElementById("show-info").innerHTML = Math.tan(result); + break; + case "lg": + document.getElementById("show-info").innerHTML = Math.log10(result); + break; + case "ln": + document.getElementById("show-info").innerHTML = Math.log(result); + break; + } + } + } +} +function change_pre(val) { + let r = val.value; + pre = r; +} +function change_num() { + let r = parseInt(document.getElementById("show-info").innerHTML); + + if (r) { + if (r > 0) { + if (document.getElementById("show-info").innerHTML.indexOf("+") > -1) + document.getElementById("show-info").innerHTML = document + .getElementById("show-info") + .innerHTML.replace("+", "-"); + else + document.getElementById("show-info").innerHTML = + "+" + document.getElementById("show-info").innerHTML; + } else if (r < 0) { + document.getElementById("show-info").innerHTML = document + .getElementById("show-info") + .innerHTML.replace("-", "+"); + } + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..a519c7e73e2df952e8fd51036616942984275999 --- /dev/null +++ b/readme.md @@ -0,0 +1,2 @@ +6. 两个计算器.. +6. 样式有点丑 也许我应该提升一下美感