diff --git a/js/beestat/address.js b/js/beestat/address.js
index b2387d7..dc1e6da 100644
--- a/js/beestat/address.js
+++ b/js/beestat/address.js
@@ -33,7 +33,8 @@ beestat.address.get_lines = function(address_id) {
};
/**
- * Get whether or not this address was validated and thus has address components/metadata, is geocoded, etc.
+ * Get whether or not this address was validated and thus has address
+ * components/metadata, is geocoded, etc.
*
* @param {number} address_id
*
diff --git a/js/beestat/affiliate.js b/js/beestat/affiliate.js
new file mode 100644
index 0000000..60dd16a
--- /dev/null
+++ b/js/beestat/affiliate.js
@@ -0,0 +1,37 @@
+beestat.affiliate = {};
+
+beestat.affiliate.links = {
+ 'bosch_glm20': {
+ 'USA': 'https://amzn.to/3P3z2Ea',
+ 'CAN': 'https://amzn.to/3RieCZx'
+ },
+ 'ecobee_smart_thermostat_premium': {
+ 'USA': 'https://amzn.to/3A7vv3S',
+ 'CAN': 'https://amzn.to/3R0spV0'
+ },
+ 'ecobee_smart_sensor_2_pack': {
+ 'USA': 'https://amzn.to/3SprUVB',
+ 'CAN': 'https://amzn.to/3pSh8tR'
+ }
+};
+
+/**
+ * Link getter for affiliate links in the currently active thermostat's
+ * country. Defaults to USA.
+ *
+ * @param {string} type
+ *
+ * @return {string}
+ */
+beestat.affiliate.get_link = function(type) {
+ const thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')];
+ let country_iso_3 = 'USA';
+ if (thermostat.address_id !== null) {
+ const address = beestat.cache.address[thermostat.address_id];
+ if (beestat.address.is_valid(address.address_id) === true) {
+ country_iso_3 = address.normalized.components.country_iso_3;
+ }
+ }
+ return beestat.affiliate.links[type][country_iso_3] ||
+ beestat.affiliate.links[type].USA;
+};
diff --git a/js/component/card/air_quality_not_supported.js b/js/component/card/air_quality_not_supported.js
index b12b4d8..32d96d0 100644
--- a/js/component/card/air_quality_not_supported.js
+++ b/js/component/card/air_quality_not_supported.js
@@ -17,11 +17,15 @@ beestat.component.card.air_quality_not_supported.prototype.decorate_contents_ =
new beestat.component.tile()
.set_icon('open_in_new')
- .set_text('Buy an ecobee Smart Thermostat Premium on Amazon')
+ .set_text([
+ 'Ecobee Smart Thermostat Premium',
+ 'Amazon Affiliate'
+ ])
+ .set_size('large')
.set_background_color(beestat.style.color.green.dark)
.set_background_hover_color(beestat.style.color.green.light)
.addEventListener('click', function() {
- window.open('https://amzn.to/3A7vv3S');
+ window.open(beestat.affiliate.get_link('ecobee_smart_thermostat_premium'));
})
.render(parent);
};
diff --git a/js/component/card/visualize_affiliate.js b/js/component/card/visualize_affiliate.js
index 19f3f56..38834c4 100644
--- a/js/component/card/visualize_affiliate.js
+++ b/js/component/card/visualize_affiliate.js
@@ -28,7 +28,7 @@ beestat.component.card.visualize_affiliate.prototype.decorate_contents_ = functi
.set_background_color(beestat.style.color.green.dark)
.set_background_hover_color(beestat.style.color.green.light)
.addEventListener('click', function() {
- window.open('https://amzn.to/3SprUVB');
+ window.open(beestat.affiliate.get_link('ecobee_smart_sensor_2_pack'));
})
);
diff --git a/js/js.php b/js/js.php
index 06b406e..2d6e238 100755
--- a/js/js.php
+++ b/js/js.php
@@ -43,6 +43,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
echo '' . PHP_EOL;
echo '' . PHP_EOL;
echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
// Layer
echo '' . PHP_EOL;