-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
270 lines (191 loc) · 6.28 KB
/
script.js
File metadata and controls
270 lines (191 loc) · 6.28 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
function login() {
window.location = "login.php";
}
function signup() {
window.location = "signup.php";
}
function results() {
window.location = "results.php";
}
function lessons() {
window.location = "lessons.php";
}
function mylessons() {
window.location = "mylessons.php";
}
function assignments() {
window.location = "assignments.php";
}
function payment() {
window.location = "payment.php";
}
function students() {
window.location = "students.php";
}
function addresult() {
window.location = "addresult.php";
}
function admin_back() {
window.location = "admin.php";
}
function teacher_back() {
window.location = "teacher.php";
}
function student_back() {
window.location = "student.php";
}
function academic_back() {
window.location = "academic.php";
}
// Global Bootstrap: false //
(() => {
'use strict'
const tooltipTriggerList = Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
tooltipTriggerList.forEach(tooltipTriggerEl => {
new bootstrap.Tooltip(tooltipTriggerEl)
})
})()
// Login Admin //
function login_admin() {
var email = document.getElementById("email");
var password = document.getElementById("password");
var rm = document.getElementById("rm");
var f = new FormData();
f.append("email", email.value);
f.append("password", password.value);
f.append("rm", rm.checked);
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4 && r.status == 200) {
var t = r.responseText;
if (t == "success") {
window.location = "admin.php";
} else {
alert(t);
}
}
}
r.open("POST", "login_admin_process.php", true);
r.send(f);
}
// Login Teacher //
function login_teacher() {
var email = document.getElementById("email");
var password = document.getElementById("password");
var rm = document.getElementById("rm");
var f = new FormData();
f.append("email", email.value);
f.append("password", password.value);
f.append("rm", rm.checked);
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4 && r.status == 200) {
var t = r.responseText;
if (t == "success") {
window.location = "teacher.php";
} else {
alert(t);
}
}
}
r.open("POST", "login_teacher_process.php", true);
r.send(f);
}
// Login Students //
function login_student() {
var email = document.getElementById("email");
var password = document.getElementById("password");
var rm = document.getElementById("rm");
var f = new FormData();
f.append("email", email.value);
f.append("password", password.value);
f.append("rm", rm.checked);
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4 && r.status == 200) {
var t = r.responseText;
if (t == "success") {
window.location = "student.php";
} else {
alert(t);
}
}
}
r.open("POST", "login_student_process.php", true);
r.send(f);
}
// Login Academic //
function login_academic() {
var email = document.getElementById("email");
var password = document.getElementById("password");
var rm = document.getElementById("rm");
var f = new FormData();
f.append("email", email.value);
f.append("password", password.value);
f.append("rm", rm.checked);
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4 && r.status == 200) {
var t = r.responseText;
if (t == "success") {
window.location = "academic.php";
} else {
alert(t);
}
}
}
r.open("POST", "login_academic_process.php", true);
r.send(f);
}
function payhere() {
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4 && r.status == 200) {
var txt = r.responseText;
// Payment completed. It can be a successful failure.
payhere.onCompleted = function onCompleted(orderId) {
console.log("Payment completed. OrderID:" + orderId);
// Note: validate the payment and show success or failure page to the customer
};
// Payment window closed
payhere.onDismissed = function onDismissed() {
// Note: Prompt user to pay again or show an error page
console.log("Payment dismissed");
};
// Error occurred
payhere.onError = function onError(error) {
// Note: show an error page
console.log("Error:" + error);
};
// Put the payment variables here
var payment = {
"sandbox": true,
"merchant_id": "1222646", // Replace your Merchant ID
"return_url": "http://localhost/assignment2/success.php", // Important
"cancel_url": "http://localhost/assignment2/error.php", // Important
"notify_url": "http://sample.com/notify",
"order_id": "#STUDENT_PAY",
"items": "MONTHLY SERVICE PAYMENT",
"amount": "3000.00",
"currency": "LKR",
"hash": txt, // *Replace with generated hash retrieved from backend
"first_name": "Sahan",
"last_name": "Perera",
"email": "sahanp@gmail.com",
"phone": "0771234567",
"address": "No.1, Galle Road",
"city": "Colombo",
"country": "Sri Lanka",
"delivery_address": "No. 46, Galle road, Kalutara South",
"delivery_city": "Kalutara",
"delivery_country": "Sri Lanka",
};
// Show the payhere.js popup, when "PayHere Pay" is clicked
payhere.startPayment(payment);
// document.getElementById('payhere-payment').onclick = function (e) {
// };
}
}
r.open("GET", "payment_process.php", true);
r.send();
}