Procházet zdrojové kódy

新政脚本编辑器monaco

huqi před 5 roky
rodič
revize
4bf4de0907

+ 54 - 11
o2web/source/o2_core/o2/widget/JavascriptEditor.js

@@ -13,7 +13,7 @@ o2.widget.JavascriptEditor = new Class({
 			mode: "javascript",
 			mode: "javascript",
 			"lineNumbers": true
 			"lineNumbers": true
 		},
 		},
-		"runtime": "web"
+		"runtime": "all"
 	},
 	},
 	initialize: function(node, options){
 	initialize: function(node, options){
 		this.setOptions(options);
 		this.setOptions(options);
@@ -536,6 +536,7 @@ o2.widget.JavascriptEditor = new Class({
 
 
 o2.widget.JavascriptEditor.runtimeEnvironment = {};
 o2.widget.JavascriptEditor.runtimeEnvironment = {};
 o2.widget.JavascriptEditor.getCompletionEnvironment = function(runtime, callback) {
 o2.widget.JavascriptEditor.getCompletionEnvironment = function(runtime, callback) {
+    debugger;
     if (!o2.widget.JavascriptEditor.runtimeEnvironment[runtime]) {
     if (!o2.widget.JavascriptEditor.runtimeEnvironment[runtime]) {
         o2.require("o2.xScript.Macro", function() {
         o2.require("o2.xScript.Macro", function() {
             switch (runtime) {
             switch (runtime) {
@@ -545,6 +546,9 @@ o2.widget.JavascriptEditor.getCompletionEnvironment = function(runtime, callback
                 case "server":
                 case "server":
                     o2.widget.JavascriptEditor.getServerCompletionEnvironment(runtime,callback);
                     o2.widget.JavascriptEditor.getServerCompletionEnvironment(runtime,callback);
                     break;
                     break;
+                case "all":
+                    o2.widget.JavascriptEditor.getAllCompletionEnvironment(runtime,callback);
+                    break;
                 default:
                 default:
                     o2.widget.JavascriptEditor.getDefaultCompletionEnvironment(runtime,callback);
                     o2.widget.JavascriptEditor.getDefaultCompletionEnvironment(runtime,callback);
             }
             }
@@ -589,19 +593,37 @@ o2.widget.JavascriptEditor.getServiceCompletionEnvironment = function(runtime, c
 };
 };
 
 
 o2.widget.JavascriptEditor.getServerCompletionEnvironment = function(runtime, callback) {
 o2.widget.JavascriptEditor.getServerCompletionEnvironment = function(runtime, callback) {
-    o2.xhr_get("../x_desktop/js/initialScriptText.js", function (xhr) {
-        var code = "o2.Macro.swapSpace.tmpMacroCompletionFunction = function (){\n" + xhr.responseText + "\nreturn bind;" + "\n};";
-        Browser.exec(code);
-        var ev = o2.Macro.swapSpace.tmpMacroCompletionFunction();
-        o2.widget.JavascriptEditor.runtimeEnvironment[runtime] = {
-            "environment": ev,
-            exec: function(code){
-                return o2.Macro.exec(code, this.environment);
+    var serverScriptText = null;
+    var serverScriptSubstitute = null;
+    var check = function () {
+        if (o2.typeOf(serverScriptText) !== "null" && o2.typeOf(serverScriptSubstitute) !== "null") {
+            var code = "o2.Macro.swapSpace.tmpMacroCompletionFunction = function (){\n" + serverScriptSubstitute + "\n" + serverScriptText + "\nreturn bind;" + "\n};";
+            Browser.exec(code);
+            var ev = o2.Macro.swapSpace.tmpMacroCompletionFunction();
+            o2.widget.JavascriptEditor.runtimeEnvironment[runtime] = {
+                "environment": ev,
+                exec: function(code){
+                    return o2.Macro.exec(code, this.environment);
+                }
             }
             }
+            if (callback) callback();
         }
         }
-        if (callback) callback();
-    }.bind(this), false);
+    }
 
 
+    o2.xhr_get("../x_desktop/js/initialScriptText.js", function (xhr) {
+        serverScriptText = xhr.responseText;
+        check();
+    }, function () {
+        serverScriptText = "";
+        check();
+    });
+    o2.xhr_get("../x_desktop/js/initalScriptSubstitute.js", function (xhr) {
+        serverScriptSubstitute = xhr.responseText;
+        check();
+    }, function () {
+        serverScriptSubstitute = "";
+        check();
+    });
 };
 };
 
 
 o2.widget.JavascriptEditor.getDefaultCompletionEnvironment = function(runtime, callback){
 o2.widget.JavascriptEditor.getDefaultCompletionEnvironment = function(runtime, callback){
@@ -611,4 +633,25 @@ o2.widget.JavascriptEditor.getDefaultCompletionEnvironment = function(runtime, c
         o2.widget.JavascriptEditor.runtimeEnvironment[runtime] = new o2.Macro.FormContext(json);
         o2.widget.JavascriptEditor.runtimeEnvironment[runtime] = new o2.Macro.FormContext(json);
         if (callback) callback();
         if (callback) callback();
     });
     });
+}
+
+o2.widget.JavascriptEditor.getAllCompletionEnvironment = function(runtime, callback){
+    var check = function(){
+        if (o2.widget.JavascriptEditor.runtimeEnvironment["service"] && o2.widget.JavascriptEditor.runtimeEnvironment["server"] && o2.widget.JavascriptEditor.runtimeEnvironment["web"] ){
+            var ev = Object.merge(o2.widget.JavascriptEditor.runtimeEnvironment["service"].environment,
+                o2.widget.JavascriptEditor.runtimeEnvironment["server"].environment,
+                o2.widget.JavascriptEditor.runtimeEnvironment["web"].environment)
+            o2.widget.JavascriptEditor.runtimeEnvironment[runtime] = {
+                "environment": ev,
+                exec: function(code){
+                    return o2.Macro.exec(code, this.environment);
+                }
+            }
+            if (callback) callback();
+        }
+    }
+    o2.widget.JavascriptEditor.getServiceCompletionEnvironment("service", check);
+    o2.widget.JavascriptEditor.getServerCompletionEnvironment("server", check);
+    o2.widget.JavascriptEditor.getDefaultCompletionEnvironment("web", check);
+
 }
 }

+ 2 - 0
o2web/source/o2_core/o2/widget/ScriptArea.js

@@ -12,6 +12,7 @@ o2.widget.ScriptArea = new Class({
         "isload": false,
         "isload": false,
         "isbind": true,
         "isbind": true,
         "mode": "javascript",
         "mode": "javascript",
+        "runtime": "all",
         "key": "code"
         "key": "code"
     },
     },
     initialize: function(node, options){
     initialize: function(node, options){
@@ -185,6 +186,7 @@ o2.widget.ScriptArea = new Class({
         var value=(content) ? content.code : "";
         var value=(content) ? content.code : "";
         value = (value) ? value : "";
         value = (value) ? value : "";
         this.jsEditor = new o2.widget.JavascriptEditor(this.contentNode,{
         this.jsEditor = new o2.widget.JavascriptEditor(this.contentNode,{
+            "runtime": this.options.runtime || "all",
             "option": {
             "option": {
                 "value": value,
                 "value": value,
                 "lineNumbers": false,
                 "lineNumbers": false,

+ 1 - 1
o2web/source/o2_core/o2/xScript/Environment.js

@@ -945,7 +945,7 @@ MWF.xScript.Environment = function(ev){
 
 
     //仅前台对象-----------------------------------------
     //仅前台对象-----------------------------------------
     //form
     //form
-    this.form = {
+    this.page = this.form = {
         "getInfor": function(){return ev.formInfor;},
         "getInfor": function(){return ev.formInfor;},
         "infor": ev.formInfor,
         "infor": ev.formInfor,
         "getApp": function(){return _form.app;},
         "getApp": function(){return _form.app;},

+ 2 - 1
o2web/source/x_component_process_FormDesigner/Property.js

@@ -1440,7 +1440,8 @@ debugger;
                     "onSave": function(){
                     "onSave": function(){
                         this.designer.saveForm();
                         this.designer.saveForm();
                     }.bind(this),
                     }.bind(this),
-                    "style": style || "default"
+                    "style": style || "default",
+                    "runtime": "web"
                 });
                 });
                 scriptArea.load(scriptContent);
                 scriptArea.load(scriptContent);
             }.bind(this));
             }.bind(this));

+ 2 - 1
o2web/source/x_component_process_ProcessDesigner/widget/ScriptText.js

@@ -54,6 +54,7 @@ MWF.xApplication.process.ProcessDesigner.widget.ScriptText = new Class({
         }
         }
         MWF.require("MWF.widget.JavascriptEditor", function(){
         MWF.require("MWF.widget.JavascriptEditor", function(){
             this.editor = new MWF.widget.JavascriptEditor(this.editorNode, {
             this.editor = new MWF.widget.JavascriptEditor(this.editorNode, {
+                "runtime": "server",
                 "option": {"value": this.code},
                 "option": {"value": this.code},
                 "onSave": function(){
                 "onSave": function(){
                     var value = this.editor.getValue();
                     var value = this.editor.getValue();
@@ -148,7 +149,7 @@ MWF.xApplication.process.ProcessDesigner.widget.ScriptText = new Class({
         var size = this.areaNode.getSize();
         var size = this.areaNode.getSize();
         var y = size.y-20;
         var y = size.y-20;
         this.editorNode.setStyle("height", ""+y+"px");
         this.editorNode.setStyle("height", ""+y+"px");
-        if (this.editor.editor) this.editor.editor.resize();
+        if (this.editor) this.editor.resize();
     },
     },
 
 
     returnSize: function(){
     returnSize: function(){

+ 2 - 1
o2web/source/x_component_query_StatementDesigner/Property.js

@@ -661,7 +661,8 @@ MWF.xApplication.query.TableDesigner.Property = MWF.FTProperty = new Class({
                     "onSave": function(){
                     "onSave": function(){
                         this.designer.saveView();
                         this.designer.saveView();
                     }.bind(this),
                     }.bind(this),
-                    "style": style || "default"
+                    "style": style || "default",
+                    "runtime": "server"
                 });
                 });
                 scriptArea.load({"code": scriptContent});
                 scriptArea.load({"code": scriptContent});
             }.bind(this));
             }.bind(this));

+ 2 - 1
o2web/source/x_component_query_ViewDesigner/Property.js

@@ -370,7 +370,8 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
                     "onSave": function(){
                     "onSave": function(){
                         this.designer.saveView();
                         this.designer.saveView();
                     }.bind(this),
                     }.bind(this),
-                    "style": style || "default"
+                    "style": style || "default",
+                    "runtime": "server"
                 });
                 });
                 scriptArea.load({"code": scriptContent});
                 scriptArea.load({"code": scriptContent});
             }.bind(this));
             }.bind(this));

+ 10 - 0
o2web/source/x_desktop/js/initalScriptSubstitute.js

@@ -0,0 +1,10 @@
+var organization = this.organization = {
+        group: function(){ return {}; },
+        identity: function(){ return {}; },
+        person: function(){ return {}; },
+        personAttribute: function(){ return {}; },
+        role: function(){ return {}; },
+        unit: function(){ return {}; },
+        unitAttribute: function(){ return {}; },
+        unitDuty: function(){ return {}; }
+};