| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- MWF.xScript = MWF.xScript || {};
- MWF.xScript.Macro = MWF.Macro = {
- "swapSpace": {},
-
- expression: function(code, bind){},
- runEvent: function(code, bind, arg){},
-
- exec: function(code, bind){
- var returnValue;
- //try{
- if (!bind) bind = window;
- if (o2.session.isDebugger){
- try {
- var f = eval("(function(){return function(){\n"+code+"\n}})();");
- returnValue = f.apply(bind);
- }catch(e){
- console.log(o2.LP.script.error);
- if (code.length>500){
- var t = code.substr(0,500)+"\n...\n";
- console.log(t);
- }else{
- console.log(code);
- }
- console.log(e);
- //throw e;
- }
- }else{
- try {
- var f = eval("(function(){return function(){\n"+code+"\n}})();");
- returnValue = f.apply(bind);
- }catch(e){
- console.log(o2.LP.script.error);
- if (code.length>500){
- var t = code.substr(0,500)+"\n...\n";
- console.log(t);
- }else{
- console.log(code);
- }
- console.log(e);
- //throw e;
- }
- }
- //}catch(e){}//
- // var macroCode = "MWF.Macro.swapSpace.tmpMacroFunction = function (){"+code+"};";
- // Browser.exec(macroCode);
- // var returnValue;
- // if (!bind) bind = window;
- //// try {
- // returnValue = MWF.Macro.swapSpace.tmpMacroFunction.apply(bind);
- //// }catch(e){};
- return returnValue;
- }
- };
- MWF.Macro.FormContext = new Class({
- macroFunction: null,
- environment: {},
- initialize: function(form){
- this.form = form;
- var environment = {
- "form": form,
- "forms": form.forms,
- "all": form.all,
- "data": form.businessData.data,
- "work": form.businessData.work,
- "workCompleted": form.businessData.workCompleted,
- "taskList": form.businessData.taskList,
- "readList": form.businessData.readList,
- "control": form.businessData.control,
- "activity": form.businessData.activity,
- "task": form.businessData.task,
- "taskCompletedList": form.businessData.taskCompletedList,
- "workLogList": form.businessData.workLogList,
- "recordList": form.businessData.recordList,
- "attachmentList": form.businessData.attachmentList,
- "inheritedAttachmentList": form.businessData.inheritedAttachmentList,
- "formInfor": form.businessData.formInfor,
- "status": form.businessData.status,
- "target": null,
- "event": null
- };
- MWF.require("MWF.xScript.Environment", null, false);
- this.environment = new MWF.xScript.Environment(environment);
- },
- setTarget: function(target){
- if (target){
- this.environment.target = target;
- }else{
- this.environment.target = null;
- }
- },
- setEvent: function(event){
- if (event){
- this.environment.event = event;
- }else{
- this.environment.event = null;
- }
- },
- exec: function(code, target){
- this.setTarget(target);
- var returnValue = MWF.Macro.exec(code, this.environment);
- //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
- return returnValue;
- //this.environment.data
- },
- fire: function(code, target, event){
- this.setTarget(target);
- this.setEvent(event);
- return MWF.Macro.exec(code, this.environment);
- }
- });
- MWF.Macro.PageContext = new Class({
- macroFunction: null,
- environment: {},
- initialize: function(page){
- this.form = page;
- var environment = {
- "form": page,
- "forms": page.forms,
- "all": page.all,
- "data": page.businessData.data,
- "status": page.businessData.status,
- "pageInfor": page.businessData.pageInfor,
- "target": null,
- "event": null
- };
- MWF.require("MWF.xScript.PageEnvironment", null, false);
- this.environment = new MWF.xScript.PageEnvironment(environment);
- },
- setTarget: function(target){
- if (target){
- this.environment.target = target;
- }else{
- this.environment.target = null;
- }
- },
- setEvent: function(event){
- if (event){
- this.environment.event = event;
- }else{
- this.environment.event = null;
- }
- },
- exec: function(code, target){
- this.setTarget(target);
- var returnValue = MWF.Macro.exec(code, this.environment);
- //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
- return returnValue;
- //this.environment.data
- },
- fire: function(code, target, event){
- this.setTarget(target);
- this.setEvent(event);
- return MWF.Macro.exec(code, this.environment);
- }
- });
- if( !MWF.Macro.ViewContext ) {
- MWF.Macro.ViewContext = new Class({
- macroFunction: null,
- environment: {},
- initialize: function (view) {
- this.form = view;
- var environment = {
- "view": view,
- "viewInfor": view.viewInfor,
- "target": null,
- "event": null
- };
- MWF.require("MWF.xScript.ViewEnvironment", null, false);
- this.environment = new MWF.xScript.ViewEnvironment(environment);
- },
- setTarget: function (target) {
- if (target) {
- this.environment.target = target;
- } else {
- this.environment.target = null;
- }
- },
- setEvent: function (event) {
- if (event) {
- this.environment.event = event;
- } else {
- this.environment.event = null;
- }
- },
- exec: function (code, target) {
- this.setTarget(target);
- var returnValue = MWF.Macro.exec(code, this.environment);
- //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
- return returnValue;
- //this.environment.data
- },
- fire: function (code, target, event) {
- this.setTarget(target);
- this.setEvent(event);
- return MWF.Macro.exec(code, this.environment);
- }
- });
- }
- JSONObject = function(o){
- };
|