如何使用相同或更好的算法将此 PHP 函数转换为 JavaScript?
error_reporting( E_ALL ^ E_NOTICE );
if($_GET['text008']=="1br")
{ $typeservice=119;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}
if($_GET['text008']=="2br")
{
$typeservice=139;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}
if($_GET['text008']=="3br")
{
$typeservice=159;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}
if($_GET['text008']=="4br")
{
$typeservice=189;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}
if($_GET['text008']=="5br")
{
$typeservice=219;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}
if($_GET['text008']=="6br")
{
$typeservice=249;
if(isset($_GET['extras']))
foreach ($_GET['extras'] as $k){
$total +=$k;
}
echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>";
echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total;
if(isset($_GET['freq']))
{
if($_GET['freq']=="O")
{
echo "<br/>Once";
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="M")
{
echo "<br/>Monthly";
$lahat = $balyo - ($balyo * .10);
echo "<br/>Discount:$ " . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="BW")
{
echo "<br/>Bi-Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
if($_GET['freq']=="W")
{
echo "<br/>Weekly";
$lahat = $balyo - ($balyo * .15);
echo "<br/>Discount: $" . ($balyo * .15);
echo "<br/> Total: $" . $lahat;
}
}
}