49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
export default AdComponent.extend({
|
|
serve_id: null,
|
|
placement: null,
|
|
|
|
init() {
|
|
this.set("serve_id", this.siteSettings.carbonads_serve_id);
|
|
this.set("placement", this.siteSettings.carbonads_placement);
|
|
this._super();
|
|
},
|
|
|
|
@discourseComputed("serve_id", "placement")
|
|
url(serveId, placement) {
|
|
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
|
|
},
|
|
|
|
@discourseComputed("currentUser.trust_level")
|
|
showToTrustLevel(trustLevel) {
|
|
return !(
|
|
trustLevel && trustLevel > this.siteSettings.carbonads_through_trust_level
|
|
);
|
|
},
|
|
|
|
@discourseComputed(
|
|
"placement",
|
|
"serve_id",
|
|
"showToTrustLevel",
|
|
"showToGroups",
|
|
"showOnCurrentPage"
|
|
)
|
|
showAd(
|
|
placement,
|
|
serveId,
|
|
showToTrustLevel,
|
|
showToGroups,
|
|
showOnCurrentPage
|
|
) {
|
|
return (
|
|
placement &&
|
|
serveId &&
|
|
showToTrustLevel &&
|
|
showToGroups &&
|
|
showOnCurrentPage
|
|
);
|
|
},
|
|
});
|