fixed up with Jo's help setTargeting base method

This commit is contained in:
Sarah Ni 2015-08-31 13:49:09 +10:00
parent 6d8cbb72e4
commit 8989d9c5ea

View File

@ -39,19 +39,20 @@ function keyParse(word) {
} }
// This sets the key and value for custom targeting // This sets the key and value for custom targeting
var Foo = function(key, value) { var Foo = function(key, value, googletag) {
this.locationKey = key; this.locationKey = key;
this.locationValue = value; this.locationValue = value;
this.googletag = googletag;
} }
// setTargeting is not defined. We want to return as a method - PROBLEM 1 // setTargeting is not defined. We want to return as a method - PROBLEM 1
Foo.prototype.bar = function() { Foo.prototype.bar = function() {
return setTargeting((this.locationKey), (this.locationValue)); return googletag.setTargeting((this.locationKey), (this.locationValue));
} }
// This should call googletag.setTargeting(key for that location, value for that location) // This should call googletag.setTargeting(key for that location, value for that location)
var googletag = new Foo(keyParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_key_code), valueParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_value_code)); var f = new Foo(keyParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_key_code), valueParse(Discourse.SiteSettings.dfp_target_topic_above_post_stream_value_code), googletag);
googletag.bar(); f.bar();
// END of Coaches Note // END of Coaches Note