Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2012 09:49
Show Gist options
  • Save anonymous/4266465 to your computer and use it in GitHub Desktop.
Save anonymous/4266465 to your computer and use it in GitHub Desktop.
shareToSociality_cn: weibo, tqq, renren(新鲜事), qzone
function share(site, url, content, pics) {
var a = {
weibo: 'http://service.weibo.com/share/share.php?url={$url}&title={$content}&pic={$pic}&searchPic=false',
tqq: 'http://v.t.qq.com/share/share.php?url={$url}&title={$content}&pic={$pic}',
renren: 'http://share.renren.com/share/buttonshare/post/4001?url={$url}&title={$content}&pic={$pic}',
qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={$url}&title={$content}&pics={$pic}'
};
pics = pics ? pics : [];
var b = {
url: encodeURIComponent(url),
content: encodeURIComponent(content),
pic: function () {
return {
weibo: pics.join('||'),
tqq: pics.join("|"),
renren: pics[0] ? pics[0] : '', // 此rr接口只支持一张图片
qzone: pics.join("|")
};
} ()
};
var url = a[site].replace(/\{\$(\w+)\}/g, function (a, d) { return d === 'pic' ? b.pic[site] : b[d]; });
openwin(url, 700, 680);
}
function openwin(url, width, height) {
var w = width ? width : 740;
var h = height ? height : 600;
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var win = window.open(url,
'newwindow',
'height=' + h + ', width=' + w + ', top=' + top + ', left=' + left + ', toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no'); // scrollbars=no, location=yes
return win;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment