2019-04-18 17:52:59 -04:00
|
|
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
2020-03-23 04:40:29 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-04-06 21:14:27 -04:00
|
|
|
|
2019-06-14 12:10:11 -04:00
|
|
|
const serve_id = Discourse.SiteSettings.carbonads_serve_id,
|
2019-04-06 21:14:27 -04:00
|
|
|
placement = Discourse.SiteSettings.carbonads_placement;
|
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
export default AdComponent.extend({
|
|
|
|
init() {
|
2019-04-06 21:14:27 -04:00
|
|
|
this.set("serve_id", serve_id);
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2020-03-23 04:40:29 -04:00
|
|
|
@discourseComputed("serve_id")
|
2019-06-14 12:10:11 -04:00
|
|
|
url(serveId) {
|
2019-04-18 14:10:56 -04:00
|
|
|
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
|
|
|
|
2020-03-23 04:40:29 -04:00
|
|
|
@discourseComputed("currentUser.trust_level")
|
2019-04-18 14:10:56 -04:00
|
|
|
showToTrustLevel(trustLevel) {
|
2019-04-06 21:14:27 -04:00
|
|
|
return !(
|
2019-04-18 14:10:56 -04:00
|
|
|
trustLevel &&
|
|
|
|
trustLevel > Discourse.SiteSettings.carbonads_through_trust_level
|
2019-04-06 21:14:27 -04:00
|
|
|
);
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
2019-04-06 21:14:27 -04:00
|
|
|
|
2020-03-23 04:40:29 -04:00
|
|
|
@discourseComputed("showToTrustLevel", "showToGroups", "showOnCurrentPage")
|
2019-06-05 15:52:52 -04:00
|
|
|
showAd(showToTrustLevel, showToGroups, showOnCurrentPage) {
|
|
|
|
return (
|
|
|
|
placement &&
|
|
|
|
serve_id &&
|
|
|
|
showToTrustLevel &&
|
|
|
|
showToGroups &&
|
|
|
|
showOnCurrentPage
|
|
|
|
);
|
2020-09-04 07:24:14 -04:00
|
|
|
},
|
2019-04-06 21:14:27 -04:00
|
|
|
});
|