Added mobile code to topic list top position to test

This commit is contained in:
vi 2015-09-01 13:20:52 +10:00
parent 6452c9c5b1
commit 67141dd884
5 changed files with 46 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import PageTracker from 'discourse/lib/page-tracker';
var ad_width = ''; var ad_width = '';
var ad_height = ''; var ad_height = '';
var ad_code = ''; var ad_code = '';
var ad_mobile_code = '';
var currentUser = Discourse.User.current(); var currentUser = Discourse.User.current();
var publisher_id = Discourse.SiteSettings.adsense_publisher_code; var publisher_id = Discourse.SiteSettings.adsense_publisher_code;
var preGoogleVars = null; var preGoogleVars = null;
@ -66,13 +67,18 @@ var data = {
"post-bottom" : {} "post-bottom" : {}
} }
if (Discourse.SiteSettings.adsense_publisher_code) { if (Discourse.SiteSettings.adsense_publisher_code) {
// if ((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level)) { if (!Discourse.SiteSettings.adsense_show_topic_list_top && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
if (Discourse.SiteSettings.adsense_topic_list_top_code && !Discourse.SiteSettings.adsense_show_topic_list_top && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_list_top_code) {
data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code; data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code;
data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
data["topic-list-top"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); data["topic-list-top"]["ad_height"] = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
} }
if (Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_mobile_topic_list_top_code) {
data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code;
}
}
if (Discourse.SiteSettings.adsense_topic_above_post_stream_code && !Discourse.SiteSettings.adsense_show_topic_above_post_stream && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (Discourse.SiteSettings.adsense_topic_above_post_stream_code && !Discourse.SiteSettings.adsense_show_topic_above_post_stream && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) {
data["topic-above-post-stream"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_post_stream_code; data["topic-above-post-stream"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_post_stream_code;
data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes)); data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
@ -104,6 +110,7 @@ export default Ember.Component.extend({
this.set('ad_width', data[this.placement]["ad_width"] ); this.set('ad_width', data[this.placement]["ad_width"] );
this.set('ad_height', data[this.placement]["ad_height"] ); this.set('ad_height', data[this.placement]["ad_height"] );
this.set('ad_code', data[this.placement]["ad_code"] ); this.set('ad_code', data[this.placement]["ad_code"] );
this.set('ad_mobile_code', data[this.placement]["ad_mobile_code"] );
this._super(); this._super();
}, },

View File

@ -96,7 +96,7 @@ function loadGoogle(settings) {
const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)); const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes));
const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes));
if (Discourse.Mobile.mobileView) { if (Discourse.Mobile.mobileView) {
googletag.defineSlot(settings.dfp_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); googletag.defineSlot(settings.dfp_mobile_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
} }
else { else {
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top') googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top')

View File

@ -3,7 +3,7 @@
<ins class="adsbygoogle" <ins class="adsbygoogle"
style={{adInsStyleMobile}} style={{adInsStyleMobile}}
data-ad-client="ca-pub-{{publisher_id}}" data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_code}}> data-ad-slot={{ad_mobile_code}}>
</ins> </ins>
<script> <script>

View File

@ -4,21 +4,25 @@ en:
dfp_through_trust_level: "Show your ads to users based on trust." dfp_through_trust_level: "Show your ads to users based on trust."
dfp_show_topic_list_top: "Disable topic_list_top ad" dfp_show_topic_list_top: "Disable topic_list_top ad"
dfp_topic_list_top_code: "Show leaderboard ad above topic lists." dfp_topic_list_top_code: "Show leaderboard ad above topic lists."
dfp_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists."
topic_list_top_ad_sizes: "Choose your ad size" topic_list_top_ad_sizes: "Choose your ad size"
dfp_target_topic_list_top_key_code: "Input key values - Inventory Level" dfp_target_topic_list_top_key_code: "Input key values - Inventory Level"
dfp_target_topic_list_top_value_code: "Input key values - Inventory Level" dfp_target_topic_list_top_value_code: "Input key values - Inventory Level"
dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad" dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream" dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream"
dfp_mobile_topic_above_post_stream_code: "Mobile - Show leaderboard ad above post stream"
topic_above_post_stream_ad_sizes: "Choose your ad size" topic_above_post_stream_ad_sizes: "Choose your ad size"
dfp_target_topic_above_post_stream_key_code: "Input key values - Inventory Level" dfp_target_topic_above_post_stream_key_code: "Input key values - Inventory Level"
dfp_target_topic_above_post_stream_value_code: "Input key values - Inventory Level" dfp_target_topic_above_post_stream_value_code: "Input key values - Inventory Level"
dfp_show_topic_above_suggested: "Disable topic_above_suggested ad" dfp_show_topic_above_suggested: "Disable topic_above_suggested ad"
dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics" dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
dfp_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
topic_above_suggested_ad_sizes: "Choose your ad size" topic_above_suggested_ad_sizes: "Choose your ad size"
dfp_target_topic_above_suggested_key_code: "Input key values - Inventory Level" dfp_target_topic_above_suggested_key_code: "Input key values - Inventory Level"
dfp_target_topic_above_suggested_value_code: "Input key values - Inventory Level" dfp_target_topic_above_suggested_value_code: "Input key values - Inventory Level"
dfp_show_post_bottom: "Disable post_bottom ad" dfp_show_post_bottom: "Disable post_bottom ad"
dfp_post_bottom_code: "Show leaderboard ad post_bottom topics" dfp_post_bottom_code: "Show leaderboard ad post_bottom topics"
dfp_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
dfp_nth_post_code: "Choose the Nth position for your ad to show" dfp_nth_post_code: "Choose the Nth position for your ad to show"
post_bottom_ad_sizes: "Choose your ad size" post_bottom_ad_sizes: "Choose your ad size"
dfp_target_post_bottom_key_code: "Input key values - Inventory Level" dfp_target_post_bottom_key_code: "Input key values - Inventory Level"
@ -27,14 +31,18 @@ en:
adsense_through_trust_level: "Show your ads to users based on trust." adsense_through_trust_level: "Show your ads to users based on trust."
adsense_show_topic_list_top: "Disable topic_list_top ad" adsense_show_topic_list_top: "Disable topic_list_top ad"
adsense_topic_list_top_code: "Show leaderboard ad above topic lists." adsense_topic_list_top_code: "Show leaderboard ad above topic lists."
adsense_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists."
adsense_topic_list_top_ad_sizes: "Choose your ad sizes" adsense_topic_list_top_ad_sizes: "Choose your ad sizes"
adsense_show_topic_above_post_stream: "Disable topic_above_post_stream ad" adsense_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
adsense_topic_above_post_stream_code: "Show leaderboard ad above post stream" adsense_topic_above_post_stream_code: "Show leaderboard ad above post stream"
adsense_mobile_topic_above_post_stream_code: "Mobile - Show leaderboard ad above post stream"
adsense_topic_above_post_stream_ad_sizes: "Choose your ad sizes" adsense_topic_above_post_stream_ad_sizes: "Choose your ad sizes"
adsense_show_topic_above_suggested: "Disable topic_above_suggested ad" adsense_show_topic_above_suggested: "Disable topic_above_suggested ad"
adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics" adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
adsense_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes" adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
adsense_post_bottom_code: "Show leaderboard ad post_bottom topics" adsense_post_bottom_code: "Show leaderboard ad post_bottom topics"
adsense_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
adsense_show_post_bottom: "Disable post_bottom ad" adsense_show_post_bottom: "Disable post_bottom ad"
adsense_post_bottom_ad_sizes: "Choose your ad sizes" adsense_post_bottom_ad_sizes: "Choose your ad sizes"
adsense_nth_post_code: "Choose the Nth position for your ad to show" adsense_nth_post_code: "Choose the Nth position for your ad to show"

View File

@ -9,6 +9,9 @@ adsense_plugin:
adsense_topic_list_top_code: adsense_topic_list_top_code:
client: true client: true
default: '' default: ''
adsense_mobile_topic_list_top_code:
client: true
default: ''
adsense_show_topic_list_top: adsense_show_topic_list_top:
client: true client: true
default: false default: false
@ -30,6 +33,9 @@ adsense_plugin:
adsense_topic_above_post_stream_code: adsense_topic_above_post_stream_code:
client: true client: true
default: '' default: ''
adsense_mobile_topic_above_post_stream_code:
client: true
default: ''
adsense_show_topic_above_post_stream: adsense_show_topic_above_post_stream:
client: true client: true
default: false default: false
@ -51,6 +57,9 @@ adsense_plugin:
adsense_topic_above_suggested_code: adsense_topic_above_suggested_code:
client: true client: true
default: '' default: ''
adsense_mobile_topic_above_suggested_code:
client: true
default: ''
adsense_show_topic_above_suggested: adsense_show_topic_above_suggested:
client: true client: true
default: false default: false
@ -72,6 +81,9 @@ adsense_plugin:
adsense_post_bottom_code: adsense_post_bottom_code:
client: true client: true
default: '' default: ''
adsense_mobile_post_bottom_code:
client: true
default: ''
adsense_show_post_bottom: adsense_show_post_bottom:
client: true client: true
default: false default: false
@ -105,6 +117,9 @@ ad_plugin:
dfp_topic_list_top_code: dfp_topic_list_top_code:
client: true client: true
default: '' default: ''
dfp_mobile_topic_list_top_code:
client: true
default: ''
topic_list_top_ad_sizes: topic_list_top_ad_sizes:
client: true client: true
default: '728*90 - leaderboard' default: '728*90 - leaderboard'
@ -134,6 +149,9 @@ ad_plugin:
dfp_topic_above_post_stream_code: dfp_topic_above_post_stream_code:
client: true client: true
default: '' default: ''
dfp_mobile_topic_above_post_stream_code:
client: true
default: ''
topic_above_post_stream_ad_sizes: topic_above_post_stream_ad_sizes:
client: true client: true
default: '728*90 - leaderboard' default: '728*90 - leaderboard'
@ -163,6 +181,9 @@ ad_plugin:
dfp_topic_above_suggested_code: dfp_topic_above_suggested_code:
client: true client: true
default: '' default: ''
dfp_mobile_topic_above_suggested_code:
client: true
default: ''
topic_above_suggested_ad_sizes: topic_above_suggested_ad_sizes:
client: true client: true
default: '728*90 - leaderboard' default: '728*90 - leaderboard'
@ -192,6 +213,9 @@ ad_plugin:
dfp_post_bottom_code: dfp_post_bottom_code:
client: true client: true
default: '' default: ''
dfp_mobile_post_bottom_code:
client: true
default: ''
dfp_nth_post_code: dfp_nth_post_code:
client: true client: true
default: '' default: ''