var jsonSvc = "https://www.scu.edu/apps/phonebook/ws/public/search/"; var groupType = ''; var username = ''; function getPhonebookData(personID,group) { groupType = group; username = personID; $.ajax({ url: jsonSvc+'?q=='+personID, dataType: 'jsonp', success: pbsuccess }).fail(function() { console.log("Ajax get Phonebook data request to "+jsonSvc+'?id='+personID+ " failed"); }); } function pbsuccess(res) { var personData = res.results.person; var positionData = personData.positions[0]; var personContact = ''; var mapbtn = ''; var deptDescr = ''; var locDescr = ''; if ( groupType == 'faculty1' ) { if ( positionData.location != '' || positionData.buildname != '') { if ( positionData.location != '' ) { locDescr = positionData.location; } if ( positionData.location == '' && positionData.build_name != '' ) { locDescr = positionData.build_name + ' ' + positionData.loc_room; } if ( positionData.locstring != '') { locDescr = positionData.locstring; } if ( locDescr != '' ) { if ( positionData.loc_id !== '' ) { maplink = 'https://www.scu.edu/map/location/' + positionData.loc_id + '/'; locationString = '' + locDescr + ''; } else { locationString = locDescr; } personContact += '
  • ' + locationString + '
  • '; } } personContact += '
  • Email
  • '; if ( positionData.posphone != '' ) { personContact += '
  • ' +positionData.posphone + '
  • '; } if ( personData.website != '' ) { var prefix = 'http'; var pweb = personData.website; if (pweb.substr(0, prefix.length) !== prefix) { pweb = 'http://' + pweb; } personContact += '
  • Website
  • '; } } else { if ( personData.email == 'login_required' ) { personContact += '
  • Email: Login to view '; } else if ( personData.email && personData.email != '' && personData.email.indexOf("@") > 1 ) { personContact += '
  • Email: '+personData.email+' '; } else { personContact += '
  • Email: Contact Form '; } if ( positionData.posphone != '' ) { personContact += '
  • Phone: ' + positionData.posphone + ' '; } if ( positionData.location != '' || positionData.buildname != '') { if ( positionData.loc_id !== '') { mapbtn = 'Campus Map'; } if ( positionData.location != '' ) { locDescr = positionData.location; } if ( positionData.location == '' && positionData.buildname != '' ) { locDescr = positionData.buildname + ' ' + positionData.loc_room; } if ( positionData.locstring != '') { locDescr = positionData.locstring; } personContact += '
  • Location: ' + locDescr + ' ' + mapbtn + ' '; } if ( personData.website != '' ) { var prefix = 'http'; var pweb = personData.website; if (pweb.substr(0, prefix.length) !== prefix) { pweb = 'http://' + pweb; } personContact += '
  • Website: ' + pweb + ' '; } if (personData.google_scholar_link && personData.google_scholar_link != '') { var prefix = 'http'; var pweb = personData.google_scholar_link; if (pweb.substr(0, prefix.length) !== prefix) { pweb = 'http://' + pweb; } personContact += '
  • Google Scholar Link: ' + pweb + '
  • '; } personContact = ' ' + personContact + ' '; } if ( personContact != '' ) { //if (groupType == 'faculty') { //$("#personContact"+username).prepend(personContact); //} else { $("#personContact"+username).html(personContact); //} } }