mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Updated affiliate links to work better in Canada
This commit is contained in:
parent
9eab5335f9
commit
f7c2a19194
@ -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
|
||||
*
|
||||
|
37
js/beestat/affiliate.js
Normal file
37
js/beestat/affiliate.js
Normal file
@ -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;
|
||||
};
|
@ -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);
|
||||
};
|
||||
|
@ -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'));
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -43,6 +43,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
|
||||
echo '<script src="/js/beestat/crypto.js"></script>' . PHP_EOL;
|
||||
echo '<script src="/js/beestat/floor_plan.js"></script>' . PHP_EOL;
|
||||
echo '<script src="/js/beestat/address.js"></script>' . PHP_EOL;
|
||||
echo '<script src="/js/beestat/affiliate.js"></script>' . PHP_EOL;
|
||||
|
||||
// Layer
|
||||
echo '<script src="/js/layer.js"></script>' . PHP_EOL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user