This is just some static backup of the original site, don't expect every link to work!

Changeset f0f993


Ignore:
Timestamp:
Jul 16, 2010, 4:09:10 PM (12 years ago)
Author:
rene <rene@…>
Branches:
ng_0.6, ng_0.8, ng_0.9
Children:
f7b110
Parents:
e777bd
Message:

unified parsing of email addresses, recursively remove paranthesis

Location:
chrome/content/v_identity
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_helper.js

    re777bd rf0f993  
    7575        }
    7676        else return false;
    77     },
    78 
    79 // vI_upgrade.js:229:
    80 // vI_upgrade.js:232:
    81     combineNames : function (fullName, email) {
    82         if (fullName && fullName.replace(/^\s+|\s+$/g,"")) return fullName.replace(/^\s+|\s+$/g,"") + " <" + email.replace(/^\s+|\s+$/g,"") + ">"
    83         else return email?email.replace(/^\s+|\s+$/g,""):""
    84     },
    85    
    86 // vI_rdfDataEditor.js:80:
    87 // vI_rdfDatasource.js:119:
    88 // vI_rdfDatasource.js:123:
    89 // vI_rdfDatasource.js:130:
    90 // vI_upgrade.js:225:
    91 // vI_upgrade.js:256:
    92     parseAddress : function(address) {
    93         var name = ""; var email = "";
    94         // prefer an email address separated with < >, only if not found use any other
    95         if (address.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || address.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || address.match(/$/)) {
    96             name = RegExp.leftContext + RegExp.rightContext
    97             email = RegExp.lastMatch
    98             email = email.replace(/\s+|<|>/g,"")
    99             name = name.replace(/^\s+|\s+$/g,"")
    100             name = name.replace(/^\"|\"$/g,"")
    101             name = name.replace(/^\'|\'$/g,"")
    102         }
    103         return { name: name,
    104              email: email,
    105              combinedName: vI_helper.combineNames(name, email)}
    10677    }
    10778}
  • chrome/content/v_identity/vI_identityData.js

    re777bd rf0f993  
    2424
    2525function vI_identityData(email, fullName, id, smtp, extras, sideDescription, existingID) {
    26     this.email = email;
    27     this.fullName = (fullName?fullName:'');
     26    this._email = email;
     27    this._emailParsed = false;
     28    this._fullName = fullName?fullName:"";
    2829    this.id = new vI_idObj(id);
    2930    this.smtp = new vI_smtpObj(smtp);
     
    3940}
    4041vI_identityData.prototype = {
    41     email : null,
    42     fullName : null,
     42    _email : null,          // internal email-field might contain combinedName (until first queried via email)
     43    _fullName : null,
     44    _emailParsed : null,
    4345    id : null,
    4446    smtp : null,
     
    5052    comp : null,   
    5153
     54    parseEmail : function() {
     55        if (this._emailParsed) return;
     56        // parse email and move any additional parts to fullName
     57        if (this._email.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || this._email.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || this._email.match(/$/)) {
     58            this._fullName += RegExp.leftContext + RegExp.rightContext;
     59            this._email = RegExp.lastMatch;
     60//          vI_notificationBar.dump("## vI_identityData: parseEmail _fullName = '" + this._fullName + "'\n");
     61//          vI_notificationBar.dump("## vI_identityData: parseEmail _email =    '" + this._email + "'\n");
     62        }
     63        this._emailParsed = true;
     64    },
     65    get email() {
     66        this.parseEmail();
     67        return (this._email?this._email.replace(/\s+|<|>/g,""):"");
     68    },
     69    set email(email) { this._email = email; this._emailParsed = false; },
     70
     71    cleanName : function(fullName) {
     72//      vI_notificationBar.dump("## vI_identityData: cleanName init '" + fullName + "'\n");
     73        var _fullName = fullName.replace(/^\s+|\s+$/g,"");
     74        if (_fullName.search(/^\".+\"$|^'.+'$/g) != -1) {
     75            _fullName = this.cleanName(_fullName.replace(/^\"(.+)\"$|^'(.+)'$/g,"$1$2"));
     76        }
     77//      vI_notificationBar.dump("## vI_identityData: cleanName done '" + _fullName + "'\n");
     78        return _fullName;
     79    },
     80
     81    get fullName() {
     82        this.parseEmail();
     83        return (this._fullName?this.cleanName(this._fullName):"")
     84    },
     85    set fullName(fullName) { this._fullName = fullName; },
     86
    5287    get combinedName() {
    53         var email = this.email?this.email.replace(/^\s+|\s+$/g,""):"";
    54         var fullName = this.fullName?this.fullName.replace(/^\s+|\s+$/g,""):"";
     88        var fullName = this.fullName; var email = this.email;
    5589        return fullName?fullName+(email?" <"+email+">":""):email
    5690    },
    57     set combinedName(combinedName) {
    58         var name = ""; var email = "";
    59         // prefer an email address separated with < >, only if not found use any other
    60         if (combinedName.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || combinedName.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || combinedName.match(/$/)) {
    61             name = RegExp.leftContext + RegExp.rightContext
    62             email = RegExp.lastMatch
    63             email = email.replace(/\s+|<|>/g,"")
    64             name = name.replace(/^\s+|\s+$/g,"")
    65             name = name.replace(/^\"|\"$/g,"")
    66             name = name.replace(/^\'|\'$/g,"")
    67         }
    68         this.fullName = name;
    69         this.email = email;
    70     },
     91    set combinedName(combinedName) { this._email = combinedName; this._fullName = ""; this._emailParsed = false; },
    7192
    7293    __makeHtml : function (string) { return string?string.replace(/>/g,"&gt;").replace(/</g,"&lt;"):"" },
  • chrome/content/v_identity/vI_rdfDataEditor.js

    re777bd rf0f993  
    9494   
    9595    blurEvent : function(elementId) {
    96         var elem = document.getElementById(elementId)
    97         var address = vI_helper.parseAddress(elem.value)
    98         elem.value = address.combinedName;                 
     96        var elem = document.getElementById(elementId);
     97        var localIdentityData = new vI_identityData(elem.value, null, null, null, null, null, null);
     98        elem.value = localIdentityData.combinedName;                   
    9999    },
    100100   
    101101    accept : function() {
    102         var address = vI_helper.parseAddress(document.getElementById("sender").value)
    103        
    104         var localIdentityData = new vI_identityData(address.email, address.name,
     102        var localIdentityData = new vI_identityData(document.getElementById("sender").value, null,
    105103            document.getElementById("identity_list").selectedItem.getAttribute("value"),
    106104            document.getElementById("smtp_server_list").selectedItem.getAttribute("key"));
  • chrome/content/v_identity/vI_storage.js

    re777bd rf0f993  
    208208        else if (vI_storage.isMailingList(recipient))
    209209            return { recDesc : vI_storage.getMailListName(recipient), recType : "maillist" }
    210         else
    211             return { recDesc : vI_helper.parseAddress(recipient).combinedName, recType : "email" }
     210        else {
     211            var localIdentityData = new vI_identityData(recipient, null, null, null, null, null, null);
     212            return { recDesc : localIdentityData.combinedName, recType : "email" }
     213        }
    212214    },
    213215       
  • chrome/content/v_identity/vI_upgrade.js

    re777bd rf0f993  
    295295        if ( info && info[1] ) smtp = info[1];
    296296       
    297         var splitted = vI_upgrade.__parseAddress(newFullEmail);
    298         //~ alert(splitted.email + "++" + splitted.name + "++" + splitted.combinedName)
    299        
    300         var localIdentityData = new vI_identityData(splitted.email, splitted.name, id, smtp, null)
    301        
    302         vI_rdfDatasource.updateRDF(vI_helper.combineNames(Card.displayName, Card.primaryEmail),
     297        var localIdentityData = new vI_identityData(newFullEmail, null, id, smtp, null)
     298       
     299        vI_rdfDatasource.updateRDF(localIdentityData.combinedName,
    303300                        "email", localIdentityData, true, true, null, null)
    304301        if (Card.secondEmail.replace(/^\s+|\s+$/g,""))
    305             vI_rdfDatasource.updateRDF(vI_helper.combineNames(Card.displayName, Card.secondEmail),
     302            vI_rdfDatasource.updateRDF(localIdentityData.combinedName,
    306303                    "email", localIdentityData, true, true, null, null)
    307304       
     
    312309    },
    313310   
    314     // by now in vI, not accessible from here. Best change all references to vI_helper.
    315     __parseAddress : function(address) {
    316         //~ vI_notificationBar.dump("## v_identity: getAddress: parsing '" + address + "'\n")
    317         var name = ""; email = "";
    318         // prefer an email address separated with < >, only if not found use any other
    319         if (address.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || address.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || address.match(/$/)) {
    320             name = RegExp.leftContext + RegExp.rightContext
    321             email = RegExp.lastMatch
    322             email = email.replace(/\s+|<|>/g,"")
    323             name = name.replace(/^\s+|\s+$/g,"")
    324         }
    325         //~ vI_notificationBar.dump("## v_identity: getAddress: address '" + address + "' name '" +
    326             //~ name + "' email '" + email + "'\n");
    327         return { name: name,
    328              email: email,
    329              combinedName: name + " <" + email + ">"}
    330     },
    331 
    332311    openURL : function(aURL) {
    333312            var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
Note: See TracChangeset for help on using the changeset viewer.