²é¿´: 1105  |  »Ø¸´: 0

foom19961125

гæ (³õÈëÎÄ̳)

[ÇóÖú] ÓÐÈËÄÜ¿´¶®Õâ¸öÂð

//
//  CXJSBridge.js
//  CXJSBridge
//
//  Created by Chao Xing on 12-3-1.
//  Copyright (c) 2012Äê Chao Xing Technology Co., Ltd. All rights reserved.
//

(function(context){
    function bridgeCall(src,callback) {
                iframe = document.createElement("iframe";
                iframe.style.display = "none";
                iframe.src = src;
                var cleanFn = function(state){
                   console.log(state)
                    try {
                        iframe.parentNode.removeChild(iframe);
                    } catch (error) {}
                    if(callback) callback();
                };
        iframe.onload = cleanFn;
                document.documentElement.appendChild(iframe);
        }
       
    function JSBridge()
    {
            this.device="ios";
        this.callbackDict = {};
        this.notificationIdCount = 0;
        this.notificationDict = {};
        
        var that = this;
        context.document.addEventListener('DOMContentLoaded',function(){
            bridgeCall('jsbridge://NotificationReady',that.trigger('jsBridgeReady',{}));
        },false);
    }
   
    JSBridge.prototype = {
        constructor: JSBridge,
        //send notification to WebView
        postNotification: function(name, userInfo){
                if(this.device == 'android'){
                        androidjsbridge.postNotification(name, JSON.stringify(userInfo));
                } else {
                    this.notificationIdCount++;
                   
                    this.notificationDict[this.notificationIdCount] = {name:name, userInfo:userInfo};
       
                    bridgeCall('jsbridge://PostNotificationWithId-' + this.notificationIdCount);
                }
        },
        //pop the notification in the cache
        popNotificationObject: function(notificationId){
            var result = JSON.stringify(this.notificationDict[notificationId]);
            delete this.notificationDict[notificationId];
            return result;
        },
        //trigger the js event
        trigger: function(name, userInfo) {
            if(this.callbackDict[name]){
                var callList = this.callbackDict[name];
               
                for(var i=0,len=callList.length;i<len;i++){
                    callList(userInfo);
                }
            }
        },
        setDevice:function(device){
                        this.device = device;
                        try{context._jsBridgeReady();}catch(e){}
                },
        //bind js event
        bind: function(name, callback){
            if(!this.callbackDict[name]){
                //create the array
                this.callbackDict[name] = [];
            }
            this.callbackDict[name].push(callback);
        },
        //unbind js event
        unbind: function(name, callback){
            if(arguments.length == 1){
                delete this.callbackDict[name];
            } else if(arguments.length > 1) {
                if(this.callbackDict[name]){
                    var callList = this.callbackDict[name];
                    
                    for(var i=0,len=callList.length;i<len;i++){
                        if(callList == callback){
                            callList.splice(i,1);
                            break;
                        }
                    }
                }
                if(this.callbackDict[name].length == 0){
                    delete this.callbackDict[name];
                }
            }            
        }        
    };
     
    context.jsBridge = new JSBridge();
   
})(window);

·¢×ÔСľ³æAndroid¿Í»§¶Ë
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ foom19961125 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] 290·Ö²ÄÁϹ¤³Ì085601Çóµ÷¼Á Êý¶þÓ¢Ò» +5 llx0610 2026-03-02 5/250 2026-03-02 20:20 by hypershenger
[¿¼ÑÐ] »¯Ñ§£¬²ÄÁÏ£¬»·¾³ÀàÇóµ÷¼Á +7 ¿¼Ñаæ°ô°ô 2026-03-02 7/350 2026-03-02 19:56 by hypershenger
[¿¼ÑÐ] 0854×Ü·Ö272 +3 ´òС¾ÍÊÇÀÏʵÈË 2026-03-02 4/200 2026-03-02 19:49 by Çóµ÷¼Ázz
[¿¼ÑÐ] 283Çóµ÷¼Á +5 ¹ĭóÏ 2026-03-02 5/250 2026-03-02 19:19 by zhukairuo
[¿¼ÑÐ] ²ÄÁÏ085601µ÷¼Á +5 ¶à¶à×Ó. 2026-03-02 5/250 2026-03-02 19:15 by zhukairuo
[¿¼ÑÐ] һ־Ըɽ¶«´óѧ²ÄÁÏÓ뻯¹¤325Çóµ÷¼Á +5 °ë½ØµÄÊ«0927 2026-03-02 5/250 2026-03-02 18:37 by Ã÷ÁÁ9527
[¿¼ÑÐ] ½ÓÊÕµ÷¼Á +6 ½òÃȽòÃÈ 2026-03-02 13/650 2026-03-02 18:34 by fengyuling00
[¿¼ÑÐ] Ò»Ö¾Ô¸»ªÄÏÀí¹¤´óѧ²ÄÁÏÓ뻯¹¤326·Ö£¬Çóµ÷¼Á +3 wujinrui1 2026-02-28 3/150 2026-03-02 16:36 by chuocheng
[¿¼ÑÐ] ²ÄÁÏ»¯¹¤µ÷¼Á +12 ½ñÏIJ»ÏÄ 2026-03-01 14/700 2026-03-02 16:09 by ½ñÏIJ»ÏÄ
[¿¼ÑÐ] 303Çóµ÷¼Á +5 ½ñÏIJ»ÏÄ 2026-03-01 5/250 2026-03-02 15:01 by ÏòÉϵÄÅÖ¶«
[¿¼²©] ³ÏÕÐũҵ²©Ê¿ +3 ÐÄÐÀÏòÈÙ 2026-02-28 3/150 2026-03-02 13:33 by ʱ¼ä²»¹·
[¿¼ÑÐ] 291 Çóµ÷¼Á +3 »¯¹¤2026½ì±ÏÒµÉ 2026-03-02 3/150 2026-03-02 12:55 by houyaoxu
[¿¼ÑÐ] 292Çóµ÷¼Á +7 yhk_819 2026-02-28 7/350 2026-03-02 12:43 by Î޼ʵIJÝÔ­
[¿¼ÑÐ] 275Çóµ÷¼Á +3 L-xin? 2026-03-01 6/300 2026-03-02 10:22 by ÈÈÇéɳĮ
[¿¼ÑÐ] ²ÄÁÏÀàÇóµ÷¼Á +11 wana_kiko 2026-02-28 14/700 2026-03-02 08:46 by ´ÏÃ÷µÄ´óËÉÊó
[¿¼ÑÐ] »¯¹¤299·ÖÇóµ÷¼Á Ò»Ö¾Ô¸985Âä°ñ +5 ÎûÎû(*^¦Ø^*) 2026-03-01 5/250 2026-03-01 19:47 by Î޼ʵIJÝÔ­
[¿¼ÑÐ] 304Çóµ÷¼Á +6 ÂüÊâ2266 2026-02-28 7/350 2026-03-01 15:14 by wjLi2017
[¿¼ÑÐ] 317Ò»Ö¾Ô¸»ªÄÏÀí¹¤µçÆø¹¤³ÌÇóµ÷¼Á +6 Soliloquy_Q 2026-02-28 11/550 2026-03-01 11:14 by ¸èliekkas
[ÂÛÎÄͶ¸å] ÇóÖúcoordination chemistry reviews µÄд×÷Ä£°å 10+3 ljplijiapeng 2026-02-27 4/200 2026-03-01 09:07 by babero
[¿¼ÑÐ] 304Çóµ÷¼Á +3 52hz~~ 2026-02-28 5/250 2026-03-01 00:00 by 52hz~~
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û