Created
December 9, 2009 10:12
-
-
Save mattmccray/252391 to your computer and use it in GitHub Desktop.
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
// ads.js v0.1 by M@ McCray, find the source at http://gist.github.com/252391 | |
var Ads=(function(B){function A(D){var C=B.location.search.substring(1);var G=C.split("&");for(var E=0;E<G.length;E++){var F=G[E].split("=");if(F[0]==D){return F[1]}}return""}return{Google:function(D,F,E,C){B.google_ad_client=D;B.google_ad_slot=F;B.google_ad_width=E;B.google_ad_height=C;document.write('<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>')},ProjectWonderful:function(J,G,D,F){var I=document,H=new String(Math.random()*9999).substr(0,5),E='<script src="http://www.projectwonderful.com/gen.php?',C=A("pw_highlight_code");E+="id="+J+"&";E+="type="+G+"&";E+="r="+H+"&";if(I.referrer){E+="referer="+escape(I.referrer)+"&"}if(I.location){E+="location="+escape(I.location);+"&"}if(D){E+="fg="+D+"&"}if(F){E+="bg="+escape(F)+"&"}if(C!=""){E+="hl="+escape(C.match(/[0-9]+/g))}E+='"><\/script>';I.write(E)}}})(this); |
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
/* | |
ads.js v0.1 | |
by M@ McCray | |
(http://www.zoodotcom.com) | |
Supplies functions for cleaning up your page and reducing the number of JS requests and document.write calls when using Project Wonderful. | |
Usage: | |
Ads.ProjectWonderful( id, type[, fgcolor, bgcolor] ); | |
// Or | |
Ads.Google( client, slot, width, height ); | |
Note: This should be used to replace the 'config' settings script block. Also, the following ad display script tag should be removed. | |
Google Adsense example, before: | |
<script type="text/javascript"><!-- | |
google_ad_client = "pub-#####"; | |
/ * ZdC Header - 728x90, created 12/9/09 * / | |
google_ad_slot = "####"; | |
google_ad_width = 728; | |
google_ad_height = 90; | |
//--> | |
</script> | |
<script type="text/javascript" | |
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | |
</script> | |
After: | |
<script type="text/javascript"><!-- | |
/ * ZdC Header - 728x90, created 12/9/09 * / | |
Ads.Google("pub-####", "####", 728, 90); | |
//--> | |
</script> | |
*/ | |
var Ads = (function(w){ | |
// Helper Functions | |
function querystring(v){ | |
var qs = w.location.search.substring(1); | |
var vars=qs.split("&"); | |
for(var i=0;i<vars.length;i++){ | |
var kv = vars[i].split("="); | |
if(kv[0] == v){ | |
return kv[1]; | |
}; | |
}; | |
return ''; | |
}; | |
// Public API | |
return { | |
Google: function(client, slot, width, height) { | |
w.google_ad_client = client; | |
w.google_ad_slot = slot; | |
w.google_ad_width = width; | |
w.google_ad_height = height; | |
document.write('<scr'+'ipt src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr'+'ipt>'); | |
}, | |
ProjectWonderful: function(id, type, fcolor, bcolor) { | |
var d = document, | |
r = new String(Math.random()*9999).substr(0,5), | |
s = '<scr'+'ipt src="http://www.projectwonderful.com/gen.php?', | |
hl = querystring('pw_highlight_code'); | |
s += 'id='+ id +'&'; | |
s += 'type='+ type +'&'; | |
s += 'r='+ r +'&'; | |
if(d.referrer){ | |
s += 'referer='+ escape(d.referrer) +'&'; | |
}; | |
if(d.location){ | |
s += 'location='+ escape(d.location); +'&'; | |
}; | |
if(fcolor){ | |
s += 'fg='+ fcolor +'&'; | |
}; | |
if(bcolor){ | |
s += 'bg='+ escape(bcolor) +'&'; | |
}; | |
if(hl!=''){ | |
s +="hl="+ escape(hl.match(/[0-9]+/g)); | |
}; | |
s += '"></sc'+'ript>'; | |
d.write(s); | |
} | |
}; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment