UNPKG

gxb-js-sdk

Version:

GXB JS-SDK is a web development kit based on BlockCity for web developers.

2 lines (1 loc) 1.33 kB
"use strict";var methods={},methodID=0;window.nativeCallback=function(t){var e=Array.prototype.slice.call(arguments,1);"function"==typeof methods[t]&&methods[t].apply(this,e)};var index={callBridge:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments[3],o=methodID++,l="";methods[o]=function(){if("function"==typeof n&&n.apply(this,arguments),methods[o])try{delete methods[o]}catch(t){methods[o]=null}},i._mId=o;for(var r in i)l+=(-1!=l.indexOf("=")?"&":"")+r+"="+encodeURI(i[r]);var a,c=t+"://"+e+"?"+l;a=document.createElement("iframe"),a.setAttribute("src",c),a.setAttribute("style","display:none;"),a.setAttribute("height","0px"),a.setAttribute("width","0px"),a.setAttribute("frameborder","0"),document.body.appendChild(a),a.parentNode.removeChild(a),a=null},callNative:function(t,e,i){this.callBridge("native",t,e,i)},exit:function(){this.callNative("exit")},openExplorer:function(t){this.callNative("openurl",{url:t})},qrScan:function(t){t||(t=function(){}),this.callNative("qrscan",{},function(e){t&&t(e)})},shareConfig:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];e||(e=function(){}),this.callNative("shareConfig",{title:t.title||"",shareDes:t.shareDes||"",url:t.url||"",thumbUrl:t.thumbUrl||""},function(t){e&&e(t)})}};module.exports=index;