Created
April 25, 2012 21:26
-
-
Save AmusableLemur/2493579 to your computer and use it in GitHub Desktop.
A simple webapp to calculate alcohol per krona
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Alkohol Per Krona</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> | |
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> | |
</head> | |
<body> | |
<div data-role="page" data-theme="a" id="input"> | |
<div data-role="header"> | |
<h1>APK</h1> | |
</div><!-- /header --> | |
<div data-role="content"> | |
<?php | |
if (isset($_GET['amount']) && isset($_GET['alcohol']) && isset($_GET['price'])) | |
{ | |
if ($_GET['price'] == 0) | |
{ | |
$apk = 'Oändligt'; | |
} | |
else | |
{ | |
$apk = round($_GET['amount'] * (($_GET['alcohol'] + $_GET['tenths']) / 10) / $_GET['price'], 1, PHP_ROUND_HALF_UP); | |
} | |
?> | |
<h1 style="text-align:center"><?php echo $apk ?> ml Alkohol Per Krona</h1> | |
<a href="./" data-role="button" data-icon="arrow-l">Ny beräkning</a> | |
<?php | |
} | |
else | |
{ | |
?> | |
<form action="./" method="get"> | |
<fieldset> | |
<div data-role="fieldcontain"> | |
<label for="amount">Mängd (cl)</label> | |
<input type="number" name="amount" min="1" id="amount" value="" /> | |
</div> | |
<div data-role="fieldcontain"> | |
<label for="alcohol">Alkohol (Hela %)</label> | |
<input type="range" name="alcohol" id="alcohol" value="7" min="1" max="99" data-highlight="true" /> | |
</div> | |
<div data-role="fieldcontain"> | |
<label for="tenths">Alkohol (Tiondelars %)</label> | |
<input type="range" name="tenths" id="tenths" value="0" min="0" max="10" data-highlight="true" /> | |
</div> | |
<div data-role="fieldcontain"> | |
<label for="price">Pris (kr)</label> | |
<input type="number" name="price" min="1" id="price" value="" /> | |
</div> | |
<button type="submit" data-role="button" data-icon="arrow-r" data-rel="dialog" data-transition="pop">Beräkna</button> | |
</fieldset> | |
</form> | |
<?php | |
} | |
?> | |
</div><!-- /content --> | |
</div><!-- /page --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment