有时候自己想说能够写任何能够实现的效果,但自己写代码最终的结果是费时费力;好处也是易见的,能够自己控制代码,清楚代码格式;
今天一是由于时间太急,二是别人已经找到了一个效果,需要在此基础上做一些调整,然后再加个新的工具栏,于是就想在其基础上修改,颇费了一番功夫,最终的结果也是差强人意……
js代码的压缩我有一定的了解,但像这种压缩方式目前为止只是见过,具体怎么样实现的还真不是太知道;不知道怎么实现压缩的不要紧,关键是能不能恢复成一个可以理解的方式,这个时候chrome的控制台就发挥了其作用;
注意看下面这句,eval要的是一个字符器,那么其function返回的p也就是相应的字符器,如果把第一个function返回的字符串提取出来则就是我们想要的东西,将eval后面的所有代码拷贝到chrome的控制台执行,得到我们认可的压缩代码;
然后去http://www.css88.com/tool/js_beautify/ 把压缩的代码格式化一下就可以得到如下代码,下面的代码就可以看的懂了,虽然变量还是abcd这些字母来代替,并且可以手动修改了。
他的代码可以学习的地方有如下几个:
- 代码压缩
他们的代码压缩方式是我经常见到但又不知道怎么去弄的方式,把关键字都提取到数组中去了,这样的解码难度确实高了不少 - 良好的代码风格
里面的所有私有成员都以“_”开头,一目了然 - 代码配置化
有自己的数据配置方式,在不改动代码的方式下实现灵活改变
但也有很大的问题在里面,这也是造成我后面扩展困难,不得不重新复制出另一套代码:
- 全局执行方式
现在成熟的写法很少进行全局执行,而它的所有js文件都是全局执行 - 没有对多侧边栏进行考虑
也许他们本就不需要考虑多个边栏,所以就没有做这方面的考虑 - 多js加载,虽然实现了一个js里面加载多个其他js,但也造成了速度慢的等问题;
- 可定制化差;无论从排序还是图标,都没有让人可定制化的地方
if (!window._jiathis_r) {
var JIATHIS_CONFIGS = {
webhost: "http://www.jiathis.com",
lhost: "http://l.jiathis.com",
codehost: "",
sc: true,
uid: 0,
type: "right",
move: 1,
btn: "",
ckprefix: "jt_",
jtcbk: "jtss",
jtck: "",
custom: [],
servicelist: {
‘jt_ishare’: ‘一键分享,yjfx’,
‘jt_copy’: ‘复制网址,fzwz’,
‘jt_fav’: ‘收藏夹,scj’,
‘jt_print’: ‘打印,dy’,
‘jt_email’: ‘邮件,yj’,
‘jt_qzone’: ‘QQ空间,qqkj,sns.qzone.qq.com’,
‘jt_tsina’: ‘新浪微博,xlwb,weibo.com’,
‘jt_tqq’: ‘腾讯微博,txwb,t.qq.com’,
‘jt_tsohu’: ‘搜狐微博,shwb,t.sohu.com’,
‘jt_t163’: ‘网易微博,wywb,t.163.com’,
‘jt_renren’: ‘人人网,rrw,www.renren.com’,
‘jt_kaixin001’: ‘开心网,kxw,www.kaixin001.com’,
‘jt_sohu’: ‘搜狐白社会,shbsh,bai.sohu.com’,
‘jt_taobao’: ‘淘江湖,tjh,i.taobao.com’,
‘jt_douban’: ‘豆瓣,db,www.douban.com’,
‘jt_xiaoyou’: ‘朋友网,pyw,share.pengyou.com’,
‘jt_mop’: ‘猫扑推客,mptk,tk.mop.com’,
‘jt_baidu’: ‘百度搜藏,bdsc,cang.baidu.com’,
‘jt_tieba’: ‘百度贴吧,bdtb,tieba.baidu.com’,
‘jt_tianya’: ‘天涯社区,tysq,my.tianya.cn’,
‘jt_feixin’: ‘飞信,fx,space.feixin.10086.cn’,
‘jt_qu1’: ‘趣一网,qyw,www.qu1.com’,
‘jt_tifeng’: ‘凤凰微博,fhwb,t.ifeng.com’,
‘jt_youshi’: ‘优士网,ysw,www.ushi.cn’,
‘jt_fanfou’: ‘饭否,ff,fanfou.com’,
‘jt_51′: ’51社区,51sq,home.51.com’,
‘jt_google’: ‘谷歌,gg’,
‘jt_buzz’: ‘谷歌Buzz,ggbuzz’,
‘jt_youdao’: ‘有道书签,ydsq,shuqian.youdao.com’,
‘jt_qq’: ‘QQ书签,qqsq,shuqian.qq.com’,
‘jt_msn’: ‘MSN,msn’,
‘jt_sina’: ‘新浪vivi,xlvivi,vivi.sina.com.cn’,
‘jt_huaban’: ‘花瓣网,hbw,huaban.com’,
‘jt_ifensi’: ‘粉丝网,fsw,cyworld.ifensi.com’,
‘jt_115’: ‘115收藏,115sc’,
‘jt_hi’: ‘百度空间,bdkj,apps.hi.baidu.com’,
‘jt_gmail’: ‘Gmail邮箱,gmailyx,mail.google.com’,
‘jt_hotmail’: ‘Hotmail邮箱,hotmailyx’,
‘jt_ymail’: ‘Yahoo! mail,yahoo! mail’,
‘jt_hexun’: ‘和讯,hx,bookmark.hexun.com’,
‘jt_139mail’: ‘139邮箱,139yx’,
‘jt_189mail’: ‘189邮箱,189yx’,
‘jt_i139’: ‘手机,sj’,
‘jt_189cn’: ‘天翼社区,tysq,club.189.cn’,
‘jt_139’: ‘139说客,139sk,shequ.10086.cn’,
‘jt_tpeople’: ‘人民微博,rmwb,t.people.com.cn’,
‘jt_cnfol’: ‘中金微博,zjwb’,
‘jt_googlereader’: ‘谷歌阅读,ggyd’,
‘jt_translate’: ‘谷歌翻译,ggfy’,
‘jt_tuita’: ‘推他,tt,www.tuita.com’,
‘jt_sdonote’: ‘麦库记事,mkjs’,
‘jt_digu’: ‘嘀咕网,dgw,digu.com’,
‘jt_zhuaxia’: ‘抓虾,zx’,
‘jt_xianguo’: ‘鲜果,xg’,
‘jt_zuosa’: ‘做啥,zs,zuosa.com’,
‘jt_ganniu’: ‘赶牛网,gnw,www.ganniu.com’,
‘jt_42qu’: ’42区,42q’,
‘jt_miliao’: ‘米聊,ml’,
‘jt_woshao’: ‘我烧网,wsw,woshao.com’,
‘jt_qingsina’: ‘新浪轻博,xlqb,qing.weibo.com’,
‘jt_chinanews’: ‘中新网,zxw’,
‘jt_gmw’: ‘光明网,gmw’,
‘jt_renjian’: ‘人间网,rjw,renjian.com’,
‘jt_leihou’: ‘雷猴网,lhw,leihou.com’,
‘jt_thexun’: ‘和讯微博,hxwb,t.hexun.com’,
‘jt_dream163’: ‘梦幻人生,mhrs,dream.163.com’,
‘jt_masar’: ‘玛撒网,msw’,
‘jt_renmaiku’: ‘人脉库,rmk,www.renmaiku.com’,
‘jt_fb’: ‘Facebook,facebook,www.facebook.com’,
‘jt_twitter’: ‘Twitter,twitter,t.co’,
‘jt_tumblr’: ‘Tumblr,tumblr,www.tumblr.com’,
‘jt_reddit’: ‘Reddit,reddit’,
‘jt_instapaper’: ‘Instapaper,instapaper,www.instapaper.com’,
‘jt_readitlater’: ‘Read It Later,readitlater,readitlaterlist.com’,
‘jt_diglog’: ‘奇客发现,qkfx,www.diglog.com’,
‘jt_wealink’: ‘若邻网,rlw’,
‘jt_bietiao’: ‘别挑,bt,i.bietiao.com’,
‘jt_leshou’: ‘乐收,ls,site.leshou.com’,
‘jt_myspacecn’: ‘聚友网,jyw,blog.myspace.cn’,
‘jt_tongxue’: ‘同学网,txw’,
‘jt_waakee’: ‘挖客网,wkw’,
‘jt_cyzone’: ‘创业邦,cyb,u.cyzone.cn’,
‘jt_99earth’: ‘救救地球,jjdq’,
‘jt_chouti’: ‘抽屉网,ctw’,
‘jt_dig24’: ‘递客网,dkw,www.dig24.cn’,
‘jt_douban9dian’: ‘豆瓣9点,db9d,9.douban.com’,
‘jt_hemidemi’: ‘黑米书签,hmsq,www.hemidemi.com’,
‘jt_meilishuo’: ‘美丽说,mls’,
‘jt_mogujie’: ‘蘑菇街,mgj,mogujie.cn’,
‘jt_tianji’: ‘天际网,tjw,app.tianji.com’,
‘jt_poco’: ‘Poco网,pocow,my.poco.cn’,
‘jt_baohe’: ‘宝盒网,bhw,www.baohe.com’,
‘jt_yijee’: ‘易集网,yjw,www.yijee.com’,
‘jt_pdfonline’: ‘Pdf在线转换,pdfzxzh’,
‘jt_printfriendly’: ‘友好打印,yhdy’,
‘jt_w3c’: ‘W3c验证,w3cyz’,
‘jt_bitly’: ‘Bit.ly,bitly,bit.ly’,
‘jt_digg’: ‘Digg,digg,digg.com’,
‘jt_mailru’: ‘Mail.ru,mail.ru’,
‘jt_diigo’: ‘Diigo,diigo’,
‘jt_evernote’: ‘EverNote,evernote’,
‘jt_friendfeed’: ‘FriendFeed,friendfeed’,
‘jt_myspace’: ‘Myspace,myspace’,
‘jt_linkedin’: ‘LinkedIn,linkedin’,
‘jt_mixx’: ‘Mixx,mixx’,
‘jt_netlog’: ‘NetLog,netlog’,
‘jt_netvibes’: ‘Netvibes,netvibes’,
‘jt_phonefavs’: ‘Phonefavs,phonefavs’,
‘jt_pingfm’: ‘Ping.fm,ping.fm’,
‘jt_plaxo’: ‘Plaxo,plaxo’,
‘jt_delicious’: ‘Delicious,delicious,www.delicious.com’,
‘jt_wong’: ‘Mister Wong,misterwong’,
‘jt_stumbleupon’: ‘Stumbleupon,stumbleupon’,
‘jt_plurk’: ‘Plurk,plurk’,
‘jt_funp’: ‘Funp,funp’,
‘jt_myshare’: ‘Myshare,myshare’,
‘jt_fwisp’: ‘Fwisp,fwisp’
}
};
(function() {
try {
var g = jiathis_config || {}
} catch(e) {
var g = {}
};
var j = document.getElementsByTagName(‘script’);
for (var i = 0, ci; ci = j[i++];) {
if (/jiathis/.test(ci.src)) {
JIATHIS_CONFIGS.codehost = ci.src.substring(0, ci.src.lastIndexOf("/"));
ci.src.replace(/(type|btn|move|uid)=([^&]+)/g,
function(a, p, v) {
JIATHIS_CONFIGS[p] = v
})
}
}
var d = document,
isStrict = d.compatMode == "CSS1Compat",
dd = d.documentElement,
db = d.body,
m = Math.max,
na = navigator.userAgent.toLowerCase(),
ie = !!d.all,
head = d.getElementsByTagName(‘head’)[0] || dd,
wlh = window.location.host,
_imgw = typeof(g.imageWidth) == "number" ? g.imageWidth: 26,
_ckpre = JIATHIS_CONFIGS.ckprefix,
_lists = JIATHIS_CONFIGS.servicelist,
_ref = d.referrer,
_reced = false,
_mt = typeof(g.marginTop) == "number" ? g.marginTop: 150,
getWH = function() {
return {
h: (isStrict ? dd: db).clientHeight,
w: (isStrict ? dd: db).clientWidth
}
},
getS = function() {
return {
t: m(dd.scrollTop, db.scrollTop),
l: m(dd.scrollLeft, db.scrollLeft)
}
},
creElm = function(o, t, a) {
var b = d.createElement(t || ‘div’);
for (var p in o) {
p == ‘style’ ? b[p].cssText = o[p] : b[p] = o[p]
}
return (a || db).insertBefore(b, (a || db).firstChild)
},
_sc = function(a, b, c) {
var d = new Date();
d.setTime(d.getTime() + c * 1000);
document.cookie = a + "=" + escape(b) + (c ? ";expires=" + d.toGMTString() : "") + ";path=/"
},
_gc = function(a) {
var b = document.cookie;
var c = b.indexOf(a + "=");
if (c != -1) {
c += a.length + 1;
var d = b.indexOf(";", c);
if (d == -1) {
d = b.length
}
return unescape(b.substring(c, d))
}
return ""
},
_rec = function(e) {
if (!_reced) {
if ( !! e.origin && e.origin.slice( – 12) == ".jiathis.com") {
if (e.data && e.data != "FALSE") {
JIATHIS_CONFIGS.jtck = e.data
}
}
_req();
_reced = true
}
},
_custom = function() {
try {
var a = jiathis_config || {}
} catch(e) {
var a = {}
};
var u = a.services_custom;
if (u) {
if (! (u instanceof Array)) {
u = [u]
}
for (var b = 0; b < u.length; b++) {
var c = u[b];
if (c.name && c.icon && c.url) {
c.code = c.url = c.url.replace(/ /g, "");
c.code = c.code.split("//").pop().split("?").shift().split("/").shift().toLowerCase();
JIATHIS_CONFIGS.custom[c.code] = c;
JIATHIS_CONFIGS.servicelist[_ckpre + c.code] = c.name + ‘,’ + c.code + ‘,’ + c.code
}
}
}
},
_req = function() {
try {
var a = jiathis_config || {}
} catch(e) {
var a = {}
};
var b = a.shareImg || {};
b.showType && creElm({
src: JIATHIS_CONFIGS.codehost + "/plugin.shareimg.js",
charset: "utf-8"
},
"script", head);
var c, s, E = encodeURIComponent,
o = _grf(_ref),
T = document.title || "",
Y = window.location.href || "",
an = Y ? Y.indexOf(JIATHIS_CONFIGS.jtcbk) : -1,
d1 = _gd(o.host),
d2 = _gd(Y),
q = null,
f = (d1 && d2 && d1 == d2) ? false: true;
if (an > -1) {
c = Y.substr(an);
q = c.split("#").pop().split("-").pop().split("=").pop();
q = _lists[_ckpre + q] ? q: ”
}
q = (!q && o.webid) ? o.webid: q;
if (q && f) {
s = ‘rsc=’ + q + ‘&rnm=’ + parseInt(JIATHIS_CONFIGS.uid) + ‘&rfh=’ + E(o.host) + ‘&rfp=’ + E(o.path) + ‘&pre=’ + E(Y) + ‘&tit=’ + escape(T);
(new Image).src = JIATHIS_CONFIGS.lhost + "/l.gif?" + s
}
},
_gd = function(o) {
var d = null;
if (o) {
d = o.split(".").slice( – 2).join(".");
d = (d == "com.cn") ? o.split(".").slice( – 3).join(".") : d;
d = d.split("/").shift()
}
return d
},
_grf = function(r) {
var h = "",
p = "",
q = "",
m;
if (r.match(/(?:[a-z]\:\/\/)([^\/\?]+)(.*)/gi)) {
h = RegExp.$1;
p = RegExp.$2;
h = h ? h: "";
p = p ? p: "";
if (h) {
for (var k in _lists) {
m = _lists[k].split(‘,’);
if (m[2] && m[2] == h) {
q = k.slice(3);
break
}
}
}
}
return {
host: h,
path: p,
webid: q
}
},
jiathis_utility_ifr = !!window.postMessage ? creElm({
style: "display:none;",
frameBorder: 0,
src: JIATHIS_CONFIGS.codehost + "/jiathis_utility.html"
},
"iframe") : null,
div,
div1 = creElm({
id: ‘ckepop’,
style: "height:auto;position:absolute;z-index:100000000;display:none;top:50%;left:50%;overflow:auto;"
}),
inputTimer,
list,
clist,
as,
texts = {},
script,
timerover,
timerout,
timerloop,
loop = function() {
var t = 1000,
st = getS().t,
c,
c = st – div.offsetTop + _mt;
c != 0 && (div.style.top = div.offsetTop + c / 10 + ‘px’, t = 10);
timerloop = setTimeout(loop, t)
},
iframe = creElm({
style: ‘position:’ + (/firefox/.test(na) ? ‘fixed’: ‘absolute’) + ‘;display:none;’,
frameBorder: 0
},
‘iframe’),
dsp = (_gc("jiathis_off") == ‘yes’) ? ‘display:none;’: ”,
rpic = g.imageUrl || (JIATHIS_CONFIGS.codehost + "/images/" + (JIATHIS_CONFIGS.btn || ‘r.gif’)),
lpic = g.imageUrl || (JIATHIS_CONFIGS.codehost + "/images/" + (JIATHIS_CONFIGS.btn || ‘l.gif’)),
hidemore = g.hideMore || false,
ckjs = hidemore ? "": " onclick=’$CKE.center(this)’",
flag = ((!isStrict && /msie /i.test(na)) || (JIATHIS_CONFIGS.move == 1 || /msie 6/i.test(na)));
div = creElm({
id: ‘ckepop’,
style: dsp + "height:auto;position:" + (flag ? ‘absolute’: ‘fixed’) + ";z-index:100000000;top:" + (flag ? ‘0’: _mt + ‘px’) + ";" + (JIATHIS_CONFIGS.type == ‘right’ ? "right:0;overflow:hidden;width:" + _imgw + "px;": "left:-242px;overflow:auto;"),
innerHTML: JIATHIS_CONFIGS.type == ‘right’ ? "<table cellPadding=0 cellSpacing=0><tbody style=’background:transparent’><tr><td style=’background:transparent’><img src=’" + rpic + "’ style=’cursor:pointer;’ onmouseover=’$CKE.over()’" + ckjs + " /></td><td><div></div></td></tr></tbody></table>": "<table cellPadding=0 cellSpacing=0><tbody style=’background:transparent’><tr><td><div></div></td><td><img src=’" + lpic + "’ style=’cursor:pointer;’ onmouseover=’$CKE.over()’" + ckjs + " /></td></tr></tbody></table>"
});
window._jiathis_r = div;
_custom();
creElm({
href: JIATHIS_CONFIGS.codehost + ‘/css/jiathis_share.css’,
rel: ‘stylesheet’,
type: ‘text/css’
},
‘link’);
d.write(‘<script src="’ + JIATHIS_CONFIGS.codehost + ‘/ckepop.js" charset="utf-8"></script><script src="’ + JIATHIS_CONFIGS.codehost + ‘/ckecenterpop.js" charset="utf-8"></script>’);
$CKE = {
sers: "",
pop: div.getElementsByTagName(‘div’)[0],
centerpop: div1,
disappear: function(a) {
var b = window.event || a,
t = b.srcElement || b.target,
contain = div1.contains ? div1.contains(t) : !!(div1.compareDocumentPosition(t) & 16),
contain1 = div.contains ? div.contains(t) : !!(div.compareDocumentPosition(t) & 16);
if (!contain && !contain1) {
iframe.style.display = div1.style.display = ‘none’
}
},
over: JIATHIS_CONFIGS.type == ‘right’ ?
function() {
if (div.offsetWidth > _imgw) {
return
}
clearTimeout(timerloop);
clearInterval(timerout);
div.style.cssText += ";width:" + _imgw + "px;left:" + (getWH() – _imgw) + "px";
var t = 10,
tmp = 0,
step = this.pop.offsetWidth / 55;
timerover = setInterval(function() {
if (t == 0) {
clearInterval(timerover);
flag && loop()
} else {
var n = Math.round(step * t–);
div.style.left = div.offsetLeft – n + ‘px’;
div.style.width = div.offsetWidth + n + ‘px’
}
div.style.zIndex = 100000000
},
10)
}: function() {
clearTimeout(timerloop);
clearInterval(timerout);
clearInterval(timerover);
var t = 10,
tmp = 0,
step = Math.abs(div.offsetLeft / 55);
timerover = setInterval(function() {
if (t == 0) {
clearInterval(timerover);
flag && loop()
} else {
var n = Math.round(step * t–);
div.style.left = div.offsetLeft + n + ‘px’
}
div.style.zIndex = 100000000
},
10)
},
out: JIATHIS_CONFIGS.type == ‘right’ ?
function() {
$CKE.cancelClose();
if (div.offsetWidth > $CKE.pop.offsetWidth) {
clearInterval(timerover);
clearTimeout(timerloop);
div.style.cssText += ";width:" + ($CKE.pop.offsetWidth + _imgw) + "px;left:" + (getWH() – _imgw – $CKE.pop.offsetWidth) + "px";
var t = 10,
tmp = 0,
step = (div.offsetWidth – _imgw) / 55;
timerout = setInterval(function() {
if (t == 0) {
clearInterval(timerout);
div.style.left = ”;
flag && loop()
} else {
var n = Math.round(step * t–);
div.style.width = div.offsetWidth – n < _imgw ? _imgw: div.offsetWidth – n + ‘px’;
div.style.left = div.offsetLeft + n + ‘px’
}
div.style.zIndex = 100000000
},
10)
}
}: function() {
$CKE.cancelClose();
clearInterval(timerover);
clearInterval(timerout);
clearTimeout(timerloop);
var t = 10,
tmp = 0,
step = Math.abs((div.offsetLeft + 242) / 55);
timerout = setInterval(function() {
if (t == 0) {
clearInterval(timerout);
div.style.left = ‘-242px’;
flag && loop()
} else {
var n = Math.round(step * t–);
div.style.left = div.offsetLeft – n + ‘px’
}
div.style.zIndex = 100000000
},
10)
},
center: function(a) {
if (a) {
db.style.position = ‘static’;
var b = getS();
div1.style.display = "block";
div1.style.margin = ( – div1.offsetHeight / 2 + b.t) + "px " + ( – div1.offsetWidth / 2 + b.l) + "px";
list = d.getElementById(‘ckelist’);
clist = list.cloneNode(true);
as = clist.getElementsByTagName(‘input’);
for (var i = 0, ci; ci = as[i++];) {
texts[ci.value] = ci.parentNode
}
with(iframe.style) {
left = top = ‘50%’;
width = div1.offsetWidth + ‘px’;
height = div1.offsetHeight + ‘px’;
margin = div1.style.margin;
display = ‘block’
}
}
},
choose: function(o) {
clearTimeout(inputTimer);
inputTimer = setTimeout(function() {
var s = o.value.replace(/^\s+|\s+$/, ”),
frag = d.createDocumentFragment();
for (var p in texts) {
eval("var f = /" + (s || ‘.’) + "/ig.test(p)"); !! texts[p].cloneNode && (f && frag.appendChild(texts[p].cloneNode(true)))
}
list.innerHTML = ”;
list.appendChild(frag)
},
100)
},
centerClose: function() {
iframe.style.display = div1.style.display = ‘none’
},
shareClose: function() {
var a = d.getElementById("jiathis_sers");
if (a) {
if (!$CKE.sers) {
$CKE.sers = a.innerHTML
}
var b = ‘<div style="margin:10px 5px 10px 10px;font-size:14px;">’;
b += ‘<p style="font-weight:normal;margin-bottom:10px;">关闭分享按钮?</p>’;
b += ‘<p style="color:#666;font-size:12px;font-weight:normal;margin-bottom:10px;">关闭后,该分享按钮将不再出现,您也无法使用分享到功能,确定吗?</p>’;
b += ‘<p style="background:none repeat scroll 0 0 #FEFFDB;border:1px solid #FFDDB3;padding:10px 15px;width:185px;"><a href="javascript:;" onclick="$CKE.doClose();return false;"><u style="font-weight:normal;">确定</u></a> <a href="javascript:;" onclick="$CKE.cancelClose();return false;"><u style="font-weight:normal;">取消</u></a></p>’;
b += ‘</div>’;
a.innerHTML = b
}
},
doClose: function() {
iframe.style.display = div1.style.display = div.style.display = ‘none’;
_sc("jiathis_off", "yes", 86400)
},
cancelClose: function() {
var a = d.getElementById("jiathis_sers");
if ($CKE.sers && a) {
a.innerHTML = $CKE.sers;
$CKE.sers = ”
}
},
open: function(A) {
creElm({
src: A,
charset: "utf-8"
},
"script", head)
},
fireEvent: function(F, O) {
if (F) {
F = typeof(F) == "function" ? F: eval(F);
F(O)
}
}
};
if ( !! window.addEventListener) { !! window.addEventListener && window.addEventListener("message", _rec, false)
} else {
if ( !! window.postMessage) { ( !! window.attachEvent && window.attachEvent("onmessage", _rec))
} else {
_req()
}
}
if (ie) {
div.onmouseleave = $CKE.out;
d.attachEvent("onclick", $CKE.disappear)
} else {
div.onmouseout = function(e) {
try {
var p = (this.compareDocumentPosition(e.relatedTarget) == 20)
} catch(e) {
var p = false
}; ! (this === e.relatedTarget || (this.contains ? this.contains(e.relatedTarget) : p)) && $CKE.out.call(this)
};
d.addEventListener("click", $CKE.disappear, false)
};
flag && loop()
})();
function jiathis_sendto(a) {
try {
var b = jiathis_config || {}
} catch(e) {
var b = {}
};
var c = encodeURIComponent,
cu = JIATHIS_CONFIGS.custom[a] || {},
U = String(b.url || document.location),
W = "?webid=" + a,
G = "&url=" + c(U),
T = "&title=" + c(b.title || document.title),
S = b.summary ? "&summary=" + c(b.summary) : "",
F = JIATHIS_CONFIGS.uid ? "&uid=" + parseInt(JIATHIS_CONFIGS.uid) : "",
E = b.data_track_clickback ? "&jtss=1": "",
K = (b.appkey && b.appkey[a]) ? "&appkey=" + b.appkey[a] : "",
P = b.pic ? "&pic=" + c(b.pic) : "",
R = (b.ralateuid && b.ralateuid[a]) ? "&ralateuid=" + b.ralateuid[a] : "",
Q = (b.evt && b.evt[‘share’]) ? b.evt[‘share’] : null,
A = ‘http://s.jiathis.com/’,
X = (cu.name && cu.url) ? "&acn=" + c(cu.name) + "&acu=" + c(cu.url) : "",
B = A + W + G + T + F + E + K + P + R + S + X;
if (a == ‘copy’ || a == ‘fav’ || a == ‘print’) {
$CKE.open(B);
if (a == ‘copy’) {
jiathis_copyUrl()
} else if (a == ‘fav’) {
jiathis_addBookmark()
} else {
window.print()
}
} else {
window.open(B, ”)
}
$CKE.fireEvent(Q, {
type: ‘share’,
data: {
service: a,
url: U
}
});
return false
}
function jiathis_addBookmark() {
try {
var d = jiathis_config || {}
} catch(e) {
var d = {}
};
var a = d.title || document.title;
var b = d.url || parent.location.href;
var c = window.sidebar;
if (c && !!c.addPanel) {
c.addPanel(a, b, "")
} else if (document.all) {
window.external.AddFavorite(b, a)
} else {
alert(‘请按 Ctrl + D 为你的浏览器添加书签!’)
}
}
function jiathis_copyUrl() {
try {
var d = jiathis_config || {}
} catch(e) {
var d = {}
};
var a = d.url || this.location.href;
var b = d.title || document.title;
var c = b + " " + a;
var f = navigator.userAgent.toLowerCase();
var g = f.indexOf(‘opera’) != -1 && opera.version();
var h = (f.indexOf(‘msie’) != -1 && !g) && f.substr(f.indexOf(‘msie’) + 5, 3);
if (h) {
clipboardData.setData(‘Text’, c);
alert("复制成功,请粘贴到你的QQ/MSN上推荐给你的好友!")
} else if (prompt(‘你使用的是非IE核心浏览器,请按下 Ctrl+C 复制代码到剪贴板’, c)) {
alert(‘复制成功,请粘贴到你的QQ/MSN上推荐给你的好友!’)
} else {
alert(‘目前只支持IE,请复制地址栏URL,推荐给你的QQ/MSN好友!’)
}
}
}