|
|
@ -24,7 +24,41 @@ |
|
|
|
</div> |
|
|
|
<!-- HLAVNÍ ČÁST KÓDU --> |
|
|
|
<main class="container"> |
|
|
|
<h1 class="display-1">Kalkulačka</h1> |
|
|
|
<h1 class="display-1 text-center">Kalkulačka</h1> |
|
|
|
|
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-10 offset-sm-1 text-center"> |
|
|
|
<form name="calc" action="" class="form-inline justify-content-center"> |
|
|
|
<input type="text" class="form-control" id="input_text"> |
|
|
|
|
|
|
|
<div class="text-center justify-content-center"> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('7')">7</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('8')">8</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('9')">9</button> |
|
|
|
<button type="button" class="btn btn-secondary col-sm-2" onclick="addText('+')">+</button> |
|
|
|
</div> |
|
|
|
<div class="text-center justify-content-center"> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('4')">4</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('5')">5</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('6')">6</button> |
|
|
|
<button type="button" class="btn btn-secondary col-sm-2" onclick="addText('-')">-</button> |
|
|
|
</div> |
|
|
|
<div class="text-center justify-content-center"> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('1')">1</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('2')">2</button> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('3')">3</button> |
|
|
|
<button type="button" class="btn btn-secondary col-sm-2" onclick="addText('*')">*</button> |
|
|
|
</div> |
|
|
|
<div class="text-center justify-content-center"> |
|
|
|
<button type="button" class="btn btn-primary col-sm-2" onclick="addText('0')">0</button> |
|
|
|
<button type="button" class="btn btn-dark col-sm-2" onclick="addText('.')">.</button> |
|
|
|
<button type="button" class="btn btn-outline-dark col-sm-2" onclick="calculate()">=</button> |
|
|
|
<button type="button" class="btn btn-secondary col-sm-2" onclick="addText('/')">/</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
</form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</main> |
|
|
|
|
|
|
@ -42,5 +76,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
<script src="js/bootstrap.bundle.js"></script> |
|
|
|
<script> |
|
|
|
function calculate() { |
|
|
|
// Zpracuje input, vypočítá obsah a vyhodí vysledek |
|
|
|
document.calc.input_text.value = eval(document.calc.input_text.value); |
|
|
|
} |
|
|
|
|
|
|
|
function addText(txt) { |
|
|
|
document.getElementById("input_text").value += txt; |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |