Skip to content

Instantly share code, notes, and snippets.

@giannwilk
Forked from gregorynicholas/index.html
Created December 7, 2013 16:02
Show Gist options
  • Save giannwilk/7844358 to your computer and use it in GitHub Desktop.
Save giannwilk/7844358 to your computer and use it in GitHub Desktop.
http://pinterest.com/pin/create/button/?url=http://www.domain.com&description=&media=
ex:
http://pinterest.com/pin/create/button/?url=http://www.youworkforthem.com&media=http://www.youworkforthem.com/img/eps/E1174/E1174_00.jpg&description=Escapism 30 pulls further away from reality by manipulating organic materials into beautiful, hi-res bursting textures. This is art, this is space, this is nature, this is chaos. Use as you wish.
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded){ return; }
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
if (window.location.protocol == "https:") {
s.src = "https://assets.pinterest.com/js/pinit.js";
} else {
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
}
if (window.attachEvent) {
window.attachEvent("onload", async_load);
} else {
window.addEventListener("load", async_load, false);
}
})();
(function () {
var links = document.getElementsByTagName("a");
var pin_links = [];
for (var k=0, total=links.length; b<total; k++){
pin_links.push(links[k]);
}
for (var i=0; pin_links.length > 0; i++) {
var link = pin_links.pop();
if (!link.className || link.className.indexOf("pin-it-button") < 0) {
continue;
}
var link_href = link.getAttribute("href");
var params = {};
// parse querystring into an object
link_href = link_href.slice(link_href.indexOf("?") + 1).split("&");
for (var k=0, total=link_href.length; k<total; k++) {
var key_val = link_href[k].split("=");
params[key_val[0]] = key_val[1];
}
params.layout = link.getAttribute("count-layout");
params.count = link.getAttribute("always-show-count");
var qs = "?";
var url = window.location.protocol + "//d3io1k5o0zdpqr.cloudfront.net/pinit.html";
for (var f in params) {
if (params[f]) { // hasOwnProperty ?
url += qs + f + "=" + params[f];
qs = "&"
}
}
var frame_el = document.createDocumentFragment("iframe");
frame_el.setAttribute("scrolling", "no");
frame_el.allowTransparency = true;
frame_el.frameBorder = 0;
frame_el.style.border = "none";
if (params.layout == "none") {
frame_el.style.width = "43px";
frame_el.style.height = "20px"
} else if (params.layout == "vertical") {
frame_el.style.width = "43px";
frame_el.style.height = "58px"
} else {
frame_el.style.width = "90px";
frame_el.style.height = "20px"
}
link.parentNode.replaceChild(frame_el, link);
// track the iframe in google analytics
// http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#trackingIFrames
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
frame_el.setAttribute("src", url);
frame_el.src = pageTracker._getLinkerUrl(url);
});
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment