-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverifyuni.js
More file actions
30 lines (29 loc) · 784 Bytes
/
verifyuni.js
File metadata and controls
30 lines (29 loc) · 784 Bytes
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
var verify = function(uni) {
if(uni.length == 7 | uni.length == 6) {
if(uni.charAt(0)) {
var swap = 3;
} else {
var swap = 2;
}
} else {
throw "length is bad"
}
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if(xmlhttp.responseText.indexOf(uni) > 0) {
return true;
} else {
return false;
}
}
}
xmlhttp.open("POST","https://directory.columbia.edu/people/uni",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //text/html
xmlhttp.send("code=" + uni);
}