Skip to content

Commit

Permalink
Merge pull request #133 from jeevatkm/for-v2.6.0-release
Browse files Browse the repository at this point in the history
For v2.6.0 release
  • Loading branch information
jeevatkm authored Sep 11, 2023
2 parents a0271bc + 763cf8f commit 53aa48d
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Quoting Email Headers in Thunderbird
[![Version](https://img.shields.io/badge/version-2.4.0-blue.svg)](https://github.com/jeevatkm/ReplyWithHeaderMozilla/releases/latest) [![License](https://img.shields.io/github/license/jeevatkm/ReplyWithHeaderMozilla.svg)](LICENSE)
[![Version](https://img.shields.io/badge/version-2.6.0-blue.svg)](https://github.com/jeevatkm/ReplyWithHeaderMozilla/releases/latest) [![License](https://img.shields.io/github/license/jeevatkm/ReplyWithHeaderMozilla.svg)](LICENSE)

ReplyWithHeaderMozilla aka [RWH Thunderbird] is an add-on for Thunderbird mail client that enables email header.
Brings Outlook header capabilities into Thunderbird.
Expand Down
96 changes: 37 additions & 59 deletions chrome/content/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ var ReplyWithHeader = {
return recipients.trim();
},

getHeaderQuotSeq: function(selectedOption) {
let quotSeq = {
0: ['subject', 'date', 'from', 'to', 'cc'], // Default
1: ['from', 'date', 'to', 'cc', 'subject'], // Outlook
2: ['from', 'date', 'subject'], // Simple
3: ['from', 'to', 'cc', 'date', 'subject'] // Lookout
};
return quotSeq[selectedOption];
},

parseMsgHeader: function(hdr) {
// Decoding values into object
// Ref: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMsgDBHdr
Expand Down Expand Up @@ -328,6 +338,8 @@ var ReplyWithHeader = {
let rawHdr = this.getMsgHeader(this.messageUri);
let pHeader = this.parseMsgHeader(rawHdr);
let headerQuotLblSeq = this.prefs.headerQuotLblSeq;
let headerQuotLblSeqValues = this.getHeaderQuotSeq(headerQuotLblSeq);
this.log.debug('headerQuotLblSeq: ' + headerQuotLblSeq + ' \tValues: ' + headerQuotLblSeqValues);

var rwhHdr = '<div id="rwhMsgHeader">';

Expand All @@ -341,10 +353,19 @@ var ReplyWithHeader = {
let fontSize = this.prefs.headerFontSize;
let fontSizeUnit = this.prefs.headerFontSizeUnit;
let fontColor = this.prefs.headerFontColor;
let systemFontColor = this.prefs.headerSystemFontColor;
let systemFontFace = this.prefs.headerSystemFontFace;
this.log.debug('System Font face: ' + systemFontFace + '\tSystem Font Color: ' + systemFontColor);
this.log.debug('Font face: ' + fontFace + '\tFont size: ' + fontSize + fontSizeUnit + '\tColor: ' + fontColor);

let htmlTagPrefix = '<div style="font-family:' + fontFace + ' !important; color:'
+ fontColor + ' !important; font-size:' + fontSize + fontSizeUnit + ' !important;">';
let htmlTagPrefix = '<div style="';
if (!systemFontFace) {
htmlTagPrefix += 'font-family:' + fontFace + ' !important;';
}
if (!systemFontColor) {
htmlTagPrefix += ' color:' + fontColor + ' !important;';
}
htmlTagPrefix += ' font-size:' + fontSize + fontSizeUnit + ' !important;">';
let htmlTagSuffix = '</div>';

let lineColor = this.prefs.headerSepLineColor;
Expand All @@ -353,38 +374,16 @@ var ReplyWithHeader = {

rwhHdr += this.createBrTags(this.prefs.beforeHdrSpaceCnt);

rwhHdr += htmlTagPrefix + '<b>' + this.i18n.from[locale] + '</b> ' + pHeader.from + htmlTagSuffix;

if (headerQuotLblSeq == 0) { // jshint ignore:line
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.subject[locale] + '</b> ' + pHeader.subject + htmlTagSuffix;
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.date[locale] + '</b> ' + pHeader.date + htmlTagSuffix;
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.to[locale] + '</b> ' + pHeader.to + htmlTagSuffix;

if (pHeader.cc) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.cc[locale] + '</b> ' + pHeader.cc + htmlTagSuffix;
headerQuotLblSeqValues.forEach(function (hdrKey, _) {
let lbl = this.i18n[hdrKey][locale]
if (headerQuotLblSeq == 1 && hdrKey == 'date') {
lbl = this.i18n['sent'][locale]
}
} else if (headerQuotLblSeq == 3) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.to[locale] + '</b> ' + pHeader.to + htmlTagSuffix;

if (pHeader.cc) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.cc[locale] + '</b> ' + pHeader.cc + htmlTagSuffix;
}
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.date[locale] + '</b> ' + pHeader.date + htmlTagSuffix;
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.subject[locale] + '</b> ' + pHeader.subject + htmlTagSuffix;
} else if (headerQuotLblSeq == 1) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.sent[locale] + '</b> ' + pHeader.date + htmlTagSuffix;
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.to[locale] + '</b> ' + pHeader.to + htmlTagSuffix;

if (pHeader.cc) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.cc[locale] + '</b> ' + pHeader.cc + htmlTagSuffix;
if (pHeader[hdrKey]) {
rwhHdr += htmlTagPrefix + '<b>' + lbl + '</b> ' + pHeader[hdrKey] + htmlTagSuffix;
}

rwhHdr += htmlTagPrefix + '<b>' + this.i18n.subject[locale] + '</b> ' + pHeader.subject + htmlTagSuffix;

} else if (headerQuotLblSeq == 2) {
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.sent[locale] + '</b> ' + pHeader.date + htmlTagSuffix;
rwhHdr += htmlTagPrefix + '<b>' + this.i18n.subject[locale] + '</b> ' + pHeader.subject + htmlTagSuffix;
}
}, this);

} else { // for plain/text emails
if (!this.prefs.excludePlainTxtHdrPrefix) {
Expand All @@ -399,38 +398,17 @@ var ReplyWithHeader = {

rwhHdr += this.createBrTags(this.prefs.beforeHdrSpaceCnt);

rwhHdr += this.i18n.from[locale] + ' ' + pHeader.from + '<br/>';

if (headerQuotLblSeq == 0) { // jshint ignore:line
rwhHdr += this.i18n.subject[locale] + ' ' + pHeader.subject + '<br/>';
rwhHdr += this.i18n.date[locale] + ' ' + pHeader.date + '<br/>';
rwhHdr += this.i18n.to[locale] + ' ' + pHeader.to + '<br/>';

if (pHeader.cc) {
rwhHdr += this.i18n.cc[locale] + ' ' + pHeader.cc + '<br/>';
headerQuotLblSeqValues.forEach(function (hdrKey, _) {
let lbl = this.i18n[hdrKey][locale]
if (headerQuotLblSeq == 1 && hdrKey == 'date') {
lbl = this.i18n['sent'][locale]
}
} else if (headerQuotLblSeq == 3) {
rwhHdr += this.i18n.to[locale] + ' ' + pHeader.to + '<br/>';

if (pHeader.cc) {
rwhHdr += this.i18n.cc[locale] + ' ' + pHeader.cc + '<br/>';
}
rwhHdr += this.i18n.date[locale] + ' ' + pHeader.date + '<br/>';
rwhHdr += this.i18n.subject[locale] + ' ' + pHeader.subject + '<br/>';
} else if (headerQuotLblSeq == 1) {
rwhHdr += this.i18n.sent[locale] + ' ' + pHeader.date + '<br/>';
rwhHdr += this.i18n.to[locale] + ' ' + pHeader.to + '<br/>';

if (pHeader.cc) {
rwhHdr += this.i18n.cc[locale] + ' ' + pHeader.cc + '<br/>';
if (pHeader[hdrKey]) {
rwhHdr += lbl + ' ' + pHeader[hdrKey] + '<br/>';
}
}, this);

rwhHdr += this.i18n.subject[locale] + ' ' + pHeader.subject + '<br/>';

} else if (headerQuotLblSeq == 2) {
rwhHdr += this.i18n.sent[locale] + ' ' + pHeader.date + '<br/>';
rwhHdr += this.i18n.subject[locale] + ' ' + pHeader.subject + '<br/>';
}
}

rwhHdr += this.createBrTags(this.prefs.afterHdrSpaceCnt);
Expand Down
2 changes: 1 addition & 1 deletion chrome/content/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var i18n = {
"pt": "Mensagem encaminhada",
"pt-BR": "Encaminhou",
"ko": "전달된 메시지",
"nl": "het volgende geschreven",
"nl": "Doorgestuurd bericht",
"nb": "Videresendt melding",
"ru": "переадресованного сообщения",
"sv": "Vidarebefordrat brev",
Expand Down
8 changes: 8 additions & 0 deletions chrome/content/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ var prefs = {
return this.getStringPref('header.font.face');
},

get headerSystemFontFace() {
return this.getBoolPref('header.system.font.face');
},

get headerFontSize() {
return this.getIntPref('header.font.size');
},
Expand All @@ -89,6 +93,10 @@ var prefs = {
return this.getStringPref('header.font.color');
},

get headerSystemFontColor() {
return this.getBoolPref('header.system.font.color');
},

get headerQuotLblSeq() {
return this.getIntPref('header.lblseq.style');
},
Expand Down
1 change: 0 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "ReplyWithHeader",
"short_name": "RWH",
"description": "Outlook style headers and few goodies for Thunderbird",
"version": "2.6.0",
"author": "Jeevanandam M.",
Expand Down
10 changes: 10 additions & 0 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
<div class="label" id="lblFontface">Font face:</div>
<div class="hbox">
<select id="hdrFontface" data-preference="header.font.face"></select>
<div class="spacer"></div>
<label style="margin-right: 7px;">
<input type="checkbox" id="hdrSystemFontface" data-preference="header.system.font.face" />
Use system font
</label>
</div>

<div class="label" id="lblFontsize">Font size:</div>
Expand All @@ -116,6 +121,11 @@
<div class="label" id="lblFontcolor">Color:</div>
<div class="hbox">
<input id="hdrFontColor" type="color" data-preference="header.font.color" />
<div class="spacer"></div>
<label>
<input type="checkbox" id="hdrFontSystemColor" data-preference="header.system.font.color" />
Use system color
</label>
</div>
</div>
</fieldset>
Expand Down
2 changes: 2 additions & 0 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ const PREF_DEFAULTS = {
"header.lblseq.style": 1,
"header.locale": "en-US",
"header.font.face": "Tahoma",
"header.system.font.face": false,
"header.font.size": 13,
"header.font.size.unit": "px",
"header.font.color": "#000000",
"header.system.font.color": false,
"header.separator.space.before": 1,
"header.space.before": 0,
"header.space.after": 1,
Expand Down

0 comments on commit 53aa48d

Please sign in to comment.