2022-06-01 12:37:01 -04:00
|
|
|
import { htmlSafe } from "@ember/template";
|
2023-11-07 12:07:33 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
2019-04-06 21:14:27 -04:00
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
export default AdComponent.extend({
|
2021-09-21 14:27:10 -04:00
|
|
|
serve_id: null,
|
|
|
|
placement: null,
|
|
|
|
|
2019-04-18 14:10:56 -04:00
|
|
|
init() {
|
2021-09-21 14:27:10 -04:00
|
|
|
this.set("serve_id", this.siteSettings.carbonads_serve_id);
|
|
|
|
this.set("placement", this.siteSettings.carbonads_placement);
|
2019-04-06 21:14:27 -04:00
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2021-09-21 14:27:10 -04:00
|
|
|
@discourseComputed("serve_id", "placement")
|
|
|
|
url(serveId, placement) {
|
2022-06-01 12:37:01 -04:00
|
|
|
return htmlSafe(
|
|
|
|
`//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`
|
|
|
|
);
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
|
|
|
|
2024-01-31 13:04:24 -05:00
|
|
|
@discourseComputed
|
|
|
|
showToDisplayGroups() {
|
|
|
|
if (!this.currentUser) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.currentUser.show_carbon_ads;
|
2019-04-12 08:10:55 -04:00
|
|
|
},
|
2019-04-06 21:14:27 -04:00
|
|
|
|
2021-09-21 14:27:10 -04:00
|
|
|
@discourseComputed(
|
|
|
|
"placement",
|
|
|
|
"serve_id",
|
2024-01-31 13:04:24 -05:00
|
|
|
"showToDisplayGroups",
|
2021-09-21 14:27:10 -04:00
|
|
|
"showToGroups",
|
|
|
|
"showOnCurrentPage"
|
|
|
|
)
|
|
|
|
showAd(
|
|
|
|
placement,
|
|
|
|
serveId,
|
2024-01-31 13:04:24 -05:00
|
|
|
showToDisplayGroups,
|
2021-09-21 14:27:10 -04:00
|
|
|
showToGroups,
|
|
|
|
showOnCurrentPage
|
|
|
|
) {
|
2019-06-05 15:52:52 -04:00
|
|
|
return (
|
|
|
|
placement &&
|
2021-09-21 14:27:10 -04:00
|
|
|
serveId &&
|
2024-01-31 13:04:24 -05:00
|
|
|
showToDisplayGroups &&
|
2019-06-05 15:52:52 -04:00
|
|
|
showToGroups &&
|
|
|
|
showOnCurrentPage
|
|
|
|
);
|
2020-09-04 07:24:14 -04:00
|
|
|
},
|
2019-04-06 21:14:27 -04:00
|
|
|
});
|