ec.share = { init: function (rid, buss, logo) { var templates = { qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{URL}}&title={{TITLE}}&desc={{DESCRIPTION}}&summary={{SUMMARY}}&site={{SOURCE}}&pics={{IMAGE}}', qq: 'http://connect.qq.com/widget/shareqq/index.html?url={{URL}}&title={{TITLE}}&source={{SOURCE}}&desc={{DESCRIPTION}}&pics={{IMAGE}}&summary="{{SUMMARY}}"', weibo: 'https://service.weibo.com/share/share.php?url={{URL}}&title={{TITLE}}&pic={{IMAGE}}&appkey={{WEIBOKEY}}', douban: 'http://shuo.douban.com/!service/share?href={{URL}}&name={{TITLE}}&text={{DESCRIPTION}}&image={{IMAGE}}&starid=0&aid=0&style=11', linkedin: 'http://www.linkedin.com/shareArticle?mini=true&ro=true&title={{TITLE}}&url={{URL}}&summary={{SUMMARY}}&source={{SOURCE}}&armin=armin', facebook: 'https://www.facebook.com/sharer/sharer.php?u={{URL}}', twitter: 'https://twitter.com/intent/tweet?text={{TITLE}}&url={{URL}}&via={{ORIGIN}}', google: 'https://plus.google.com/share?url={{URL}}', wechat: 'javascript:ec.share.wechat();', copyurl: 'javascript:ec.share.copyUrl();' }; function getMetaContentByName(name) { return (document.getElementsByName(name)[0] || 0).content; } function crateShareUrl(name, data) { return templates[name].replace(/\{\{(\w)(\w*)\}\}/g, function (m, fix, key) { var nameKey = name + fix + key.toLowerCase(); key = (fix + key).toLowerCase(); return encodeURIComponent((data[nameKey] === undefined ? data[key] : data[nameKey]) || ''); }); } if (logo) logo = window.location.protocol + "//" + window.location.host + "/image/" + logo + ".png?"; else logo = (document.images[0] || 0).src || ''; this.data = { url: location.href, origin: location.origin, source: document.title, title: getMetaContentByName("title") || document.title, description: getMetaContentByName("Description") || "", image: logo, summary: getMetaContentByName("Description") || "", imageSelector: undefined, weiboKey: '', mobileSites: [], disabled: [], initialized: false, buss: buss, rid: rid }; for (var name in templates) { var el = $(".share ." + name); if (el.length) { var url = crateShareUrl(name, this.data); el.attr("href", url); } } }, wechat(rid) { ke.openWindow(null, "/qrcode?refDocType=" + this.data.buss + "&refDocRID=" + this.data.rid, 300, 320, { modal: true, clickHide: true, css: 'window1 ', draggable: false, btnClose: true }).show(); }, copyUrl: function () { var input = document.createElement("input"); input.style = "position: absolute; left: -1000px; top: -1000px"; input.value = window.location.href; document.body.appendChild(input); input.select(); try { document.execCommand("copy"); ec.notify(L.G("已经复制到剪切板")); } catch (e) { ec.notifyE(L.G("复制失败,您的浏览器不支持,请手动复制")); } document.body.removeChild(input); } } L.push([ "已经复制到剪切板", "Already copied to clipboard", "复制失败,您的浏览器不支持,请手动复制.", "Copy failed, your browser does not support it, please manually copy" ]);