1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/webmi-MobileShare

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
share.min.js 3.7 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
小菜 Отправлено 01.03.2017 05:32 4b9e7bb
var mobileShare=function(e,t){var i=document.getElementById(e),n={encode:function(e){return window.btoa(unescape(encodeURIComponent(e)))},decode:function(e){return decodeURIComponent(escape(window.atob(e)))}},o=navigator.userAgent;this.deviceDetect=function(e){return o.indexOf(e)!==-1},this.getVersion=function(e){var t=e.split("."),i=parseFloat(t[0]+"."+t[1]);return i};var s=deviceDetect("MQQBrowser"),r=deviceDetect("UCBrowser"),a=deviceDetect("MicroMessenger"),c=deviceDetect("iPhone")||deviceDetect("iPad")||deviceDetect("iPod"),l=deviceDetect("Android"),d=s?getVersion(o.split("MQQBrowser/")[1]):0,p=r?getVersion(o.split("UCBrowser/")[1]):0,m=c?o.split("OS")[1].split("_")[0]:0,u=!1;(c&&p>=10.2||l&&p>=9.7||d>=5.4&&!a)&&(u=!0),t=t||{};var h=t.url||document.location.href,g=t.title||document.title,v=t.desc,w=t.img||document.getElementsByTagName("img").length>0&&document.getElementsByTagName("img")[0].src,f={Weibo:["http://service.weibo.com/share/share.php?url={url}&title={title}&pic={img}",""],QQ:["http://connect.qq.com/widget/shareqq/index.html?url={url}&title={title}&pics={img}","mqqapi://share/to_fri?src_type=web&version=1&file_type=news"],QZone:["http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}&title={title}&pics={img}","mqqapi://share/to_qzone?src_type=web&version=1&file_type=news&req_type=1"]};if(this.loadCss=function(){var e=document.scripts,t=e[e.length-1],i=t.src,n=i.substring(0,i.lastIndexOf("/")+1);t.getAttribute("merge")||document.head.appendChild(function(){var e=document.createElement("link");return e.href=n+"icon/style.css",e.rel="styleSheet",e}())},this.loadHtml=function(){var e=document.createElement("div");e.id="mobileShare",e.style.display="none",e.innerHTML='<div id="mask" onclick="closeShare()"></div>'+(a?'<div class="tips"><i></i><p>点击右上角<br>分享到朋友圈或指定的朋友</p></div>':'<div class="share"><ul><li data-app="Weibo" class="weibo"><i></i>新浪微博</li><li data-app="QQ" class="qq"><i></i>QQ好友</li><li data-app="QZone" class="qzone"><i></i>QQ空间</li></ul><a href="javascript:closeShare();">取消</a></div>'),document.body.appendChild(e)},this.loadQQJs=function(){if(s){var e=d<5.4?"http://3gimg.qq.com/html5/js/qb.js":"http://jsapi.qq.com/get?api=app.share",t=document.createElement("script");t.src=e,document.body.appendChild(t)}},this.share=function(e){var t=appendToQuerysting(f[e][1],{share_id:"1101685683",url:n.encode(h),title:n.encode(g),description:n.encode(v),previewimageUrl:n.encode(w),image_url:n.encode(w)});"Weibo"==e?openAppByApi(f[e][0]):openAppByScheme(t)},this.openAppByApi=function(e){var t={url:h,title:g,img:w};for(k in t)e=e.replace("{"+k+"}",encodeURIComponent(t[k]));window.open(e)},this.appendToQuerysting=function(e,t){var i=[];for(var n in t)i.push(n+"="+encodeURIComponent(t[n]));return e+(e.indexOf("?")!==-1?"&":"?")+i.join("&")},this.openAppByScheme=function(e){if(m>8)window.location.href=e;else{var t=document.createElement("iframe");t.style.display="none",t.src=e,document.body.appendChild(t),setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},1e3)}},loadCss(),loadQQJs(),!u){loadHtml();var y=document.getElementById("mobileShare");this.closeShare=function(){y.className="",document.getElementById("mask").style.display="none"};for(var b=y.getElementsByTagName("li"),q=0;q<b.length;q++)b[q].onclick=function(){share(this.getAttribute("data-app"))}}i.onclick=function(){u?(r&&(window.ucweb&&ucweb.startRequest("shell.page_share",["","","","","","",""]),window.ucbrowser&&ucbrowser.web_share(["","","","","","",""])),s&&(window.browser&&browser.app.share({to_app:""}),window.qb&&window.qb.share({to_app:""}))):(y.style.display="block",setTimeout(function(){y.className="show"},0),document.getElementById("mask").style.display="block")}};

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/webmi-MobileShare.git
git@api.gitlife.ru:oschina-mirror/webmi-MobileShare.git
oschina-mirror
webmi-MobileShare
webmi-MobileShare
master