1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-17 06:40:08 -07:00

Updated ForecastIO to DarkSky

Fixed bug on api_key paste with space
This commit is contained in:
Andrew Van Tassel 2016-10-11 22:30:58 -06:00
parent 7d37587a77
commit f903960c99
5 changed files with 20 additions and 14 deletions

View File

@ -1,11 +1,10 @@
# Change Log
## 2.0.0 - 2016-9-10
## 2.0.0 - 2016-10-10
### Added
- MailHops API v2
- MailHops API key for v2
- Security section in preferences
- MailHops API v2 membership
- Filters section in preferences
- Tag and mark as junk by CountryCode
- Time Traveled, total time it took for the email to reach you

View File

@ -462,7 +462,7 @@ var mailHopsDisplay =
message.time = message.time/1000;
if(message.time < 60)
distanceText += ' in '+message.time+' sec.';
else if(message.time<3600) //something is wrong if it takes this long
else if(message.time < 3600) //something is wrong if it takes this long
distanceText += ' in '+Math.round(message.time/60)+' min.';
else //something is wrong if it takes this long
distanceText += ' in '+Math.round(message.time/60/60)+' hrs.';

View File

@ -102,9 +102,9 @@ var mailHopPreferences = {
document.getElementById("country_"+this.country_filter[c]).checked=true;
}
}
if(!!this.api_key.value){
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);
document.getElementById("mailhops-membership-link").setAttribute('data-account-url','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;
@ -120,7 +120,7 @@ var mailHopPreferences = {
mailHopsUtils.launchExternalURL(this.getAttribute('data-account-url'));
});
document.getElementById("forecastio").addEventListener("click", function () {
mailHopsUtils.launchExternalURL('https://developer.forecast.io/');
mailHopsUtils.launchExternalURL('https://darksky.net');
});
this.saveAPIKey();
},
@ -142,7 +142,7 @@ var mailHopPreferences = {
//API vars
if(!this.valid_api_key)
this.api_key.value='';
pref.setCharPref("mail.mailHops.api_key", this.api_key.value);
pref.setCharPref("mail.mailHops.api_key", this.api_key.value.trim());
pref.setCharPref("mail.mailHops.api_http", this.api_http.value);
pref.setCharPref("mail.mailHops.api_host", this.api_host.value);
@ -173,6 +173,7 @@ var mailHopPreferences = {
document.getElementById("plan-error").style.display = 'block';
document.getElementById("plan-error").value=error;
document.getElementById("plan").value='';
document.getElementById("status").value='';
document.getElementById("rate-limit").value='';
document.getElementById("rate-remaining").value='';
document.getElementById("rate-reset").value='';
@ -189,8 +190,8 @@ var mailHopPreferences = {
var xmlhttp = new XMLHttpRequest();
var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
var apiBase = this.api_http.value+this.api_host.value,
accountURL = '/v2/accounts/?api_key='+this.api_key.value,
api_key = this.api_key.value,
accountURL = '/v2/accounts/?api_key='+this.api_key.value.trim(),
api_key = this.api_key.value.trim(),
self = this;
xmlhttp.open("GET", apiBase+accountURL,true);
@ -203,6 +204,7 @@ var mailHopPreferences = {
document.getElementById("plan-error").style.display = 'none';
// set plan info
document.getElementById("plan").value = "Plan: "+data.account.subscriptions.data[0].plan.id;
document.getElementById("status").value = "Status: "+data.account.subscriptions.data[0].status;
document.getElementById("rate-limit").value = "Limit: "+data.account.rate.limit;
document.getElementById("rate-remaining").value = "Remaining: "+data.account.rate.remaining;
if(data.account.rate.reset/60 < 60)

View File

@ -46,6 +46,11 @@
<label id="plan" class="plain" value=""></label>
</description>
</hbox>
<hbox align="center">
<description>
<label id="status" class="plain" value=""></label>
</description>
</hbox>
<hbox align="center">
<description>
<label id="rate-limit" class="plain" value=""></label>
@ -530,10 +535,10 @@
<spacer/>
<description>
MailHops API uses <label id="forecastio" class="text-link plain" value="Forecast.IO"/> to get the weather of the sender, register for an API Key to enable this feature.
MailHops API uses <label id="forecastio" class="text-link plain" value="DarkSky"/> to get the weather of the sender, register for an API Key to enable this feature.
</description>
<textbox id="mailhop.fkey" value="" placeholder="Enter ForecastIO API Key"/>
<textbox id="mailhop.fkey" value="" placeholder="Enter your DarkSky API Key"/>
<checkbox id="mailhop.debug" label="Debug" checked="false"/>
</groupbox>

View File

@ -305,7 +305,7 @@ var mailHopsDisplay =
message.time = message.time/1000;
if(message.time < 60)
distanceText += ' in '+message.time+' sec.';
else if(message.time<3600) //something is wrong if it takes this long
else if(message.time < 3600) //something is wrong if it takes this long
distanceText += ' in '+Math.round(message.time/60)+' min.';
else //something is wrong if it takes this long
distanceText += ' in '+Math.round(message.time/60/60)+' hr.';