<commit_before><!DOCTYPE html>
<html>
<head>
<title>Tip Calculator</title>
<style>
	body{
		/*background code via http://lea.verou.me/css3patterns/*/
		background:
		linear-gradient(135deg, lavender 22px, thistle 22px, thistle 24px, transparent 24px, transparent 67px, thistle 67px, thistle 69px, transparent 69px),
		linear-gradient(225deg, lavender 22px, thistle 22px, thistle 24px, transparent 24px, transparent 67px, thistle 67px, thistle 69px, transparent 69px)0 64px;
		background-color:lavender;
		background-size: 64px 128px
	}
	div.outer{
		background-color: papayawhip;
		position: relative;
		max-width: 270px;
		border: 3px solid indigo;
		padding: 15px;
		margin: 15px;
		color: indigo;
	}
	div.inner{
		background-color: peachpuff;
		max-width: 230px;
		border: 2px solid indigo;
		padding: 15px;
		margin: 5px;
		color: indigo;
	}
</style>
</head>
<body>
<?php
	$bill=$percent=$cpercent=0.0;
	$split=0;
	$print=$printSplit=false;
	$error_bill=$error_per=$error_split='';
	if($_SERVER["REQUEST_METHOD"]=="POST"){
		$bill=$_POST["bill"];
		if(is_numeric($_POST["bill"]) && $_POST["bill"]>0){
			$bill=(intval(100*$_POST["bill"]))/100.0;
			$print=true;
		}
		else{
			$error_bill='color: salmon';
		}
		$cpercent=$_POST["custompercent"];
		if($_POST["percent"]=="custom" && (!is_numeric($_POST["custompercent"]) || $_POST["custompercent"]<=0)){
			$error_per='color: salmon';
			$print=false;
		}
		switch($_POST["percent"]){
			case "10%":
				$percent=0.10;
				break;
			case "15%":
				$percent=0.15;
				break;
			case "20%":
				$percent=0.20;
				break;
			case "custom":
				if($print){
					$percent=intval($cpercent)/100.0;
				}
				break;
			default:
				$percent=0.0;
				$print=false;
		}
		$split=$_POST["split"];
		if(!is_numeric($_POST["split"]) || $_POST["split"]<=0 || !is_int(intval($split))){
			$error_split='color: salmon';
			$print=false;
		}
		elseif($split>1){
			$printSplit=true;
		}
	}
	if(empty($_POST['submitbutton'])){
		$bill=123.45;
		$cpercent=18.5;
		$split=12;
	}
?>
<div class="outer"><!--text box that encloses this calculator-->
<h2>Tip Calculator</h2>
<form action='TipCalculatorLS.php' method='post' action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<p><!--form fields and labels-->
	<span style="<?php echo $error_bill;?>">Bill subtotal:
	$<input type="text" name="bill" placeholder="123.45" maxlength="8" value="<?php echo $bill?>">
	</span><br><br>

	<span style="<?php echo $error_per;?>">Tip percentage:
	<br><br>

	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="10%") echo 'checked="checked"';?> value="10%" >10%
	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="15%") echo 'checked="checked"';?> value="15%">15%
	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="20%") echo 'checked="checked"';?> value="20%">20%
	<br>
	<input type="radio" name="percent" <?php if(!isset($_POST["percent"]) || $_POST["percent"]=="custom") echo 'checked="checked"';?> value="custom">Custom:
	<input type="text" name="custompercent" placeholder="18.5" maxlength="5" value="<?php echo $cpercent;?>">%
	</span><br><br>

	<span style="<?php echo $error_split;?>">Split between:
	$<input type="text" name="split" placeholder="12" maxlength="2" value="<?php echo $split;?>" style="<?php echo $error_split;?>">
	person(s)
	</span><br><br>

	<input type="submit" name="submitbutton" style="margin-left: 40%;">
</p>
</form>
<!--following field prints results, if input is correct-->
<?php<commit_msg>Update aesthetics and remove some unnecessary code<commit_after><!DOCTYPE html>
<html>
<head>
<title>Tip Calculator</title>
<style>
	body{
		/*background code via http://lea.verou.me/css3patterns/*/
		background:
		linear-gradient(135deg, white 22px, lavender 22px, lavender 24px, transparent 24px, transparent 67px, lavender 67px, lavender 69px, transparent 69px),
		linear-gradient(225deg, white 22px, lavender 22px, lavender 24px, transparent 24px, transparent 67px, lavender 67px, lavender 69px, transparent 69px)0 64px;
		background-color:white;
		background-size: 64px 128px
	}
	div.outer{
		background-color: papayawhip;
		position: relative;
		max-width: 270px;
		border: 3px solid indigo;
		padding: 15px;
		margin: 15px;
		color: indigo;
	}
	div.inner{
		background-color: peachpuff;
		max-width: 230px;
		border: 2px solid indigo;
		padding: 15px;
		margin: 5px;
		color: indigo;
	}
	h2{
		text-align: center;
		font: 30px/1 Georgia, serif;
		font-weight: bold;
	}
</style>
</head>
<body>
<?php
	$bill=$percent=$cpercent=0.0;
	$split=0;
	$print=$printSplit=false;
	$error_bill=$error_per=$error_split='';
	if($_SERVER["REQUEST_METHOD"]=="POST"){
		$bill=$_POST["bill"];
		if(is_numeric($_POST["bill"]) && $_POST["bill"]>0){
			$bill=(intval(100*$_POST["bill"]))/100.0;
			$print=true;
		}
		else{
			$error_bill='color: salmon';
		}
		$cpercent=$_POST["custompercent"];
		if($_POST["percent"]=="custom" && (!is_numeric($_POST["custompercent"]) || $_POST["custompercent"]<=0)){
			$error_per='color: salmon';
			$print=false;
		}
		switch($_POST["percent"]){
			case "10%":
				$percent=0.10;
				break;
			case "15%":
				$percent=0.15;
				break;
			case "20%":
				$percent=0.20;
				break;
			case "custom":
				if($print){
					$percent=intval($cpercent)/100.0;
				}
				break;
			default:
				$percent=0.0;
				$print=false;
		}
		$split=$_POST["split"];
		if(!is_numeric($_POST["split"]) || $_POST["split"]<=0 || !is_int(intval($split))){
			$error_split='color: salmon';
			$print=false;
		}
		elseif($split>1){
			$printSplit=true;
		}
	}
	if(empty($_POST['submitbutton'])){
		$bill=123.45;
		$cpercent=18.5;
		$split=12;
	}
?>
<div class="outer"><!--text box that encloses this calculator-->
<h2>Tip Calculator</h2>
<form action='TipCalculatorLS.php' method='post' action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<p><!--form fields and labels-->
	<span style="<?php echo $error_bill;?>">Bill subtotal:
	$<input type="text" name="bill" placeholder="123.45" maxlength="8" value="<?php echo $bill?>" style="width: 70px">
	</span><br><br>

	<span style="<?php echo $error_per;?>">Tip percentage:<br>
	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="10%") echo 'checked="checked"';?> value="10%">10%<br>
	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="15%") echo 'checked="checked"';?> value="15%">15%<br>
	<input type="radio" name="percent" <?php if(isset($_POST["percent"]) && $_POST["percent"]=="20%") echo 'checked="checked"';?> value="20%">20%<br>
	<input type="radio" name="percent" <?php if(!isset($_POST["percent"]) || $_POST["percent"]=="custom") echo 'checked="checked"';?> value="custom">Custom:
	<input type="text" name="custompercent" placeholder="18.5" maxlength="6" value="<?php echo $cpercent;?>" style="width: 45px">%
	</span><br><br>

	<span style="<?php echo $error_split;?>">Split between:
	<input type="text" name="split" placeholder="12" maxlength="2" value="<?php echo $split;?>" style="width: 30px">
	person(s)
	</span><br><br>

	<input type="submit" name="submitbutton" value="Calculate" style="margin-left: 38%;">
</p>
</form>
<!--following field prints results, if input is correct-->
<?php
{'fraction_non_alphanumeric': 0.21883542919628213, 'fraction_numerical': 0.0401858939311099, 'mean_word_length': 5.688299817184643, 'pattern_counts': {'":': 8, '<': 119, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7086917', 'n_tokens_mistral': 3120, 'n_tokens_neox': 2668, 'n_words': 539}