Skip to content
Permalink
135b674836
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
41 lines (39 sloc) 1.17 KB
jQuery(document).ready(function($){
if( $('#uc_people_lookup').length ){
$('#uc_people_lookup_search').click(function(ev){
ev.preventDefault();
var query = $('#uc_people_lookup').val();
if( (query.length == 8 && query.match(/[a-z]{3}[0-9]{5}/)) || query.match(/uconn.edu/) ){
$.ajax({
url: ajax_object.ajax_url,
data: { 'action': 'uc_people_lookup', 'query': query },
success: function(response){
if( !isEmpty(response) ){
$('#uc_people_lookup_metabox p.howto').text("Person found");
var fields = ['first_name', 'last_name', 'phone', 'email'];
fields.forEach(function(el,i,a){
$('#acf-field_'+el).val("");
if( response.hasOwnProperty(el) ){
$('#acf-field_'+el).val( response[el] );
}
});
} else {
$('#uc_people_lookup_metabox p.howto').text("Person not found");
}
},
dataType: 'json'
});
} else {
$('#uc_people_lookup_metabox p.howto').text("Invalid e-mail address or NetID entered");
}
});
}
});
function isEmpty( object ){
for( var key in object ){
if( Object.prototype.hasOwnProperty.call(object,key) ){
return false;
}
}
return true;
}