-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Angeletti
committed
Nov 9, 2012
1 parent
0937d1c
commit 3fbf48d
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// @requires GPT library (e.g., //www.googletagservices.com/tag/js/gpt.js) | ||
|
||
// Set up a simple console noop for clients without a console | ||
window.console = window.console || {log: function(m){}, error: function(m){}}; | ||
|
||
|
||
// Set up the `Adgeletti` object and its methods | ||
window.Adgeletti = { | ||
// An object for storing data (populated upstream) | ||
data: {}, | ||
|
||
// Sets up an ad position by adding it to the `data` object herein | ||
position: function(breakpoint, ad_unit_id, sizes, div_id){ | ||
var positions = this.data[breakpoint] = this.data[breakpoint] || []; | ||
positions.push({ | ||
ad_unit_id: ad_unit_id, | ||
sizes: sizes, | ||
div_id: div_id | ||
}); | ||
}, | ||
|
||
// Displays all ads in the page for the given breakpoint | ||
display: function(breakpoint){ | ||
console.log('Displaying ads for breakpoint "' + breakpoint + '"'); | ||
var positions = this.data.breakpoint || []; | ||
|
||
if(positions.length == 0){ // Johnny 5 | ||
console.log('No ads for breakpoint "' + breakpoint + '"'); | ||
return; | ||
} | ||
|
||
for(var i = 0; i < positions.length; ++i){ | ||
var pos = positions[i]; | ||
// Show the div | ||
document.getElementById(pos.div_id).style.display = 'block'; | ||
// Tell Google to display the ad | ||
googletag.pubads().display(pos.ad_unit_id, pos.sizes, pos.div_id); | ||
} | ||
} | ||
} |