-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
121 lines (103 loc) · 5.3 KB
/
index.php
File metadata and controls
121 lines (103 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Infix Calculator</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<style>
body {
background-color: rgb(29, 29, 29);
color: whitesmoke;
}
.accordion-button:not(.collapsed) {
background: rgb(29, 29, 29);
color: whitesmoke;
}
.accordion-button:not(.collapsed)::after {
filter: brightness(0%) invert(70%);
}
.accordion-button:focus {
box-shadow: inherit;
}
</style>
</head>
<body>
<?php include 'infix_calcu.php' ?>
<div class="container mt-5 mb-5">
<div class="row">
<h1 class="display-4">Infix Calculator</h1>
<p id="header">code by Jamora, Morales, Selerio | BSCS - C83</p>
</div>
<div id="liveAlertPlaceholder"></div>
<div class="col-lg-6 mt-5 mb-5" style="padding: 0;">
<label>Enter Infix:</label><br>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="fname" id="input-field" style="width: 70%">
<button type="submit" id="Calculate" class="btn btn-primary" style="width:auto;">Calculate</button>
<button type="button" id="clear-btn" class="btn btn-secondary" onclick="clear_values()" style="width:auto;">Clear</button>
</form>
</div>
</div>
<div class="container mt-5">
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input = $_POST['fname']; // collect value of input field
if (empty($input)) {
echo "0";
}
$calcu->infix = $input;
if ($calcu->error_trap() != "") {
for ($i = 0; $i < strlen($calcu->error_trap()); $i++) {
if ($calcu->error_trap()[$i] == "1") {
echo '<script type="text/javascript" src="index.js"> </script>';
echo '<script> bootstrap_alert("input error!", " invalid character detected", "danger") </script>';
} else if ($calcu->error_trap()[$i] == "2") {
echo '<script type="text/javascript" src="index.js"> </script>';
echo '<script>bootstrap_alert("Invalid Input!", " excess number/s detected", "warning")</script>';
} else if ($calcu->error_trap()[$i] == "3") {
echo '<script type="text/javascript" src="index.js"> </script>';
echo '<script>bootstrap_alert("Invalid Input!", " excess operator/s detected", "info")</script>';
} else if ($calcu->error_trap()[$i] == "4") {
echo '<script type="text/javascript" src="index.js"> </script>';
echo '<script>bootstrap_alert("Invalid Input!", " excess parenthesis detected", "dark")</script>';
}
}
} else { ?>
<div class="col-lg-6">
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingOne">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
Infix to Postfix
</button>
</h2>
<div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
<div class="accordion-body"> <?php $calcu->infix_to_postfix(); ?> </div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="flush-headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
Stack Operation
</button>
</h2>
<div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
<div class="accordion-body"> <?php $calcu->stack_operation(); ?> </div>
</div>
</div>
</div>
</div>
<?php
if (!empty($input)) {
echo "<br>" . "= " . $calcu->final_ans . "<br>";
}
}
}
?>
</div>
<script src="index.js"></script>
<script src="bootstrap/js/bootstrap.bundle.js"></script>
</body>
</html>