honpre:'',
honsuf:'',
data:undefined,
+ update:function() {
+ // Make sure proper DOM is loaded.
+ console.log('Card.update(), #n: ' + $('#n').length);
+ console.log('Card.update(), #contacts: ' + $('#contacts li').length);
+ if($('#n').length == 0 && $('#contacts li').length > 0) {
+ $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
+ if(jsondata.status == 'success'){
+ $('#rightcontent').html(jsondata.data.page);
+ Contacts.UI.loadHandlers();
+ if($('#contacts li').length > 0) {
+ var firstid = $('#contacts li:first-child').data('id');
+ console.log('trying to load: ' + firstid);
+ $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){
+ if(jsondata.status == 'success'){
+ Contacts.UI.Card.loadContact(jsondata.data);
+ } else{
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
+ }
+ });
+ }
+ } else{
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
+ }
+ });
+ }
+ if($('#contacts li').length == 0) {
+ // load intro page
+ $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
+ if(jsondata.status == 'success'){
+ id = '';
+ $('#rightcontent').data('id','');
+ $('#rightcontent').html(jsondata.data.page);
+ } else {
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
+ }
+ });
+ }
+ },
export:function() {
document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id;
//$.get(OC.linkTo('contacts', 'export.php'),{'contactid':this.id},function(jsondata){
this.data = undefined;
// Load first in list.
if($('#contacts li').length > 0) {
+ Contacts.UI.Card.update();
+ /*
var firstid = $('#contacts li:first-child').data('id');
console.log('trying to load: ' + firstid);
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){
else{
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
}
- });
+ });*/
} else {
// load intro page
$.getJSON('ajax/loadintro.php',{},function(jsondata){
$('#reverse_comma').text(this.famname + ', ' + this.givname);*/
$('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']);
$('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']);
+ $('#contact_identity').show();
},
editNew:function(){ // add a new contact
//Contacts.UI.notImplemented();
* Reload the contacts list.
*/
update:function(){
+ console.log('Contacts.update, start');
$.getJSON('ajax/contacts.php',{},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page);
+ Contacts.UI.Card.update();
}
else{
Contacts.UI.messageBox(t('contacts', 'Error'),jsondata.data.message);