This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
andrewmbacon
committed
Aug 5, 2015
1 parent
a1d8f0b
commit e74a255
Showing
2 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters