ScriptLib.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var scriptCodeText = "";
top.scriptCodeFun = function(){
return scriptCodeText;
};
function ScriptLib(){
this.pageUrl = "/mobilemode/scriptlib/ScriptCenter.jsp";
}
ScriptLib.prototype.addScriptToField = function(selector, callbackFn){
var $target = null;
if(typeof selector === "string"){
$target = $(selector);
}else if(selector instanceof jQuery){
$target = selector;
}else{
$target = $(selector);
}
var v = $target.val();
this.openWindow(v, function(result){
var scriptCode = result["scriptCode"];
$target[0].value = scriptCode;
if(typeof(callbackFn) == "function"){
callbackFn.call(this, scriptCode);
}
});
};
ScriptLib.prototype.openWindow = function(value, callbackFn){
scriptCodeText = value;
var url = this.pageUrl;
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.normalDialog = false;
dlg.Width = 800;//定义长度
dlg.Height = 500;
dlg.URL = url;
dlg.Title = SystemEnv.getHtmlNoteName(4182); //脚本库
dlg.show();
dlg.hookFn = function(result){
callbackFn.call(this, result);
};
};
function SL_AddScriptToField(selector, callbackFn){
var sl = new ScriptLib();
sl.addScriptToField(selector, callbackFn);
}