<commit_before>
var Action_contact = {
  formatmozContact: null,
  sendfunc: null,

  init:function (data){
    dump('pcsync action-contact.js line7 :' + data);
    this.sendfunc = data;
  },

  request: function (data){
    dump('pcsync action-contact.js line11 :' + JSON.stringify(data));
    switch (data.command) {
      //all contacts
      case "getAllContacts":{
        this.getAllContacts(data.id, data.command);
        break;
      }
      case "clearContacts":{
        this.clearContacts(data.id, data.command);
        break;
      }
      //single contact
      case "getContact":{
        this.getContact(data.id, data.command,data.data);
        break;
      }
      case "removeContact":{
        this.removeContact(data.id, data.command,data.data);
        break;
      }
      case "addContact":{
        this.addContact(data.id, data.command,data.data);
        break;
      }
      case "updateContact":{
        this.updateContact(data.id, data.command,data.data);
        break;
      }
      //multi contacts
      case "getContacts":{
        this.getContacts(data.id, data.command,data.data);
        break;
      }
      case "removeContacts":{
        this.removeContacts(data.id, data.command,data.data);
        break;
      }
      case "addContacts":{
        this.addContacts(data.id, data.command,data.data);
        break;
      }
      case "updateContacts":{
        this.updateContacts(data.id, data.command,data.data);
        break;
      }
    case "getContactProfilePic":{
      this.getContactProfilePic(data.id, data.command, data.data);
      break;
    }
      default:
        dump('pcsync action-contact.js line57 :' + data);
        break;
    }
  },

  response: function (data){
    switch (data.command) {
      default:
        dump('pcsync action-contact.js line65 :' + data);
        break;
    }
  },

  success: function (resultid,resultcommand,resultdata){
    var contactdata = {
      action: 'response',
      id: resultid,
      command: resultcommand,
      status: 200,
      data: resultdata
    };
    dump('pcsync action-contact.js line78 :' + JSON.stringify(contactdata));
    Action_contact.sendresponse(contactdata);
    /*
     * * dump(request.result[0].photo[0].size);
     * */
  },

  error: function (resultid,resultcommand,resultdata){
    var contactdata = {
      action: 'response',
      id: resultid,
      command: resultcommand,
      status: 201,
      data: resultdata
    };
    dump('pcsync action-contact.js line93 :' + JSON.stringify(contactdata));
    Action_contact.sendresponse(contactdata);
  },

  format2mozContact: function (data){
    if(this.formatmozContact){
      //this.formatmozContact
      this.formatmozContact = null;
    }
    this.formatmozContact = new mozContact();
    this.formatmozContact.init(data);
  },
  //get contact profile picture
  getContactProfilePic: function(requestid, requestcommand, requestdata){
    var options = {
      filterBy: ['id'],
      filterOp: 'equals',
      filterValue: requestdata
    };
   var request = window.navigator.mozContacts.find(options);
   request.onsuccess = function(){
     var fr = new FileReader();
     fr.readAsDataURL(request.result[0].photo[0]);
     fr.onload = function(e){
       Action_contact.success(requestid, requestcommand, e.target.result);
     }
   };
   request.onerror = function(){
   };
  },
  //all contacts
  getAllContacts: function (requestid,requestcommand){
    var options = {
    sortBy: 'familyName',
    sortOrder: 'ascending'
    };
    var request = window.navigator.mozContacts.find(options);
    request.onsuccess = function findCallback() {
      Action_contact.success(requestid,requestcommand,request.result);
    };
    request.onerror = function findCallback() {
      Action_contact.error(requestid,requestcommand, request.result);
    };
  },

  clearContacts: function (requestid,requestcommand){<commit_msg>improve get uer profile picture<commit_after>
var Action_contact = {
  formatmozContact: null,
  sendfunc: null,

  init:function (data){
    dump('pcsync action-contact.js line7 :' + data);
    this.sendfunc = data;
  },

  request: function (data){
    dump('pcsync action-contact.js line11 :' + JSON.stringify(data));
    switch (data.command) {
      //all contacts
      case "getAllContacts":{
        this.getAllContacts(data.id, data.command);
        break;
      }
      case "clearContacts":{
        this.clearContacts(data.id, data.command);
        break;
      }
      //single contact
      case "getContact":{
        this.getContact(data.id, data.command,data.data);
        break;
      }
      case "removeContact":{
        this.removeContact(data.id, data.command,data.data);
        break;
      }
      case "addContact":{
        this.addContact(data.id, data.command,data.data);
        break;
      }
      case "updateContact":{
        this.updateContact(data.id, data.command,data.data);
        break;
      }
      //multi contacts
      case "getContacts":{
        this.getContacts(data.id, data.command,data.data);
        break;
      }
      case "removeContacts":{
        this.removeContacts(data.id, data.command,data.data);
        break;
      }
      case "addContacts":{
        this.addContacts(data.id, data.command,data.data);
        break;
      }
      case "updateContacts":{
        this.updateContacts(data.id, data.command,data.data);
        break;
      }
      case "getProfilePic":{
      this.getProfilePic(data.id, data.command, data.data);
        break;
    }
      default:
        dump('pcsync action-contact.js line57 :' + data);
        break;
    }
  },

  response: function (data){
    switch (data.command) {
      default:
        dump('pcsync action-contact.js line65 :' + data);
        break;
    }
  },

  success: function (resultid,resultcommand,resultdata){
    var contactdata = {
      action: 'response',
      id: resultid,
      command: resultcommand,
      status: 200,
      data: resultdata
    };
    dump('pcsync action-contact.js line78 :' + JSON.stringify(contactdata));
    Action_contact.sendresponse(contactdata);
    /*
     * * dump(request.result[0].photo[0].size);
     * */
  },

  error: function (resultid,resultcommand,resultdata){
    var contactdata = {
      action: 'response',
      id: resultid,
      command: resultcommand,
      status: 201,
      data: resultdata
    };
    dump('pcsync action-contact.js line93 :' + JSON.stringify(contactdata));
    Action_contact.sendresponse(contactdata);
  },

  format2mozContact: function (data){
    if(this.formatmozContact){
      //this.formatmozContact
      this.formatmozContact = null;
    }
    this.formatmozContact = new mozContact();
    this.formatmozContact.init(data);
  },
  //get contact profile picture
  getProfilePic: function(requestid, requestcommand, requestdata) {
    var options = {
      filterBy: ['id'],
      filterOp: 'equals',
      filterValue: requestdata
    };
   var request = window.navigator.mozContacts.find(options);
   request.onsuccess = function() {
     if((request.result.length>0)&&(request.result[0].photo.length>0)) {
       var fr = new FileReader();
       fr.readAsDataURL(request.result[0].photo[0]);
       fr.onload = function(e){
         Action_contact.success(requestid, requestcommand, e.target.result);
       }
     }else {
         Action_contact.success(requestid, requestcommand, '');
     }
   };
   request.onerror = function() {
     Action_contact.error(requestid, requestcommand, '');
   };
  },
  //all contacts
  getAllContacts: function (requestid,requestcommand){
    var options = {
    sortBy: 'familyName',
    sortOrder: 'ascending'
    };
    var request = window.navigator.mozContacts.find(options);
    request.onsuccess = function findCallback() {
      Action_contact.success(requestid,requestcommand,request.result);
    };
    request.onerror = function findCallback() {
      Action_contact.error(requestid,requestcommand, request.result);
    };
  },

  clearContacts: function (requestid,requestcommand){
{'fraction_non_alphanumeric': 0.13016503288249162, 'fraction_numerical': 0.005831989080531084, 'mean_word_length': 2.612729717615419, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1344424', 'n_tokens_mistral': 2505, 'n_tokens_neox': 2426, 'n_words': 437}