Skip to content

Instantly share code, notes, and snippets.

@judsonmitchell
Last active August 29, 2015 13:56
Show Gist options
  • Save judsonmitchell/8945712 to your computer and use it in GitHub Desktop.
Save judsonmitchell/8945712 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<meta charset="utf-8">
<title>Good Time Calculator</title>
</head>
<body>
<form role="form">
<div class="form-group">
<label for="days">Length of sentence</label>
<input type="number" class="form-control" id="days" placeholder="Number of Days in Sentence">
</div>
<div class="form-group">
<label for="credit">Length of time the judge credited client for time-served</label>
<input type="number" class="form-control" id="credit" placeholder="Number of Days Credited">
</div>
<div class="form-group">
<label for "type">Type of offense?</label>
<select class="form-control" id="type">
<option value="true">Felony</option>
<option value="false">Misdemeanor</option>
</select>
</div>
<div class="form-group">
<label for "violence">Was it a crime of violence?</label>
<select class="form-control" id="violence">
<option value="true">Yes</option>
<option value="false" selected=selected>No</option>
</select>
</div>
<div class="form-group">
<label for "sex">Was it a sex offense?</label>
<select class="form-control" id="sex">
<option value="true">Yes</option>
<option value="false" selected=selected>No</option>
</select>
</div>
<button type="submit" class="btn btn-default">Calculate Good Time</button>
</form>
<div id="result"></div>
</body>
</html>
//Define the result variable
var numDays;
/*
When someone clicks the submit button on the form,
this function is triggered
*/
$('form').submit(function (e) {
e.preventDefault();
var sentence = $('#days').val(); //value of "Number of Days Input"
var creditedDays = $('#credit').val();//value of next input, etc
var felony = $('#type').val();
var violence = $('#violence').val();
var sex = $('#sex').val();
result = $('#result');
if (felony === 'true'){
if (sex === 'true' || violence === 'true'){
/*
if it is a felony violence/sex crime, the amount of time left
to be served will be the 85% of the sentence remaining after
subtracting the amount of time credited by the judge for
time served prior to sentencing.
*/
numDays = (sentence - creditedDays) * 0.85;
} else {
/*
if it is a felony non-sex/non-violence crime, the amount
of time left to be served will be 40% of the sentence
remaining after subtracting the amount of time credited by
the judge for time served prior to sentencing.
*/
numDays = (sentence - creditedDays) * 0.4;
}
} else {
if (violence === 'true'){
/*
if it is a misdemeanor crime of violence, client
must serve 85% of the sentence remaining after subtracting
the amount of time the judge credited the client for
time served prior to sentencing
*/
numDays = (sentence - creditedDays) * 0.85;
} else {
/*
if it is a regular misdemeanor, the time the client must serve
is %50 of the sentence remaining after subtracting the amount
of time the judge credited the client for time served prior to sentencing.
*/
numDays = (sentence - creditedDays) * 0.5;
}
result.html('Your client will serve ' + numDays + ' days with good time');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment