Files

52 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

import { htmlSafe } from "@ember/template";
2023-11-07 17:07:33 +00:00
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
2019-04-07 03:14:27 +02:00
2019-04-18 14:10:56 -04:00
export default AdComponent.extend({
serve_id: null,
placement: null,
2019-04-18 14:10:56 -04:00
init() {
this.set("serve_id", this.siteSettings.carbonads_serve_id);
this.set("placement", this.siteSettings.carbonads_placement);
2019-04-07 03:14:27 +02:00
this._super();
},
@discourseComputed("serve_id", "placement")
url(serveId, placement) {
return htmlSafe(
`//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`
);
2019-04-12 14:10:55 +02:00
},
2019-04-07 03:14:27 +02:00
@discourseComputed("currentUser.trust_level")
2019-04-18 14:10:56 -04:00
showToTrustLevel(trustLevel) {
2019-04-07 03:14:27 +02:00
return !(
trustLevel && trustLevel > this.siteSettings.carbonads_through_trust_level
2019-04-07 03:14:27 +02:00
);
2019-04-12 14:10:55 +02:00
},
2019-04-07 03:14:27 +02:00
@discourseComputed(
"placement",
"serve_id",
"showToTrustLevel",
"showToGroups",
"showOnCurrentPage"
)
showAd(
placement,
serveId,
showToTrustLevel,
showToGroups,
showOnCurrentPage
) {
return (
placement &&
serveId &&
showToTrustLevel &&
showToGroups &&
showOnCurrentPage
);
2020-09-04 13:24:14 +02:00
},
2019-04-07 03:14:27 +02:00
});