Skip to content

Commit

Permalink
Added adgeletti dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Angeletti committed Nov 9, 2012
1 parent 0937d1c commit 3fbf48d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions adgeletti/static/adgeletti/adgeletti.js
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);
}
}
}

0 comments on commit 3fbf48d

Please sign in to comment.