Last active
September 1, 2015 09:20
-
-
Save mperlet/ca182b03f8468e4e65ca to your computer and use it in GitHub Desktop.
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 lang="de"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Westgeld</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<!-- Bootstrap --> | |
<!-- Das neueste kompilierte und minimierte CSS --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | |
<!-- Optionales Theme --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css"> | |
<!-- Das neueste kompilierte und minimierte JavaScript --> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> | |
<script type="text/javascript"> | |
var option = "percentOption"; | |
$(document).ready(function () { | |
$('input').keyup(function () { | |
calc(); | |
}); | |
$('input[type=radio][name=inlineRadioOptions]').change(function() { | |
if (this.value == 'percentOption') { | |
option = "percentOption"; | |
} | |
else if (this.value == 'sameOption') { | |
option = "sameOption"; | |
} | |
else if (this.value == 'hasOption') { | |
option = "hasOption"; | |
} | |
calc(); | |
}); | |
}); | |
function calc() { | |
var personA = parseInt($('#personA').val()); | |
var personB = parseInt($('#personB').val()); | |
var needAB = parseInt($('#needAB').val()); | |
var percent = (needAB/(personA+personB)); | |
if(isNaN(percent)) percent = 0.0; | |
if(isNaN(needAB)) needAB = 0; | |
if(isNaN(personA)) personA = 0; | |
if(isNaN(personB)) personB = 0; | |
var together = personA + personB; | |
$('#outputTogether').html((together) + "€"); | |
$('#outputTogetherWithout').html((together-needAB) + "€"); | |
$('#outputPercent').html(r(percent*100) + "%"); | |
if(option==="percentOption") { | |
$('#outputPersonAperMonth').html(r(percent*personA) + "€"); | |
$('#outputPersonBperMonth').html(r(percent*personB) + "€"); | |
$('#outputPersonAperMonthRest').html(r(personA - percent*personA) + "€"); | |
$('#outputPersonBperMonthRest').html(r(personB - percent*personB) + "€"); | |
} else if (option==="sameOption") { | |
$('#outputPercent').html("<s>" + r(percent*100) + "%</s>"); | |
$('#outputPersonAperMonth').html(r(needAB/2) + "€"); | |
$('#outputPersonBperMonth').html(r(needAB/2) + "€"); | |
$('#outputPersonAperMonthRest').html(r(personA-(needAB/2)) + "€"); | |
$('#outputPersonBperMonthRest').html(r(personB-(needAB/2)) + "€"); | |
} else if (option==="hasOption") { | |
var rest = (together - needAB)/2; | |
$('#outputPercent').html("<s>" + r(percent*100) + "%</s>"); | |
$('#outputPersonAperMonth').html(r(personA-rest) + "€"); | |
$('#outputPersonBperMonth').html(r(personB-rest) + "€"); | |
$('#outputPersonAperMonthRest').html(r(rest) + "€"); | |
$('#outputPersonBperMonthRest').html(r(rest) + "€"); | |
} | |
} | |
function r(num) { | |
return Math.round(num * 100) / 100; | |
} | |
</script> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Westgeld</h1> | |
Berechnet einen fairen Prozentsatz für gemeinsame Ausgaben. Alle Berechnungen finden | |
bei dir im Browser statt. Er werden keine Daten übertragen. | |
<hr /> | |
<p> | |
<label class="radio-inline"> | |
<input type="radio" name="inlineRadioOptions" checked="checked" id="inlineRadio1" value="percentOption"> gleicher Prozentsatz | |
</label> | |
<label class="radio-inline"> | |
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="sameOption"> gleiches zahlen | |
</label> | |
<label class="radio-inline"> | |
<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="hasOption"> gleiches haben | |
</label> | |
</p> | |
<p> | |
<input type="number" class="form-control" id="personA" min="0" max="500000" placeholder="Gehalt von Person A" /> | |
</p> | |
<p> | |
<input type="number" class="form-control" id="personB" min="0" max="500000" placeholder="Gehalt von Person B" /> | |
</p> | |
<p> | |
<input type="number" class="form-control" id="needAB" min="0" max="5000000" placeholder="Gemeinsame Ausgaben" /> | |
</p> | |
<p>Gemeinsames Gehalt: <span id="outputTogether"></span></p> | |
<p>Gemeinsames mit Abgaben: <span id="outputTogetherWithout"></span></p> | |
<p>Prozentsatz der Gerechtigkeit: <strong><span id="outputPercent"></span></strong></p> | |
<p> | |
PersonA pro Monat (Abgabe): <strong><span id="outputPersonAperMonth"></span></strong><br /> | |
<small>PersonA pro Monat (Übrig): <span id="outputPersonAperMonthRest"></span></small> | |
</p> | |
<p> | |
PersonB pro Monat (Abgabe): <strong><span id="outputPersonBperMonth"></span></strong><br /> | |
<small>PersonB pro Monat (Übrig): <span id="outputPersonBperMonthRest"></span></small> | |
</p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try: http://ho.io/wg_ http://bit.do/wg_ http://tiny.cc/wg_