PageSourceSearch

https://pb.hebbank.com/ares-web-base/assets/js/plugin/ukey/feitian.js

js hebbank.com collected 2026-10-06 19:20:30 UTC 8,046 bytes, 264 lines download raw bytes

1/**
2 * 支持IE控件的示例
3 * 共通部分不需要修改,仅修改注释“调用控件接口的部分”之后的内容
4 * 须在注释“调用控件接口的部分”之后加入对控件接口的转发调用
5 */
6function SampleAtlCtrl(clsid) {
7    // 共通部分不要修改
8    this.ready_func_ = null;
9    this.GetUSBKeyStat_callback = null;
10    this.callbacks_ = new HashTable();
11    this.module_ = "IActiveXCtrl";
12    if ('WebSocket' in window) {
13        try{
14            this.ws = new WebSocket("wss://127.0.0.1:1237");
15        }catch(e){
16            ES.websock = false;
17            console.log(e);
18        }
19    }
20    else{
21        FT.wsError = true ;
22        throw "WebSocket not supported";
23    }
24    this.ws.onerror = function () { 
25        FT.wsError = true ;
26        // throw "Unable to establish connection to WebSocket";
27    }
28
29    this.loadModule = function() {
30        var msg = JSON.stringify({
31            "MsgId": "LoadModule",
32            "Module": this.module_});
33        this.ws.onmessage = this._callback.bind(this);
34        this.ws.send(msg);
35    };
36    this.loadModuleCallBack = function(result, response) {
37        if (!result)
38            throw result.Response;
39        if (this.ready_func_) this.ready_func_();
40    }.bind(this);
41
42    this.callbacks_.add("LoadModule", this.loadModuleCallBack);
43
44    this.exec = function(func, param, callback) {
45        var msg_id = Object.id(callback).toString();
46        this.callbacks_.add(msg_id, callback);
47        var param_ = {
48            "MsgId": msg_id,
49            "Method": func + "|" + clsid
50        };
51        if (param) {
52            param_["Param"] = JSON.stringify(param);
53        }
54        var msg = JSON.stringify(param_);
55        this.ws.send(msg);
56    }
57
58
59    this.ready = function(func) {
60        this.ready_func_ = func;
61    }
62
63    this._callback = function(response) {
64        var r = JSON.parse(response.data);
65        var msg_id = r.MsgId;
66        // if(r.Result){
67        //     console.info(r.Response);
68        // }else{
69        //     console.error(r.response);
70        // }
71        if(!this.callbacks_.containsKey(msg_id)){
72            return;
73        }
74        //console.log(this.callbacks_.getKeys());
75        //console.log(msg_id);
76        var callback = this.callbacks_.getValue(msg_id);
77        callback(r.Result, r.Response);
78        this.callbacks_.remove(msg_id);
79    }
80
81    this.ws.onopen = this.loadModule.bind(this);
82
83    /**
84     * 调用控件接口的部分
85     * 与test.html的调用名称相对应,以下均为示例函数,使用时删除即可
86     * exec第一个参数是 ActiveX控件 的接口名称,第二个参数是ActiveX控件的 参数 传入,第三个参数不需要修改
87     * 对每一个ActiveX控件接口都要写一个通过WebSocket调用的函数
88     */
89
90    this.GetUSBKeyStat = function(callback){
91        if(callback==null){
92            callback = this.GetUSBKeyStat_callback;
93        }
94        if(!FT.wsError){
95            if(FT.wsOpen){
96                this.exec("GetUSBKeyStat", null, callback);
97            }else{
98                this.GetUSBKeyStat_callback = callback ;
99                window.setTimeout("FT.ctrl.GetUSBKeyStat()",200);
100            }
101        }else{
102            callback && callback(true,"");
103        }
104        
105    }
106    this.GetUSBKeyType = function(callback){
107        if(!FT.wsError){
108            this.exec("GetUSBKeyType", null, callback);
109        }else{
110            callback && callback(true,"");
111        }
112    }
113    this.GetSN = function(callback){
114        if(!FT.wsError){
115            this.exec("GetSN", null, callback);
116        }else{
117            callback && callback(true,"");
118        }
119    }
120    this.InitUSBKey = function(callback){
121        if(!FT.wsError){
122            this.exec("InitUSBKey", null, callback);
123        }else{
124            callback && callback(true,"");
125        }
126        
127    }
128};
129
130
131//------------------------------------------------------------------------------
132
133var FT = {
134    ctrl:null,
135    websock:true,
136    wsError:false,
137    wsOpen:false,
138    state:"",
139
140
141    init:function() {
142        var browserName = navigator.appName;
143        var browserNum = parseInt(navigator.appVersion);
144        if(FT.ctrl==null){
145            if ((browserName == "Microsoft Internet Explorer") && (browserNum >= 4) || (navigator.userAgent.indexOf("Trident") >= 0)){
146                FT.websock = false;
147                FT.ctrl = document.getElementById("FTKeyCtrl");
148            }else{
149                try{
150                    /*需要修改所加载ActiveX控件的classid,需要带花括号*/
151                    
152                    FT.ctrl = new SampleAtlCtrl("{FA800E48-D9BE-419b-BC6E-2A80B66A8AAE}");
153                    FT.ctrl.ready(function(){
154                        FT.wsOpen = true ;
155                    })
156                }catch (e){
157                    FT.ctrl = document.getElementById("FTKeyCtrl");
158                    FT.websock = false;
159                }
160            }
161        }
162    },
163    /* 以下是调用接口函数的实现,以下均为示例函数,使用时删除即可
164     * 如果websocket调用失败,直接调用ActiveX控件,调用时与ActiveX控件接口名称相对应
165     * 如果通过websocket调用接口,接口名称与test.js的接口相对应即可
166     */
167    /**
168     * @return {string}
169     */
170    GetUSBKeyState:function(callback){
171        if(!FT.websock){
172            var ret = "" ;
173            try{
174                ret = document.getElementById("FTKeyCtrl").GetUSBKeyStat() ;
175            }catch(e){
176                YT.log.debug(e) ;
177            }
178            callback && callback(ret);
179        }
180        else{
181            FT.ctrl.GetUSBKeyStat(function(result, response) {
182                if (!result) {
183                    YT.log.debug("GetUSBKeyStat error. " + response);
184                    callback && callback("");
185                    return "";
186                }
187                else{
188                    FT.state = response ;
189                    callback && callback(response);
190
191                }
192            })
193        }
194        return FT.state ;
195    },
196    GetUSBKeyType:function(){
197        if(!FT.websock){
198            var ret = "" ;
199            try{
200                ret = document.getElementById("FTKeyCtrl").GetUSBKeyType() ;
201            }catch(e){
202                YT.log.debug(e) ;
203            }
204            callback && callback(ret);
205        }
206        else{
207            FT.ctrl.GetUSBKeyType(function(result, response) {
208                if (!result) {
209                    alert("GetUSBKeyType error. " + response);
210                    return;
211                }
212                else{
213                    rtn = response;
214                }
215            })
216        }
217        return rtn ;
218    },
219    GetUSBSN:function(callback){
220        if(!FT.websock){
221
222            var ret = "" ;
223            try{
224                ret = document.getElementById("FTKeyCtrl").GetSN() ;
225            }catch(e){
226                YT.log.debug(e) ;
227            }
228            callback && callback(ret);
229        }
230        else{
231            FT.ctrl.GetSN(function(result, response) {
232                if (!result) {
233                    YT.log.debug("GetSN error. " + response);
234                    callback && callback("");
235                }
236                else{
237                    callback && callback(response);
238                }
239            })
240        }
241    },
242    initUSBKey:function(callback){
243        if(!FT.websock){
244            var ret = "" ;
245            try{
246                ret = document.getElementById("FTKeyCtrl").InitUSBKey() ;
247            }catch(e){
248                YT.log.debug(e) ;
249            }
250            callback && callback(ret);
251        }
252        else{
253            FT.ctrl.InitUSBKey(function(result, response) {
254                if (!result) {
255                    YT.log.debug("InitUSBKey error. " + response);
256                    callback && callback("");
257                }
258                else{
259                    callback && callback(response);
260                }
261            })
262        }
263    }
264};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.