mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-17 06:40:08 -07:00
Added country column in message list
This commit is contained in:
parent
e5efbd1c15
commit
e995ae30f4
@ -1,5 +1,10 @@
|
||||
# Change Log
|
||||
|
||||
## 3.2 - 2019-04-03
|
||||
|
||||
### Added
|
||||
- Country column to message list
|
||||
|
||||
## 3.1.4 - 2017-07-24
|
||||
|
||||
### Fixed
|
||||
|
@ -10,8 +10,9 @@ locale mailhops pt-BR jar:chrome/mailhops.jar!/locale/pt-BR/
|
||||
locale mailhops ru jar:chrome/mailhops.jar!/locale/ru/
|
||||
locale mailhops zh-CN jar:chrome/mailhops.jar!/locale/zh-CN/
|
||||
|
||||
# Postbox
|
||||
# Postbox 5
|
||||
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application=postbox@postbox-inc.com
|
||||
|
||||
# Thunberbird
|
||||
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
overlay chrome://messenger/content/messenger.xul chrome://mailhops/content/msgListColumn.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
@ -405,7 +405,7 @@ mailHops.LOG(lookupURL);
|
||||
var d = new Date();
|
||||
data.meta.cached = d.toISOString();
|
||||
//save the result
|
||||
mailHops.saveResults(JSON.stringify(data),data.response.route);
|
||||
mailHops.saveResults(data, data.response.route);
|
||||
//display the result
|
||||
mailHopsDisplay.route(header_route, mailHops.message, data.response, data.meta, lookupURL);
|
||||
} else if(data.error){
|
||||
@ -422,7 +422,7 @@ mailHops.LOG(lookupURL);
|
||||
xmlhttp.send(null);
|
||||
};
|
||||
|
||||
mailHops.saveResults = function(results,route){
|
||||
mailHops.saveResults = function(results, route){
|
||||
|
||||
if(!mailHops.msgURI)
|
||||
return false;
|
||||
@ -432,13 +432,23 @@ mailHops.saveResults = function(results,route){
|
||||
|
||||
if(!msgHdr)
|
||||
return false;
|
||||
|
||||
if(!results){
|
||||
msgHdr.setStringProperty( "MH-Route", '' );
|
||||
return false;
|
||||
}
|
||||
|
||||
msgHdr.setStringProperty( "MH-Route", results );
|
||||
var countryCode = mailHopsUtils.getOriginatingCountryCode(route);
|
||||
|
||||
if(!!countryCode){
|
||||
results.sender = { countryCode: countryCode };
|
||||
}
|
||||
|
||||
msgHdr.setStringProperty( "MH-Route", JSON.stringify(results) );
|
||||
|
||||
//Add tag
|
||||
if(!!route && !!mailHops.options.api_key){
|
||||
try {
|
||||
var countryCode = mailHopsUtils.getOriginatingCountryCode(route);
|
||||
if(!!countryCode && !!mailHops.options.api_key){
|
||||
try {
|
||||
var msg = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
|
||||
msg.clear();
|
||||
msg.appendElement(msgHdr, false);
|
||||
@ -488,8 +498,8 @@ mailHops.getResults = function(){
|
||||
};
|
||||
|
||||
mailHops.refreshCache = function(){
|
||||
mailHops.saveResults('');
|
||||
mailHops.saveResults();
|
||||
mailHops.getRoute();
|
||||
};
|
||||
|
||||
addEventListener ( "messagepane-loaded" , mailHops.setupEventListener , true ) ;
|
||||
addEventListener( "messagepane-loaded" , mailHops.setupEventListener , true );
|
70
chrome/content/msgListColumn.js
Normal file
70
chrome/content/msgListColumn.js
Normal file
@ -0,0 +1,70 @@
|
||||
var columnHandler = {
|
||||
getCellText: function(row, col) {return null;},
|
||||
getSortStringForRow: function(msgHdr) {
|
||||
msgHdr.getStringProperty( "MH-Route" );
|
||||
var countryCode = null;
|
||||
var cached_results = msgHdr.getStringProperty( "MH-Route" );
|
||||
if(cached_results){
|
||||
try {
|
||||
cached_results = JSON.parse(cached_results);
|
||||
if(cached_results.sender && cached_results.sender.countryCode){
|
||||
countryCode = cached_results.sender.countryCode;
|
||||
} else {
|
||||
countryCode = mailHopsUtils.getOriginatingCountryCode(cached_results.response.route);
|
||||
}
|
||||
if(countryCode){
|
||||
return 'chrome://mailhops/content/images/flags/'+countryCode.toLowerCase()+'.png';
|
||||
}
|
||||
} catch(e) {
|
||||
return countryCode;
|
||||
}
|
||||
}
|
||||
return countryCode;
|
||||
},
|
||||
isString: function() {return true;},
|
||||
|
||||
getCellProperties: function(row, col, props){},
|
||||
getRowProperties: function(row, props){},
|
||||
getImageSrc: function(row, col) {
|
||||
var msgKey = gDBView.getKeyAt(row);
|
||||
var msgHdr = gDBView.db.GetMsgHdrForKey(msgKey);
|
||||
var countryCode = null;
|
||||
var cached_results = msgHdr.getStringProperty( "MH-Route" );
|
||||
if(cached_results){
|
||||
try {
|
||||
cached_results = JSON.parse(cached_results);
|
||||
if(cached_results.sender && cached_results.sender.countryCode){
|
||||
countryCode = cached_results.sender.countryCode;
|
||||
} else {
|
||||
countryCode = mailHopsUtils.getOriginatingCountryCode(cached_results.response.route);
|
||||
}
|
||||
if(countryCode){
|
||||
return 'chrome://mailhops/content/images/flags/'+countryCode.toLowerCase()+'.png';
|
||||
}
|
||||
} catch(e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
getSortLongForRow: function(hdr) {return 0;}
|
||||
};
|
||||
|
||||
var CreateDbObserver = {
|
||||
// Components.interfaces.nsIObserver
|
||||
observe: function(aMsgFolder, aTopic, aData)
|
||||
{
|
||||
addCustomColumnHandler();
|
||||
}
|
||||
};
|
||||
|
||||
function doOnceLoaded() {
|
||||
var ObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
||||
ObserverService.addObserver(CreateDbObserver, "MsgCreateDBView", false);
|
||||
}
|
||||
|
||||
function addCustomColumnHandler() {
|
||||
gDBView.addColumnHandler("colMailHops", columnHandler);
|
||||
}
|
||||
|
||||
addEventListener( "load", doOnceLoaded, false );
|
16
chrome/content/msgListColumn.xul
Normal file
16
chrome/content/msgListColumn.xul
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<overlay id="mailhops_listcolumn"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<tree id="threadTree">
|
||||
<treecols id="threadCols">
|
||||
<splitter class="tree-splitter" />
|
||||
<treecol id="colMailHops" persist="hidden ordinal width"
|
||||
currentView="unthreaded" flex="2"
|
||||
label="Country" tooltiptext="Click to sort by Country" />
|
||||
</treecols>
|
||||
</tree>
|
||||
|
||||
<!-- include our javascript file -->
|
||||
<script type="application/x-javascript" src="chrome://mailhops/content/utils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://mailhops/content/msgListColumn.js"/>
|
||||
</overlay>
|
@ -70,7 +70,7 @@ var mailHopPreferences = {
|
||||
}
|
||||
if(!!this.api_key.value.trim()){
|
||||
document.getElementById("mailhops-membership-link").value='My Account';
|
||||
document.getElementById("mailhops-membership-link").setAttribute('data-account-url','https://mailhops.com/account/'+this.api_key.value.trim());
|
||||
document.getElementById("mailhops-membership-link").setAttribute('href','https://mailhops.com/account/'+this.api_key.value.trim());
|
||||
}
|
||||
if(pref.getCharPref("mail.mailHops.country_tag",'false')=='false')
|
||||
document.getElementById("mailhop.country_tag").checked = false;
|
||||
@ -87,10 +87,6 @@ var mailHopPreferences = {
|
||||
else
|
||||
document.getElementById("mailhop.hide_compact").checked = true;
|
||||
|
||||
document.getElementById("mailhops-membership-link").addEventListener("click", function () {
|
||||
mailHopsUtils.launchExternalURL(this.getAttribute('data-account-url'));
|
||||
});
|
||||
|
||||
this.saveAPIKey();
|
||||
|
||||
document.getElementById("mailhop.bar_color").addEventListener("input", function () {
|
||||
@ -152,11 +148,17 @@ var mailHopPreferences = {
|
||||
document.getElementById("rate-remaining").value='';
|
||||
document.getElementById("rate-reset").value='';
|
||||
document.getElementById("mailhops-membership-link").value='Join MailHops';
|
||||
document.getElementById("mailhops-membership-link").setAttribute('data-account-url','https://mailhops.com');
|
||||
document.getElementById("mailhops-membership-link").setAttribute('href','https://mailhops.com');
|
||||
var items = document.getElementsByClassName('filters');
|
||||
for(x in items){ items[x].disabled = true; }
|
||||
for(x in items){
|
||||
items[x].disabled = true;
|
||||
}
|
||||
var items = document.getElementsByClassName('country');
|
||||
for(x in items){ items[x].disabled = true; if(items[x].label) items[x].label = items[x].label.toUpperCase();}
|
||||
for(x in items){
|
||||
items[x].disabled = true;
|
||||
if(items[x].label)
|
||||
items[x].label = items[x].label.toUpperCase();
|
||||
}
|
||||
},
|
||||
saveAPIKey: function() {
|
||||
|
||||
@ -185,7 +187,7 @@ var mailHopPreferences = {
|
||||
else
|
||||
document.getElementById("rate-reset").value = "Resets in: "+Math.round(data.account.rate.reset/60/60)+" hr.";
|
||||
document.getElementById("mailhops-membership-link").value='My Account';
|
||||
document.getElementById("mailhops-membership-link").setAttribute('data-account-url','https://mailhops.com/account/'+api_key);
|
||||
document.getElementById("mailhops-membership-link").setAttribute('href','https://mailhops.com/account/'+api_key);
|
||||
|
||||
var items = document.getElementsByClassName('filters');
|
||||
for(x in items){ items[x].disabled = false;}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<groupbox flex="1">
|
||||
<caption label="MailHops &mailhops_tab_member_label;"/>
|
||||
<description>
|
||||
API Key <label id="mailhops-membership-link" class="text-link plain" value="Join MailHops" data-account-url="https://mailhops.com"/>
|
||||
API Key <label id="mailhops-membership-link" class="text-link plain" value="Join MailHops" href="https://mailhops.com"/>
|
||||
</description>
|
||||
<hbox align="center">
|
||||
<textbox id="mailhop.api_key" placeholder="Enter your MailHops API Member Key" width="500"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:type>2</em:type>
|
||||
<em:id>thunderbird@mailhops.com</em:id>
|
||||
<em:version>3.1.8</em:version>
|
||||
<em:version>3.2.0</em:version>
|
||||
|
||||
<em:name>MailHops</em:name>
|
||||
<em:description>MailHops maps the route an email took to get to you. Displaying the senders location, weather, user-agent and authentication used.</em:description>
|
||||
|
Loading…
x
Reference in New Issue
Block a user