Skip to content

Instantly share code, notes, and snippets.

@bkardell
Created January 13, 2012 16:27
Show Gist options
  • Save bkardell/1607332 to your computer and use it in GitHub Desktop.
Save bkardell/1607332 to your computer and use it in GitHub Desktop.
plusone hitch
/**
{
"title": "Google +1 Hitch",
"type": "html",
"description": "Provides google +1 button as an HTML hitch",
"package": "bkardell.google.plusone",
"version": "1"
}
======
Some docs go here... This is a test.
**/
window.___jsl=window.___jsl||{};
window.___jsl.h=window.___jsl.h||'m;\/_\/apps-static\/_\/js\/widget\/__features__\/rt=j\/ver=BIL9VgfGink.en.\/sv=1\/am=!bMxf2l2AOqKIHfWTkg\/d=1\/';
window.___jsl.l=[];
window.___gpq=[];
window.gapi=window.gapi||{};
window.gapi.plusone=window.gapi.plusone||(function(){
function f(n){return function(){window.___gpq.push(n,arguments)}}
return{go:f('go'),render:f('render')}})();
function __bsld(){var p=window.gapi.plusone=window.googleapisv0.plusone;var f;while(f=window.___gpq.shift()){
p[f]&&p[f].apply(p,window.___gpq.shift())}
p=window.gapi.plus=window.googleapisv0.plus;while(f=window.___gbq.shift()){
p[f]&&p[f].apply(p,window.___gbq.shift())}
var parseTags = gapi.config.get('parsetags') || gapi.config.get('gwidget/parsetags');if (parseTags!=='explicit'){gapi.plusone.go();}}
window.___gbq=[];
window.gapi.plus=window.gapi.plus||(function(){
function f(n){return function(){window.___gbq.push(n,arguments)}}
return{go:f('go'),render:f('render')}})();
window.__GOOGLEAPIS=window.__GOOGLEAPIS||{};
window.__GOOGLEAPIS.iframes=window.__GOOGLEAPIS.iframes||{};
window.__GOOGLEAPIS.iframes.plus=window.__GOOGLEAPIS.iframes.plus||{url:':socialhost:/u/:session_index:/_/pages/badge'};window['___jsl'] = window['___jsl'] || {};window['___jsl']['uc'] = 'https:\/\/apis.google.com\/js\/plusone.js';window['___jsl']['u'] = 'https:\/\/apis.google.com\/js\/plusone.js';window['___jsl']['f'] = ['googleapis.client','plusone','gcm_ppb'];window['___jsl']['ms'] = 'https://plus.google.com';(window['___jsl']['ci'] = (window['___jsl']['ci'] || [])).push({"gwidget":{"parsetags":"onload"},"iframes":{"additnow":{"url":"https://apis.google.com/additnow/additnow.html"},"sharebox":{"params":{"json":"&"},"url":":socialhost:/:session_prefix:_/sharebox/dialog"},"plus":{"url":":socialhost:/:session_prefix:_/pages/badge"},":socialhost:":"https://plusone.google.com","plusone_m":{"url":":socialhost:/:session_prefix:_/+1/fastbutton","params":{"count":"","size":"","url":""}},"card":{"params":{"s":"#","userid":"&"},"url":":socialhost:/u/:session_index:/_/hovercard/card"},"plusone":{"url":":socialhost:/:session_prefix:_/+1/fastbutton","params":{"count":"","size":"","url":""}}},"googleapis.config":{"requestCache":{"enabled":true},"methods":{"chili.people.list":true,"pos.plusones.list":true,"pos.plusones.get":true,"chili.people.get":true,"pos.plusones.insert":true,"chili.activities.list":true,"pos.plusones.delete":true,"chili.activities.get":true,"chili.activities.search":true,"pos.plusones.getSignupState":true},"versions":{"chili":"v1","pos":"v1"},"rpc":"/rpc","transport":{"isProxyShared":true},"sessionCache":{"enabled":true},"root-1p":"https://clients6.google.com","root":"https://www.googleapis.com","xd3":"/static/proxy.html","developerKey":"AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ","auth":{"useInterimAuth":false}}});var gapi=window.gapi||{};gapi.client=window.gapi&&window.gapi.client||{};
window.gapi=window.gapi||{};
(function(){var A=void 0,B=void 0,C="___jsl",U="h",D="l",V="m",E="ms",W="ci",X="cu",Y="c",Z="cm",$="o",n="p",o="q",F="lc",G="Q",s="I",t="il",u="_",v="https://ssl.gstatic.com",aa="/webclient/js",ba="/webclient/jsx/",H="https://apis.google.com",I=".js",ca="gcjs-3p",da=/^(https?:)?\/\/([^/:@]*)(:[0-9]+)?(\/[\w.,:!=/-]*)(\?[^#]*)?(#.*)?$/,J=/^[?#]([^&]*&)*jsh=([^&]*)/,K="d",p="r",ea="f",q="m",L="n",fa="sync",ga="callback",ha="config",ia="_ci",w="nodep",M="gapi.load: ",N=function(a,b){A&&A(a,b);throw M+
a+(b&&" "+b);},O=function(a){B&&B(a);var b=window.console;b&&b.warn(M+a)},ja=function(a,b,c){a=a[U];if(b=b&&J.exec(b)||c&&J.exec(c))try{a=decodeURIComponent(b[2])}catch(e){O("Invalid hint "+b[2])}return a},P=function(a){a.sort();for(var b=0;b<a.length;)!a[b]||b&&a[b]==a[b-1]?a.splice(b,1):++b},Q=function(a,b){for(var c=!0,e=0,f=0,d,g;c&&(d=a[e])&&(g=b[f]);)d==g?++e:d<g&&(c=!1),++f;return c&&!d},ka=function(a){if("loading"!=document.readyState)return!1;if("undefined"!=typeof window.___gapisync)return window.___gapisync;
if(a&&(a=a[fa],"undefined"!=typeof a))return a;for(var a=document.getElementsByTagName("meta"),b=0,c;c=a[b];++b)if("generator"==c.getAttribute("name")&&"blogger"==c.getAttribute("content"))return!0;return!1},R=function(a,b){if(ka(a))document.write('<script src="'+encodeURI(b)+'"><\/script>');else{var c=b,e=document.createElement("script");e.setAttribute("src",c);e.async=!0;c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(e,c)}},S=function(a,b,c,e,f,d){var g=c.shift(),h;h=g==
p?v:g==q?e[E]||H:(h=c.shift())&&h.replace(/\/+$/,"");var j;g==p?(j=c.shift(),j=(j.indexOf(ba)?aa+"/":"")+j):j=c.shift();var i=g==K,k=i&&c.shift()||ca,c=i&&c.shift();if(g==K)d=b,b=j,f=k,a="/"+a.join(":")+(d.length?"!"+d.join(":"):"")+I+"?container="+f+"&c=2&jsload=0",b&&(a+="&r="+b),"d"==c&&(a+="&debug=1");else if(g==p||g==ea)d=b,b=j,a=(b.indexOf("/")?"/":"")+b+"/"+a.join("__")+(d.length?"--"+d.join("__"):"")+I;else if(g==q||g==L)b=j,a=a.join(",").replace(/\./g,"_").replace(/-/g,"_"),a=b.replace("__features__",
a),a=f[w]?a.replace("/d=1/","/d=0/"):a,d&&(a.match(/\/$/)||(a+="/"),a+="cb=gapi."+encodeURIComponent(d));else return O("Unknown hint type "+g),"";if(!h)return"";h+=a;a=h;d=e;if(b=e=da.exec(a))if(b=!/\.\.|\/\//.test(e[4]))b:if(b=a,e=e[2],g==p)b=b.substr(0,v.length)==v;else if(g==q)e=d[E]||H,b=b.substr(0,e.length)==e;else{g=d[V];if(e&&g){g=g.split(",");d=0;for(b=g.length;d<b;++d)if(f=g[d],c=e.lastIndexOf(f),(0==c||"."==f.charAt(0)||"."==e.charAt(c-1))&&e.length-f.length==c){b=!0;break b}}b=!1}b||N("Invalid URI",
a);return h},x=function(a,b,c){c&&(a[b]=a[b]||[]).push(c)},y=function(a){a[o]&&0<a[o].length&&(window.gapi.load||T).apply(null,a[o].shift())},r=function(a){if(a)try{a()}catch(b){return b}return null},m=window.gapi,la=function(){if(m[u])return m[u];var a;if((a=Object.create)&&/\[native code\]/.test(a))a=a(null);else{a={};for(var b in a)a[b]=void 0}return m[u]=a},ma=function(a,b,c,e,f){var d=f[G]=f[G]||[],g=f[F]=f[F]||{};d.push([a,b,e]);m[c]=function(b){m[c]=void 0;if(!g[a]){g[a]=b;for(var b=d,e=g,
i=f,k;b[0]&&e[b[0][0]];){var l=b.shift();z(l[2],i);e[l[0]].call(window,la());e[l[0]]=!0;(l=r(l[1]))&&!k&&(k=l)}i[n]=void 0;y(i);if(k)throw k;}}},z=function(a,b){var c=a[ia];x(b,W,c);c=a[ha];m.config?m.config.update(c):x(b,X,c)},na=function(a){a[s]||(a[s]=0);return"loaded"+a[s]++},T=function(a,b){var c,e={};"function"!==typeof b?(e=b||{},c=e[ga]):c=b;var f=window[C]=window[C]||{},d=ja(f,window.location.search,window.location.hash),g=d&&!!d.match(/\/gapi\/|ms=gapi/);if(f[n])x(f,o,[a,b]);else{d||N("No hint present",
"");var h=d.split(";"),j=h[0]==q||h[0]==L,d=[],i=[];f[t]&&"function"===typeof f[t]?(d=f[t](a),e[w]=1):(d=a.split(":"),e[w]||P(d),i=f[D]=f[D]||[],P(i));if(g){if(!Q(d,i)&&(g=na(f),h=S(d,i,h,f,e,g))){f[n]=d;ma(h,c,g,e,f);i.push.apply(i,d);R(e,h);return}z(e,f);if(c)var k=r(c)}else{z(e,f);if(!Q(d,i)){var l=j?Z:Y;if(h=S(d,i,h,f,e,null)){f[n]=d;f[$]=1;f[l]=function(){f[n]=void 0;f[l]=void 0;var a=r(c);y(f);if(a)throw a;};i.push.apply(i,d);R(e,h);return}}k=r(c)}y(f);if(k)throw k;}};gapi.loader={load:T}})();
gapi.load=gapi.loader.load;
(window.gapi=window.gapi||{}).load=window.___jsl&&window.___jsl.il&&window.gapi.load||gapi.load;
gapi.load('googleapis.client:plusone:gcm_ppb', {'callback': window['__bsld'] });
Hitch.add([{
name: 'data-g-plusone',
base: '[data-g-plusone]',
type: 'html',
init: function(m){
for(var i=0;i<m.length;i++){
m[i].className += 'g-plusone';
m[i].setAttribute('data-annotation',"inline");
};
gapi.plusone.go();
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment