Changeset f0f993
- Timestamp:
- Jul 16, 2010, 4:09:10 PM (12 years ago)
- Branches:
- ng_0.6, ng_0.8, ng_0.9
- Children:
- f7b110
- Parents:
- e777bd
- Location:
- chrome/content/v_identity
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
chrome/content/v_identity/vI_helper.js
re777bd rf0f993 75 75 } 76 76 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 other95 if (address.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || address.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || address.match(/$/)) {96 name = RegExp.leftContext + RegExp.rightContext97 email = RegExp.lastMatch98 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)}106 77 } 107 78 } -
chrome/content/v_identity/vI_identityData.js
re777bd rf0f993 24 24 25 25 function 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:""; 28 29 this.id = new vI_idObj(id); 29 30 this.smtp = new vI_smtpObj(smtp); … … 39 40 } 40 41 vI_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, 43 45 id : null, 44 46 smtp : null, … … 50 52 comp : null, 51 53 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 52 87 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; 55 89 return fullName?fullName+(email?" <"+email+">":""):email 56 90 }, 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; }, 71 92 72 93 __makeHtml : function (string) { return string?string.replace(/>/g,">").replace(/</g,"<"):"" }, -
chrome/content/v_identity/vI_rdfDataEditor.js
re777bd rf0f993 94 94 95 95 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; 99 99 }, 100 100 101 101 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, 105 103 document.getElementById("identity_list").selectedItem.getAttribute("value"), 106 104 document.getElementById("smtp_server_list").selectedItem.getAttribute("key")); -
chrome/content/v_identity/vI_storage.js
re777bd rf0f993 208 208 else if (vI_storage.isMailingList(recipient)) 209 209 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 } 212 214 }, 213 215 -
chrome/content/v_identity/vI_upgrade.js
re777bd rf0f993 295 295 if ( info && info[1] ) smtp = info[1]; 296 296 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, 303 300 "email", localIdentityData, true, true, null, null) 304 301 if (Card.secondEmail.replace(/^\s+|\s+$/g,"")) 305 vI_rdfDatasource.updateRDF( vI_helper.combineNames(Card.displayName, Card.secondEmail),302 vI_rdfDatasource.updateRDF(localIdentityData.combinedName, 306 303 "email", localIdentityData, true, true, null, null) 307 304 … … 312 309 }, 313 310 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 other319 if (address.match(/<\s*[^>\s]*@[^>\s]*\s*>/) || address.match(/<?\s*[^>\s]*@[^>\s]*\s*>?/) || address.match(/$/)) {320 name = RegExp.leftContext + RegExp.rightContext321 email = RegExp.lastMatch322 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 332 311 openURL : function(aURL) { 333 312 var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
Note: See TracChangeset
for help on using the changeset viewer.