Skip to content

Instantly share code, notes, and snippets.

@joshfishman
Created April 28, 2012 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfishman/2514651 to your computer and use it in GitHub Desktop.
Save joshfishman/2514651 to your computer and use it in GitHub Desktop.
Pinterest Javascript taken from http://assets.pinterest.com/js/pinit.js
<script type="text/javascript">
(function(o,q,c){var s=function(h){var e=c.pinit,m="?",a,i,f,b;f=[];b=[];var j={},g=o.createElement("IFRAME"),r=h.getAttribute(c.att.count)||false,n=h.getAttribute(c.att.layout)||"horizontal";if(q.location.protocol==="https:")e=c.pinit_secure;f=h.href.split("?")[1].split("#")[0].split("&");a=0;for(i=f.length;a<i;a+=1){b=f[a].split("=");j[b[0]]=b[1]}a=f=0;for(i=c.vars.req.length;a<i;a+=1){b=c.vars.req[a];if(j[b]){e=e+m+b+"="+j[b];m="&"}f+=1}if(j.media&&j.media.indexOf("http")!==0)f=0;if(f===i){a=0;
for(i=c.vars.opt.length;a<i;a+=1){b=c.vars.opt[a];if(j[b])e=e+m+b+"="+j[b]}e=e+"&layout="+n;if(r!==false)e+="&count=1";g.setAttribute("src",e);g.setAttribute("scrolling","no");g.allowTransparency=true;g.frameBorder=0;g.style.border="none";g.style.width=c.layout[n].width+"px";g.style.height=c.layout[n].height+"px";h.parentNode.replaceChild(g,h)}else h.parentNode.removeChild(h)},p=o.getElementsByTagName("A"),l,d,k=[];d=0;for(l=p.length;d<l;d+=1)k.push(p[d]);d=0;for(l=k.length;d<l;d+=1)k[d].href&&k[d].href.indexOf(c.button)!==
-1&&s(k[d])})(document,window,{att:{layout:"count-layout",count:"always-show-count"},pinit:"http://pinit-cdn.pinterest.com/pinit.html",pinit_secure:"https://assets.pinterest.com/pinit.html",button:"//pinterest.com/pin/create/button/?",vars:{req:["url","media"],opt:["title","description"]},layout:{none:{width:43,height:20},vertical:{width:43,height:58},horizontal:{width:90,height:20}}});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment