1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | <!DOCTYPE html> <html> <head> <title>Calculator</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <link href="{{url_for('static', filename='calculator.css')}}" rel="stylesheet"> <link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'> <link rel="shortcut icon" href="{{url_for('static', filename='img/favicon.ico')}}" type="image/x-icon"> </head> <body> <div class="box"> <div class="screen"> <div class="main-screen" id="output">0</div> <div class="sub-screen" id="output2"></div> </div> <input type="hidden" id="num1"> <input type="hidden" id="operator"> <input type="hidden" id="num2"> <input type="hidden" id="temp"> <div class="container-fluid"> <div class="buttons"> <button class="btn-clear btn btn-danger" id="clearButton">C</button> <button class="btn btn-warning" >A</button> <button class="btn-operate btn btn-default" value="/">/</button> <button class="btn-operate btn btn-default" value="*">x</button> </div> <div class="buttons"> <button class="nums btn btn-default" value="7">7</button> <button class="nums btn btn-default" value="8">8</button> <button class="nums btn btn-default" value="9">9</button> <button class="btn-operate btn btn-default" value="-">-</button> </div> <div class="buttons"> <button class="nums btn btn-default" value="4">4</button> <button class="nums btn btn-default" value="5">5</button> <button class="nums btn btn-default" value="6">6</button> <button class="btn-operate btn btn-default" value="+">+</button> </div> <div class="buttons"> <button class="nums btn btn-default" value="1">1</button> <button class="nums btn btn-default" value="2">2</button> <button class="nums btn btn-default" value="3">3</button> <button class="btn-equal btn btn-info" id="resultButton">=</button> </div> <div class="buttons"> <button class="nums btn-zero btn btn-default" value="0">0</button> <button class="nums btn btn-default" value=".">.</button> </div> </div> <a href="/move/index">뒤로가기</a> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!--<script src="{{url_for('static', filename='js/ui_calc.js')}}"></script> --> <script type="text/javascript"> var $SCRIPT_ROOT = {{ request.script_root|tojson|safe }}; let mainOutput = $('#output'); let subOutput = $('#output2'); let op = $('#operator'); let num1 = $('#num1'); let num2 = $('#num2'); let temp = $('#temp'); let clearData = ()=>{ num1.val('') op.val('') num2.val('') temp.val('') }; let clearOutput = ()=>{ mainOutput.html(''); subOutput.html(''); }; let digitError = ()=>{ mainOutput.html(0); subOutput.html('Reach Digit Limit'); temp.val(0); }; $('.btn-default').click(function(e){ if (('+-*!/').indexOf(mainOutput.html()) != -1){ mainOutput.html('') } if ($(this).val() == '.' && (mainOutput.html()).indexOf('.') != -1) return; if (mainOutput.html() == '0' || subOutput.html() == 'Reach Digit Limit'){ clearOutput(); } if(temp.val() !== ''){ clearOutput(); clearData(); } clearData(); mainOutput.html($(this).val()); subOutput.append($(this).val()); if(mainOutput.html().length > 12){ digitError(); } }); $('#clearButton').click(e=>{ mainOutput.html('0'); subOutput.html(''); clearData(); }); $('.btn-equal').click(function (e) { e.preventDefault(); $.getJSON($SCRIPT_ROOT+'/calculator', {stmt:$('#output2').text()}, d=>{ $('#output').html(d.result) }); }); </script> <style> .box { font-family: 'Orbitron', sans-serif; width: 285px; height: 360px; margin: 15% auto auto; border: 1px solid #9e9b97; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), inset -1px -6px 12px 0.1px #89847e; border-radius: 20px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .screen { height: 60px; width: 240px; border: 1px solid #7c877f; background: #c7d3c5; margin: 25px 20px 5px 20px; border-radius: 6px; } .main-screen { width: 240px; height: 22px; padding: 10px 5px; font-size: 20px; text-align: right; } .sub-screen { max-width: 280px; height: 15px; padding: 10px 5px; font-size: 12px; text-align: right; } .buttons { margin: 10px auto; } button { margin: 5px; padding: 3px 10px; width: 50px; height: 30px; border: none; box-shadow: 1px 2px #666; } button:focus {outline:0 !important;} button:active { box-shadow: none; transform: translateY(4px); } .btn-zero { width: 113px; margin-right: 7px; } .btn-equal { position: absolute; margin-left: 10px; height: 75px; } footer { font-size: 10px; } @media (max-width: 425px) { .github { display: none; } } </style> </body> </html> | cs |
'Python' 카테고리의 다른 글
[플라스크] AI 계산기 ai_calculator.html (0) | 2020.04.30 |
---|---|
[플라스크] 계산기 calculator.html (0) | 2020.04.30 |
[플라스크] login.html (0) | 2020.04.30 |
[머신러닝] 캐글 타이타닉 분석코드 titanic.py (0) | 2020.04.19 |
[머신러닝] celeb A에서 제공하는 face data 사용하기 (0) | 2020.03.27 |