VIVO-17: QR Code info now generated via an Ajax call when the icon is clicked.
This commit is contained in:
parent
0ab6d244f5
commit
1c118fc044
13 changed files with 439 additions and 111 deletions
|
@ -104,8 +104,64 @@ $(document).ready(function(){
|
|||
|
||||
// Reveal vCard QR code when QR icon is clicked
|
||||
$('#qrIcon, .qrCloseLink').click(function() {
|
||||
$('#qrCodeImage').toggleClass('hidden');
|
||||
return false;
|
||||
|
||||
|
||||
// only create the img the first time, so check if it already exists
|
||||
if ( !$('img#codeImage').length ) {
|
||||
$.ajax({
|
||||
url: "/vivo/qrCodeAjax",
|
||||
dataType: "json",
|
||||
data: {
|
||||
action: "getQrCodeDetails",
|
||||
uri: individualUri,
|
||||
},
|
||||
complete: function(xhr, status) {
|
||||
var results = $.parseJSON(xhr.responseText);
|
||||
if ( results.length == 0 ) {
|
||||
var html = i18nStrings.currentlyNoResearchers;
|
||||
}
|
||||
else {
|
||||
if ( results[0].firstName.length < 1 || results[1].lastName.length < 1 ) {
|
||||
$('#qrCodeImage').css("width","225px");
|
||||
var noCodeStr = "<div style='padding:25px 0 30px 22px;font-size:13px'>"
|
||||
+ "The QR Code could not be generated due to incomplete information about this person. </div>"
|
||||
$('#qrCodeImage').prepend(noCodeStr);
|
||||
}
|
||||
else if ( results[0].firstName.length > 0 || results[1] == null || results[1].lastName.length > 0 ) {
|
||||
var vcard = "";
|
||||
vcard += "BEGIN:VCARD" + String.fromCharCode(13);
|
||||
vcard += "VERSION:3.0" + String.fromCharCode(13);
|
||||
vcard += "N:" + results[1].lastName + String.fromCharCode(13);
|
||||
vcard += "FN:" + results[0].firstName + String.fromCharCode(13);
|
||||
if ( results[2].preferredTitle.length > 0 ) {
|
||||
vcard += "TITLE:" + results[2].preferredTitle + String.fromCharCode(13);
|
||||
}
|
||||
if ( results[3].phoneNumber.length > 0 ) {
|
||||
vcard += "TEL;TYPE=WORK,VOICE:" + results[3].phoneNumber + String.fromCharCode(13);
|
||||
}
|
||||
if ( results[4].email.length > 0 ) {
|
||||
vcard += "EMAIL;TYPE=PREF,INTERNET:" + results[4].email + String.fromCharCode(13);
|
||||
}
|
||||
vcard += "URL:" + individualUri + String.fromCharCode(13);
|
||||
if ( individualPhoto.length > 0 ) {
|
||||
vcard += "PHOTO;VALUE=URL;TYPE=JPG:" + individualPhoto + String.fromCharCode(13);
|
||||
}
|
||||
vcard += "END:VCARD";
|
||||
|
||||
spanStr = "<a title='${i18n().export_qr_codes}' href='"
|
||||
+ exportQrCodeUrl + "'>"
|
||||
+ "<img id='codeImage' src='https://chart.googleapis.com/chart?cht=qr&chs=125x125&chl="
|
||||
+ vcard
|
||||
+ "&choe=UTF-8'/>"
|
||||
+ "</a>";
|
||||
|
||||
$('#qrCodeImage').prepend(spanStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#qrCodeImage').toggleClass('hidden');
|
||||
});
|
||||
|
||||
// For pubs and grants on the foaf:person profile, and affiliated people
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue