forked from MS-Ignis/IDPopandMom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (153 loc) · 7.2 KB
/
index.html
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
<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<html>
<head>
<title>Find Roll Number Mom And Pop</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css"
integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<script type="text/javascript">
function fn1() {
var bits_id = document.getElementById("bits_id").value;
if(bits_id.slice(-1) === "P" || bits_id.slice(-1) === "p"){
var bits_slice = bits_id.slice(-5, -1);
var campus = "pilani"
}else if (bits_id.slice(-1) === "G" || bits_id.slice(-1) === "g"){
var campus = "goa"
var bits_slice = bits_id.slice(-5, -1) + "G";
}else{
var campus = "none"
var bits_slice = bits_id.slice(-4,);
}
var ids = [];
var emails = [];
var names = [];
var orphan = false;
var ans_ids = [];
var ans_emails = [];
var ans_names = [];
var ans_branch = [];
var branch_codes = ['A1', 'A2', 'A3', 'A4', 'A5', 'A7', 'A8', 'AA', 'AB', 'B1', 'B2', 'B3', 'B4', 'B5'];
var branch_names = ['Chemical', 'Civil', 'EEE', 'Mechanical', 'B. Pharma', 'Computer Science', 'EnI', 'ECE', 'Manufacturing', 'Msc. Bio', 'Msc. Chemistry', 'Msc. Eco', 'Msc. Math', 'Msc. Physics'];
var ans_branch = [[]];
var filename = 'mailingList_full.csv';
if (campus === "goa"){
filename = 'mailing_list_goa.csv';
}
$.ajax({
url: filename,
dataType: 'text',
}).done(successFunction);
function successFunction(data) {
rows = data.split('\n');
ids = rows.map((row) => (row.split(','))[0]);
emails = rows.map((row) => (row.split(','))[1]);
names = rows.map((row) => (row.split(','))[2]);
ids.forEach(element => {
temp_branch = []
if (element.includes(bits_slice)) {
idx = ids.indexOf(element);
ans_ids.push(ids[idx]);
ans_emails.push(emails[idx]);
ans_names.push(names[idx]);
branch_codes.forEach(code => {
if (element.includes(code)) {
idx_branch = branch_codes.indexOf(code);
temp_branch.push(branch_names[idx_branch]);
console.log(temp_branch)
}
});
if (temp_branch) {
ans_branch.push(temp_branch)
}
}
});
if (ans_ids.length === 0) {
orphan = true;
ans_ids.push(ids[Math.floor((Math.random()*ids.length))]);
ans_ids.push(ids[Math.floor((Math.random()*ids.length))]);
ans_ids.push(ids[Math.floor((Math.random()*ids.length))]);
ans_ids.slice(0,3);
ans_ids.forEach(element => {
temp_branch = []
idx = ids.indexOf(element);
ans_emails.push(emails[idx]);
ans_names.push(names[idx]);
branch_codes.forEach(code => {
if (element.includes(code)) {
idx_branch = branch_codes.indexOf(code);
temp_branch.push(branch_names[idx_branch]);
console.log(temp_branch)
}
});
if (temp_branch) {
ans_branch.push(temp_branch)
}
});
}
ans_branch = ans_branch.slice(1,)
for (let i = 0; i < ans_ids.length; i++) {
var parent = document.getElementById("parentlist");
var child = document.createElement('div');
var orphanDiv = document.getElementById("orphan");
if (orphan){
orphanDiv.innerHTML = "<p>Aww. Looks like you don't have an ID mom or pop. But here's some people who might adopt you 😂 </p>"
}
child.innerHTML = '<p class = "card-text">BITS ID: ' + ans_ids[i] + '</p>' +
'<p "card-title">Name: ' + ans_names[i] + '</p>' +
'<p "card-text">Branch: ' + ans_branch[i] + '</p>' +
'<p "card-text">Email: ' + ans_emails[i] + '</p>';
parent.appendChild(child);
child.classList.add("card");
};
}
document.getElementById("parentlist").innerHTML = '<div id = "orphan"></div>';
}
</script>
<style>
* {
margin: 7px;
}
</style>
</head>
<body>
<div class="page-header">
<h1>Find Your ID Pop or ID Mom</h1>
<small>And maybe even ask them for a treat</small>
</div>
<div class="form-group">
<label>BITS ID</label>
<input id="bits_id" class="form-control" placeholder="Enter Your BITS Id">
<small class="form-text text-muted">Don't forget to add the first letter of your campus at the end (Also maybe learn to give a formal intro lol)</small>
</div>
<button onclick="fn1()" id="btn1" class="btn btn-primary" type="button">Submit</button>
<div id="parentlist"><div id = "orphan"></div></div>
<div class="jumbotron">
<p>Hope you found your mom and pop. This project is for Nawgati's brand awareness. It would be great if you could check them out</p>
<button class="btn btn-primary" type="button"><a
href=https://medium.com/@yash.mundada_91379/mapmyindia-3d04721d62d8
style="color: white">Quick Info about Nawgati</a></button>
<button class="btn btn-primary" type="button"><a
href=https://www.nawgati.com/
style="color: white">Nawgati's Page</a></button>
</div>
</body>
<footer>
<p>A project by Yash Mundada and Dhruv Tandon</p>
</footer>
<script>
var input = document.getElementById("bits_id");
// Execute a function when the user releases a key on the keyboard
input.addEventListener('keyup', function (event) {
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Cancel the default action, if needed
event.preventDefault();
fn1();
// Trigger the button element with a click
// document.getElementById("btn1").click();
}
});
</script>
</html>