initialScriptText.js 123 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347
  1. var GLOBAL_ITEMS=function(){var t=[];for(var e in this)t.push(e);return t}();!function(){this.MooTools={version:"1.5.0dev",build:"%build%"};var t=this.typeOf=function(t){if(null==t)return"null";if(null!=t.$family)return t.$family();if(t.nodeName){if(1==t.nodeType)return"element";if(3==t.nodeType)return/\S/.test(t.nodeValue)?"textnode":"whitespace"}else if("number"==typeof t.length){if(t.callee)return"arguments";if("item"in t)return"collection"}return typeof t},e=(this.instanceOf=function(t,e){if(null==t)return!1;for(var n=t.$constructor||t.constructor;n;){if(n===e)return!0;n=n.parent}return!!t.hasOwnProperty&&t instanceof e},this.Function),n=!0;for(var r in{toString:1})n=null;n&&(n=["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"]),e.prototype.overloadSetter=function(t){var e=this;return function(r,i){if(null==r)return this;if(t||"string"!=typeof r){for(var a in r)e.call(this,a,r[a]);if(n)for(var o=n.length;o--;)a=n[o],r.hasOwnProperty(a)&&e.call(this,a,r[a])}else e.call(this,r,i);return this}},e.prototype.overloadGetter=function(t){var e=this;return function(n){var r,i;if("string"!=typeof n?r=n:arguments.length>1?r=arguments:t&&(r=[n]),r){i={};for(var a=0;a<r.length;a++)i[r[a]]=e.call(this,r[a])}else i=e.call(this,n);return i}},e.prototype.extend=function(t,e){this[t]=e}.overloadSetter(),e.prototype.implement=function(t,e){this.prototype[t]=e}.overloadSetter();var i=Array.prototype.slice;e.from=function(e){return"function"==t(e)?e:function(){return e}},e.convert=e.from,Array.from=function(e){return null==e?[]:a.isEnumerable(e)&&"string"!=typeof e?"array"==t(e)?e:i.call(e):[e]},Array.convert=Array.from,Number.from=function(t){var e=parseFloat(t);return isFinite(e)?e:null},Number.convert=Number.from,String.from=function(t){return t+""},String.convert=String.from,e.implement({hide:function(){return this.$hidden=!0,this},protect:function(){return this.$protected=!0,this}});var a=this.Type=function(e,n){if(e){var r=e.toLowerCase();a["is"+e]=function(e){return t(e)==r},null!=n&&(n.prototype.$family=function(){return r}.hide())}return null==n?null:(n.extend(this),n.$constructor=a,n.prototype.$constructor=n,n)},o=Object.prototype.toString;a.isEnumerable=function(t){return null!=t&&"number"==typeof t.length&&"[object Function]"!=o.call(t)};var s={},u=function(e){var n=t(e.prototype);return s[n]||(s[n]=[])},c=function(e,n){if(!n||!n.$hidden){for(var r=u(this),a=0;a<r.length;a++){var o=r[a];"type"==t(o)?c.call(o,e,n):o.call(this,e,n)}var s=this.prototype[e];null!=s&&s.$protected||(this.prototype[e]=n),null==this[e]&&"function"==t(n)&&l.call(this,e,(function(t){return n.apply(t,i.call(arguments,1))}))}},l=function(t,e){if(!e||!e.$hidden){var n=this[t];null!=n&&n.$protected||(this[t]=e)}};a.implement({implement:c.overloadSetter(),extend:l.overloadSetter(),alias:function(t,e){c.call(this,t,this.prototype[e])}.overloadSetter(),mirror:function(t){return u(this).push(t),this}}),new a("Type",a);var h=function(t,e,n){var r=e!=Object,i=e.prototype;r&&(e=new a(t,e));for(var o=0,s=n.length;o<s;o++){var u=n[o],c=e[u],l=i[u];c&&c.protect(),r&&l&&e.implement(u,l.protect())}if(r){var f=i.propertyIsEnumerable(n[0]);e.forEachMethod=function(t){if(!f)for(var e=0,r=n.length;e<r;e++)t.call(i,i[n[e]],n[e]);for(var a in i)t.call(i,i[a],a)}}return h};h("String",String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","quote","replace","search","slice","split","substr","substring","trim","toLowerCase","toUpperCase"])("Array",Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"])("Number",Number,["toExponential","toFixed","toLocaleString","toPrecision"])("Function",e,["apply","call","bind"])("RegExp",RegExp,["exec","test"])("Object",Object,["create","defineProperty","defineProperties","keys","getPrototypeOf","getOwnPropertyDescriptor","getOwnPropertyNames","preventExtensions","isExtensible","seal","isSealed","freeze","isFrozen"])("Date",Date,["now"]),Object.extend=l.overloadSetter(),Date.extend("now",(function(){return+new Date})),new a("Boolean",Boolean),Number.prototype.$family=function(){return isFinite(this)?"number":"null"}.hide(),Number.extend("random",(function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}));var f=Object.prototype.hasOwnProperty;Object.extend("forEach",(function(t,e,n){for(var r in t)f.call(t,r)&&e.call(n,t[r],r,t)})),Object.each=Object.forEach,Array.implement({forEach:function(t,e){for(var n=0,r=this.length;n<r;n++)n in this&&t.call(e,this[n],n,this)},each:function(t,e){return Array.forEach(this,t,e),this}});var d=function(e){switch(t(e)){case"array":return e.clone();case"object":return Object.clone(e);default:return e}};Array.implement("clone",(function(){for(var t=this.length,e=new Array(t);t--;)e[t]=d(this[t]);return e}));var g=function(e,n,r){switch(t(r)){case"object":"object"==t(e[n])?Object.merge(e[n],r):e[n]=Object.clone(r);break;case"array":e[n]=r.clone();break;default:e[n]=r}return e};Object.extend({merge:function(e,n,r){if("string"==t(n))return g(e,n,r);for(var i=1,a=arguments.length;i<a;i++){var o=arguments[i];for(var s in o)g(e,s,o[s])}return e},clone:function(t){var e={};for(var n in t)e[n]=d(t[n]);return e},append:function(t){for(var e=1,n=arguments.length;e<n;e++){var r=arguments[e]||{};for(var i in r)t[i]=r[i]}return t}}),["Object","WhiteSpace","TextNode","Collection","Arguments"].each((function(t){new a(t)}));var p=Date.now();String.extend("uniqueID",(function(){return(p++).toString(36)}))}(),Array.implement({every:function(t,e){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&!t.call(e,this[n],n,this))return!1;return!0},filter:function(t,e){for(var n,r=[],i=0,a=this.length>>>0;i<a;i++)i in this&&(n=this[i],t.call(e,n,i,this)&&r.push(n));return r},indexOf:function(t,e){for(var n=this.length>>>0,r=e<0?Math.max(0,n+e):e||0;r<n;r++)if(this[r]===t)return r;return-1},map:function(t,e){for(var n=this.length>>>0,r=Array(n),i=0;i<n;i++)i in this&&(r[i]=t.call(e,this[i],i,this));return r},some:function(t,e){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&t.call(e,this[n],n,this))return!0;return!1},clean:function(){return this.filter((function(t){return null!=t}))},invoke:function(t){var e=Array.slice(arguments,1);return this.map((function(n){return n[t].apply(n,e)}))},associate:function(t){for(var e={},n=Math.min(this.length,t.length),r=0;r<n;r++)e[t[r]]=this[r];return e},link:function(t){for(var e={},n=0,r=this.length;n<r;n++)for(var i in t)if(t[i](this[n])){e[i]=this[n],delete t[i];break}return e},contains:function(t,e){return-1!=this.indexOf(t,e)},append:function(t){return this.push.apply(this,t),this},getLast:function(){return this.length?this[this.length-1]:null},getRandom:function(){return this.length?this[Number.random(0,this.length-1)]:null},include:function(t){return this.contains(t)||this.push(t),this},combine:function(t){for(var e=0,n=t.length;e<n;e++)this.include(t[e]);return this},erase:function(t){for(var e=this.length;e--;)this[e]===t&&this.splice(e,1);return this},empty:function(){return this.length=0,this},flatten:function(){for(var t=[],e=0,n=this.length;e<n;e++){var r=typeOf(this[e]);"null"!=r&&(t=t.concat("array"==r||"collection"==r||"arguments"==r||instanceOf(this[e],Array)?Array.flatten(this[e]):this[e]))}return t},pick:function(){for(var t=0,e=this.length;t<e;t++)if(null!=this[t])return this[t];return null},hexToRgb:function(t){if(3!=this.length)return null;var e=this.map((function(t){return 1==t.length&&(t+=t),t.toInt(16)}));return t?e:"rgb("+e+")"},rgbToHex:function(t){if(this.length<3)return null;if(4==this.length&&0==this[3]&&!t)return"transparent";for(var e=[],n=0;n<3;n++){var r=(this[n]-0).toString(16);e.push(1==r.length?"0"+r:r)}return t?e:"#"+e.join("")}}),String.implement({test:function(t,e){return("regexp"==typeOf(t)?t:new RegExp(""+t,e)).test(this)},contains:function(t,e){return e?(e+this+e).indexOf(e+t+e)>-1:String(this).indexOf(t)>-1},trim:function(){return String(this).replace(/^\s+|\s+$/g,"")},clean:function(){return String(this).replace(/\s+/g," ").trim()},camelCase:function(){return String(this).replace(/-\D/g,(function(t){return t.charAt(1).toUpperCase()}))},hyphenate:function(){return String(this).replace(/[A-Z]/g,(function(t){return"-"+t.charAt(0).toLowerCase()}))},capitalize:function(){return String(this).replace(/\b[a-z]/g,(function(t){return t.toUpperCase()}))},escapeRegExp:function(){return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},toInt:function(t){return parseInt(this,t||10)},toFloat:function(){return parseFloat(this)},hexToRgb:function(t){var e=String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return e?e.slice(1).hexToRgb(t):null},rgbToHex:function(t){var e=String(this).match(/\d{1,3}/g);return e?e.rgbToHex(t):null},substitute:function(t,e){return String(this).replace(e||/\\?\{([^{}]+)\}/g,(function(e,n){return"\\"==e.charAt(0)?e.slice(1):null!=t[n]?t[n]:""}))}}),Function.extend({attempt:function(){for(var t=0,e=arguments.length;t<e;t++)try{return arguments[t]()}catch(t){}return null}}),Function.implement({attempt:function(t,e){try{return this.apply(e,Array.from(t))}catch(t){}return null},bind:function(t){var e=this,n=arguments.length>1?Array.slice(arguments,1):null,r=function(){},i=function(){var a=t,o=arguments.length;this instanceof i&&(r.prototype=e.prototype,a=new r);var s=n||o?e.apply(a,n&&o?n.concat(Array.slice(arguments)):n||arguments):e.call(a);return a==t?s:a};return i},pass:function(t,e){var n=this;return null!=t&&(t=Array.from(t)),function(){return n.apply(e,t||arguments)}},delay:function(t,e,n){return setTimeout(this.pass(null==n?[]:n,e),t)},periodical:function(t,e,n){return setInterval(this.pass(null==n?[]:n,e),t)}}),Number.implement({limit:function(t,e){return Math.min(e,Math.max(t,this))},round:function(t){return t=Math.pow(10,t||0).toFixed(t<0?-t:0),Math.round(this*t)/t},times:function(t,e){for(var n=0;n<this;n++)t.call(e,n,this)},toFloat:function(){return parseFloat(this)},toInt:function(t){return parseInt(this,t||10)}}),Number.alias("each","times"),function(t){var e={};["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"].each((function(t){Number[t]||(e[t]=function(){return Math[t].apply(null,[this].concat(Array.from(arguments)))})})),Number.implement(e)}(),function(){var t=this.Class=new Type("Class",(function(r){instanceOf(r,Function)&&(r={initialize:r});var i=function(){if(n(this),i.$prototyping)return this;this.$caller=null;var t=this.initialize?this.initialize.apply(this,arguments):this;return this.$caller=this.caller=null,t}.extend(this).implement(r);return i.$constructor=t,i.prototype.$constructor=i,i.prototype.parent=e,i})),e=function(){if(!this.$caller)throw new Error('The method "parent" cannot be called.');var t=this.$caller.$name,e=this.$caller.$owner.parent,n=e?e.prototype[t]:null;if(!n)throw new Error('The method "'+t+'" has no parent.');return n.apply(this,arguments)},n=function(t){for(var e in t){var r=t[e];switch(typeOf(r)){case"object":var i=function(){};i.prototype=r,t[e]=n(new i);break;case"array":t[e]=r.clone()}}return t},r=function(e,n,r){if(t.Mutators.hasOwnProperty(e)&&null==(n=t.Mutators[e].call(this,n)))return this;if("function"==typeOf(n)){if(n.$hidden)return this;this.prototype[e]=r?n:function(t,e,n){n.$origin&&(n=n.$origin);var r=function(){if(n.$protected&&null==this.$caller)throw new Error('The method "'+e+'" cannot be called.');var t=this.caller,i=this.$caller;this.caller=i,this.$caller=r;var a=n.apply(this,arguments);return this.$caller=i,this.caller=t,a}.extend({$owner:t,$origin:n,$name:e});return r}(this,e,n)}else Object.merge(this.prototype,e,n);return this};t.implement("implement",r.overloadSetter()),t.Mutators={Extends:function(t){this.parent=t,this.prototype=function(t){t.$prototyping=!0;var e=new t;return delete t.$prototyping,e}(t)},Implements:function(t){Array.from(t).each((function(t){var e=new t;for(var n in e)r.call(this,n,e[n],!0)}),this)}}}(),function(){this.Chain=new Class({$chain:[],chain:function(){return this.$chain.append(Array.flatten(arguments)),this},callChain:function(){return!!this.$chain.length&&this.$chain.shift().apply(this,arguments)},clearChain:function(){return this.$chain.empty(),this}});var t=function(t){return t.replace(/^on([A-Z])/,(function(t,e){return e.toLowerCase()}))};this.Events=new Class({$events:{},addEvent:function(e,n,r){return e=t(e),this.$events[e]=(this.$events[e]||[]).include(n),r&&(n.internal=!0),this},addEvents:function(t){for(var e in t)this.addEvent(e,t[e]);return this},fireEvent:function(e,n,r){e=t(e);var i=this.$events[e];return i?(n=Array.from(n),i.each((function(t){r?t.delay(r,this,n):t.apply(this,n)}),this),this):this},removeEvent:function(e,n){e=t(e);var r=this.$events[e];if(r&&!n.internal){var i=r.indexOf(n);-1!=i&&delete r[i]}return this},removeEvents:function(e){var n;if("object"==typeOf(e)){for(n in e)this.removeEvent(n,e[n]);return this}for(n in e&&(e=t(e)),this.$events)if(!e||e==n)for(var r=this.$events[n],i=r.length;i--;)i in r&&this.removeEvent(n,r[i]);return this}}),this.Options=new Class({setOptions:function(){var t=this.options=Object.merge.apply(null,[{},this.options].append(arguments));if(this.addEvent)for(var e in t)"function"==typeOf(t[e])&&/^on[A-Z]/.test(e)&&(this.addEvent(e,t[e]),delete t[e]);return this}})}(),function(){var t=Object.prototype.hasOwnProperty;Object.extend({subset:function(t,e){for(var n={},r=0,i=e.length;r<i;r++){var a=e[r];a in t&&(n[a]=t[a])}return n},map:function(e,n,r){var i={};for(var a in e)t.call(e,a)&&(i[a]=n.call(r,e[a],a,e));return i},filter:function(e,n,r){var i={};for(var a in e){var o=e[a];t.call(e,a)&&n.call(r,o,a,e)&&(i[a]=o)}return i},every:function(e,n,r){for(var i in e)if(t.call(e,i)&&!n.call(r,e[i],i))return!1;return!0},some:function(e,n,r){for(var i in e)if(t.call(e,i)&&n.call(r,e[i],i))return!0;return!1},keys:function(e){var n=[];for(var r in e)t.call(e,r)&&n.push(r);return n},values:function(e){var n=[];for(var r in e)t.call(e,r)&&n.push(e[r]);return n},getLength:function(t){return Object.keys(t).length},keyOf:function(e,n){for(var r in e)if(t.call(e,r)&&e[r]===n)return r;return null},contains:function(t,e){return null!=Object.keyOf(t,e)},toQueryString:function(t,e){var n=[];return Object.each(t,(function(t,r){var i;switch(e&&(r=e+"["+r+"]"),typeOf(t)){case"object":i=Object.toQueryString(t,r);break;case"array":var a={};t.each((function(t,e){a[e]=t})),i=Object.toQueryString(a,r);break;default:i=r+"="+encodeURIComponent(t)}null!=t&&n.push(i)})),n.join("&")}})}(),"undefined"!=typeof exports&&function(){for(var t in this)GLOBAL_ITEMS.contains(t)||(exports[t]=this[t]);exports.apply=function(t){Object.append(t,exports)}}(),MooTools.More={version:"1.6.1-dev",build:"%build%"},function(){var t=function(t){return null!=t},e=Object.prototype.hasOwnProperty;Object.extend({getFromPath:function(t,n){"string"==typeof n&&(n=n.split("."));for(var r=0,i=n.length;r<i;r++){if(!e.call(t,n[r]))return null;t=t[n[r]]}return t},cleanValues:function(e,n){for(var r in n=n||t,e)n(e[r])||delete e[r];return e},erase:function(t,n){return e.call(t,n)&&delete t[n],t},run:function(t){var e=Array.slice(arguments,1);for(var n in t)t[n].apply&&t[n].apply(t,e);return t}})}(),function(){var t=null,e={},n=function(t){return instanceOf(t,r.Set)?t:e[t]},r=this.Locale={define:function(n,i,a,o){var s;return instanceOf(n,r.Set)?(s=n.name)&&(e[s]=n):(e[s=n]||(e[s]=new r.Set(s)),n=e[s]),i&&n.define(i,a,o),t||(t=n),n},use:function(e){return(e=n(e))&&(t=e,this.fireEvent("change",e)),this},getCurrent:function(){return t},get:function(e,n){return t?t.get(e,n):""},inherit:function(t,e,r){return(t=n(t))&&t.inherit(e,r),this},list:function(){return Object.keys(e)}};Object.append(r,new Events),r.Set=new Class({sets:{},inherits:{locales:[],sets:{}},initialize:function(t){this.name=t||""},define:function(t,e,n){var r=this.sets[t];return r||(r={}),e&&("object"==typeOf(e)?r=Object.merge(r,e):r[e]=n),this.sets[t]=r,this},get:function(t,n,r){var i=Object.getFromPath(this.sets,t);if(null!=i){var a=typeOf(i);return"function"==a?i=i.apply(null,Array.convert(n)):"object"==a&&(i=Object.clone(i)),i}var o=t.indexOf("."),s=o<0?t:t.substr(0,o),u=(this.inherits.sets[s]||[]).combine(this.inherits.locales).include("en-US");r||(r=[]);for(var c=0,l=u.length;c<l;c++)if(!r.contains(u[c])){r.include(u[c]);var h=e[u[c]];if(h&&null!=(i=h.get(t,n,r)))return i}return""},inherit:function(t,e){t=Array.convert(t),e&&!this.inherits.sets[e]&&(this.inherits.sets[e]=[]);for(var n=t.length;n--;)(e?this.inherits.sets[e]:this.inherits.locales).unshift(t[n]);return this}})}(),Locale.define("en-US","Date",{months:["January","February","March","April","May","June","July","August","September","October","November","December"],months_abbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],days_abbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dateOrder:["month","date","year"],shortDate:"%m/%d/%Y",shortTime:"%I:%M%p",AM:"AM",PM:"PM",firstDayOfWeek:0,ordinal:function(t){return t>3&&t<21?"th":["th","st","nd","rd","th"][Math.min(t%10,4)]},lessThanMinuteAgo:"less than a minute ago",minuteAgo:"about a minute ago",minutesAgo:"{delta} minutes ago",hourAgo:"about an hour ago",hoursAgo:"about {delta} hours ago",dayAgo:"1 day ago",daysAgo:"{delta} days ago",weekAgo:"1 week ago",weeksAgo:"{delta} weeks ago",monthAgo:"1 month ago",monthsAgo:"{delta} months ago",yearAgo:"1 year ago",yearsAgo:"{delta} years ago",lessThanMinuteUntil:"less than a minute from now",minuteUntil:"about a minute from now",minutesUntil:"{delta} minutes from now",hourUntil:"about an hour from now",hoursUntil:"about {delta} hours from now",dayUntil:"1 day from now",daysUntil:"{delta} days from now",weekUntil:"1 week from now",weeksUntil:"{delta} weeks from now",monthUntil:"1 month from now",monthsUntil:"{delta} months from now",yearUntil:"1 year from now",yearsUntil:"{delta} years from now"}),function(){var t=this.Date,e=t.Methods={ms:"Milliseconds",year:"FullYear",min:"Minutes",mo:"Month",sec:"Seconds",hr:"Hours"};["Date","Day","FullYear","Hours","Milliseconds","Minutes","Month","Seconds","Time","TimezoneOffset","Week","Timezone","GMTOffset","DayOfYear","LastMonth","LastDayOfMonth","UTCDate","UTCDay","UTCFullYear","AMPM","Ordinal","UTCHours","UTCMilliseconds","UTCMinutes","UTCMonth","UTCSeconds","UTCMilliseconds"].each((function(e){t.Methods[e.toLowerCase()]=e}));var n=function(t,e,r){return 1==e?t:t<Math.pow(10,e-1)?(r||"0")+n(t,e-1,r):t};t.implement({set:function(t,n){t=t.toLowerCase();var r=e[t]&&"set"+e[t];return r&&this[r]&&this[r](n),this}.overloadSetter(),get:function(t){t=t.toLowerCase();var n=e[t]&&"get"+e[t];return n&&this[n]?this[n]():null}.overloadGetter(),clone:function(){return new t(this.get("time"))},increment:function(e,n){switch(n=null!=n?n:1,e=e||"day"){case"year":return this.increment("month",12*n);case"month":var r=this.get("date");return this.set("date",1).set("mo",this.get("mo")+n),this.set("date",r.min(this.get("lastdayofmonth")));case"week":return this.increment("day",7*n);case"day":return this.set("date",this.get("date")+n)}if(!t.units[e])throw new Error(e+" is not a supported interval");return this.set("time",this.get("time")+n*t.units[e]())},decrement:function(t,e){return this.increment(t,-1*(null!=e?e:1))},isLeapYear:function(){return t.isLeapYear(this.get("year"))},clearTime:function(){return this.set({hr:0,min:0,sec:0,ms:0})},diff:function(e,n){return"string"==typeOf(e)&&(e=t.parse(e)),((e-this)/t.units[n||"day"](3,3)).round()},getLastDayOfMonth:function(){return t.daysInMonth(this.get("mo"),this.get("year"))},getDayOfYear:function(){return(t.UTC(this.get("year"),this.get("mo"),this.get("date")+1)-t.UTC(this.get("year"),0,1))/t.units.day()},setDay:function(e,n){null==n&&""===(n=t.getMsg("firstDayOfWeek"))&&(n=1),e=(7+t.parseDay(e,!0)-n)%7;var r=(7+this.get("day")-n)%7;return this.increment("day",e-r)},getWeek:function(e){null==e&&""===(e=t.getMsg("firstDayOfWeek"))&&(e=1);var n,r=this,i=(7+r.get("day")-e)%7,a=0;if(1==e){var o=r.get("month"),s=r.get("date")-i;if(11==o&&s>28)return 1;0==o&&s<-2&&(r=new t(r).decrement("day",i),i=0),(n=new t(r.get("year"),0,1).get("day")||7)>4&&(a=-7)}else n=new t(r.get("year"),0,1).get("day");return a+=r.get("dayofyear"),a+=6-i,(a+=(7+n-e)%7)/7},getOrdinal:function(e){return t.getMsg("ordinal",e||this.get("date"))},getTimezone:function(){return this.toString().replace(/^.*? ([A-Z]{3}).[0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3")},getGMTOffset:function(){var t=this.get("timezoneOffset");return(t>0?"-":"+")+n((t.abs()/60).floor(),2)+n(t%60,2)},setAMPM:function(t){t=t.toUpperCase();var e=this.get("hr");return e>11&&"AM"==t?this.decrement("hour",12):e<12&&"PM"==t?this.increment("hour",12):this},getAMPM:function(){return this.get("hr")<12?"AM":"PM"},parse:function(e){return this.set("time",t.parse(e)),this},isValid:function(t){return t||(t=this),"date"==typeOf(t)&&!isNaN(t.valueOf())},format:function(e){if(!this.isValid())return"invalid date";if(e||(e="%x %X"),"string"==typeof e&&(e=a[e.toLowerCase()]||e),"function"==typeof e)return e(this);var r=this;return e.replace(/%([a-z%])/gi,(function(e,i){switch(i){case"a":return t.getMsg("days_abbr")[r.get("day")];case"A":return t.getMsg("days")[r.get("day")];case"b":return t.getMsg("months_abbr")[r.get("month")];case"B":return t.getMsg("months")[r.get("month")];case"c":return r.format("%a %b %d %H:%M:%S %Y");case"d":return n(r.get("date"),2);case"e":return n(r.get("date"),2," ");case"H":return n(r.get("hr"),2);case"I":return n(r.get("hr")%12||12,2);case"j":return n(r.get("dayofyear"),3);case"k":return n(r.get("hr"),2," ");case"l":return n(r.get("hr")%12||12,2," ");case"L":return n(r.get("ms"),3);case"m":return n(r.get("mo")+1,2);case"M":return n(r.get("min"),2);case"o":return r.get("ordinal");case"p":return t.getMsg(r.get("ampm"));case"s":return Math.round(r/1e3);case"S":return n(r.get("seconds"),2);case"T":return r.format("%H:%M:%S");case"U":return n(r.get("week"),2);case"w":return r.get("day");case"x":return r.format(t.getMsg("shortDate"));case"X":return r.format(t.getMsg("shortTime"));case"y":return r.get("year").toString().substr(2);case"Y":return r.get("year");case"z":return r.get("GMTOffset");case"Z":return r.get("Timezone")}return i}))},toISOString:function(){return this.format("iso8601")}}).alias({toJSON:"toISOString",compare:"diff",strftime:"format"});var r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a={db:"%Y-%m-%d %H:%M:%S",compact:"%Y%m%dT%H%M%S",short:"%d %b %H:%M",long:"%B %d, %Y %H:%M",rfc822:function(t){return r[t.get("day")]+t.format(", %d ")+i[t.get("month")]+t.format(" %Y %H:%M:%S %Z")},rfc2822:function(t){return r[t.get("day")]+t.format(", %d ")+i[t.get("month")]+t.format(" %Y %H:%M:%S %z")},iso8601:function(t){return t.getUTCFullYear()+"-"+n(t.getUTCMonth()+1,2)+"-"+n(t.getUTCDate(),2)+"T"+n(t.getUTCHours(),2)+":"+n(t.getUTCMinutes(),2)+":"+n(t.getUTCSeconds(),2)+"."+n(t.getUTCMilliseconds(),3)+"Z"}},o=[],s=t.parse,u=function(e,n,r){var i=-1,a=t.getMsg(e+"s");switch(typeOf(n)){case"object":i=a[n.get(e)];break;case"number":if(!(i=a[n]))throw new Error("Invalid "+e+" index: "+n);break;case"string":var o=a.filter((function(t){return this.test(t)}),new RegExp("^"+n,"i"));if(!o.length)throw new Error("Invalid "+e+" string");if(o.length>1)throw new Error("Ambiguous "+e);i=o[0]}return r?a.indexOf(i):i},c=1900,l=70;t.extend({getMsg:function(t,e){return Locale.get("Date."+t,e)},units:{ms:Function.convert(1),second:Function.convert(1e3),minute:Function.convert(6e4),hour:Function.convert(36e5),day:Function.convert(864e5),week:Function.convert(6084e5),month:function(e,n){var r=new t;return 864e5*t.daysInMonth(null!=e?e:r.get("mo"),null!=n?n:r.get("year"))},year:function(e){return e=e||(new t).get("year"),t.isLeapYear(e)?316224e5:31536e6}},daysInMonth:function(e,n){return[31,t.isLeapYear(n)?29:28,31,30,31,30,31,31,30,31,30,31][e]},isLeapYear:function(t){return t%4==0&&t%100!=0||t%400==0},parse:function(e){var n,r=typeOf(e);return"number"==r?new t(e):"string"!=r?e:(e=e.clean()).length?(o.some((function(t){var r=t.re.exec(e);return!!r&&(n=t.handler(r))})),n&&n.isValid()||(n=new t(s(e)))&&n.isValid()||(n=new t(e.toInt())),n):null},parseDay:function(t,e){return u("day",t,e)},parseMonth:function(t,e){return u("month",t,e)},parseUTC:function(e){var n=new t(e),r=t.UTC(n.get("year"),n.get("mo"),n.get("date"),n.get("hr"),n.get("min"),n.get("sec"),n.get("ms"));return new t(r)},orderIndex:function(e){return t.getMsg("dateOrder").indexOf(e)+1},defineFormat:function(t,e){return a[t]=e,this},defineParser:function(t){return o.push(t.re&&t.handler?t:g(t)),this},defineParsers:function(){return Array.flatten(arguments).each(t.defineParser),this},define2DigitYearStart:function(t){return c=t-(l=t%100),this}}).extend({defineFormats:t.defineFormat.overloadSetter()});var h,f=function(e){return new RegExp("(?:"+t.getMsg(e).map((function(t){return t.substr(0,3)})).join("|")+")[a-z]*")},d={d:/[0-2]?[0-9]|3[01]/,H:/[01]?[0-9]|2[0-3]/,I:/0?[1-9]|1[0-2]/,M:/[0-5]?\d/,s:/\d+/,o:/[a-z]*/,p:/[ap]\.?m\.?/,y:/\d{2}|\d{4}/,Y:/\d{4}/,z:/Z|[+-]\d{2}(?::?\d{2})?/};d.m=d.I,d.S=d.M;var g=function(e){if(!h)return{format:e};var n=[],r=(e.source||e).replace(/%([a-z])/gi,(function(e,n){return function(e){switch(e){case"T":return"%H:%M:%S";case"x":return(1==t.orderIndex("month")?"%m[-./]%d":"%d[-./]%m")+"([-./]%y)?";case"X":return"%H([.:]%M)?([.:]%S([.:]%s)?)? ?%p? ?%z?"}return null}(n)||e})).replace(/\((?!\?)/g,"(?:").replace(/ (?!\?|\*)/g,",? ").replace(/%([a-z%])/gi,(function(t,e){var r=d[e];return r?(n.push(e),"("+r.source+")"):e})).replace(/\[a-z\]/gi,"[a-z\\u00c0-\\uffff;&]");return{format:e,re:new RegExp("^"+r+"$","i"),handler:function(e){e=e.slice(1).associate(n);var r=(new t).clearTime(),i=e.y||e.Y;for(var a in null!=i&&p.call(r,"y",i),"d"in e&&p.call(r,"d",1),("m"in e||e.b||e.B)&&p.call(r,"m",1),e)p.call(r,a,e[a]);return r}}},p=function(e,n){if(!n)return this;switch(e){case"a":case"A":return this.set("day",t.parseDay(n,!0));case"b":case"B":return this.set("mo",t.parseMonth(n,!0));case"d":return this.set("date",n);case"H":case"I":return this.set("hr",n);case"m":return this.set("mo",n-1);case"M":return this.set("min",n);case"p":return this.set("ampm",n.replace(/\./g,""));case"S":return this.set("sec",n);case"s":return this.set("ms",1e3*("0."+n));case"w":return this.set("day",n);case"Y":return this.set("year",n);case"y":return(n=+n)<100&&(n+=c+(n<l?100:0)),this.set("year",n);case"z":"Z"==n&&(n="+00");var r=n.match(/([+-])(\d{2}):?(\d{2})?/);return r=(r[1]+"1")*(60*r[2]+(+r[3]||0))+this.getTimezoneOffset(),this.set("time",this-6e4*r)}return this};t.defineParsers("%Y([-./]%m([-./]%d((T| )%X)?)?)?","%Y%m%d(T%H(%M%S?)?)?","%x( %X)?","%d%o( %b( %Y)?)?( %X)?","%b( %d%o)?( %Y)?( %X)?","%Y %b( %d%o( %X)?)?","%o %b %d %X %z %Y","%T","%H:%M( ?%p)?"),Locale.addEvent("change",(function(t){Locale.get("Date")&&function(t){h=t,d.a=d.A=f("days"),d.b=d.B=f("months"),o.each((function(t,e){t.format&&(o[e]=g(t.format))}))}(t)})).fireEvent("change",Locale.getCurrent())}(),Locale.define("zh-CHS","Date",{months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],months_abbr:["一","二","三","四","五","六","七","八","九","十","十一","十二"],days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],days_abbr:["日","一","二","三","四","五","六"],dateOrder:["year","month","date"],shortDate:"%Y-%m-%d",shortTime:"%I:%M%p",AM:"AM",PM:"PM",firstDayOfWeek:1,ordinal:"",lessThanMinuteAgo:"不到1分钟前",minuteAgo:"大约1分钟前",minutesAgo:"{delta}分钟之前",hourAgo:"大约1小时前",hoursAgo:"大约{delta}小时前",dayAgo:"1天前",daysAgo:"{delta}天前",weekAgo:"1星期前",weeksAgo:"{delta}星期前",monthAgo:"1个月前",monthsAgo:"{delta}个月前",yearAgo:"1年前",yearsAgo:"{delta}年前",lessThanMinuteUntil:"从现在开始不到1分钟",minuteUntil:"从现在开始約1分钟",minutesUntil:"从现在开始约{delta}分钟",hourUntil:"从现在开始1小时",hoursUntil:"从现在开始约{delta}小时",dayUntil:"从现在开始1天",daysUntil:"从现在开始{delta}天",weekUntil:"从现在开始1星期",weeksUntil:"从现在开始{delta}星期",monthUntil:"从现在开始一个月",monthsUntil:"从现在开始{delta}个月",yearUntil:"从现在开始1年",yearsUntil:"从现在开始{delta}年"}),Locale.define("zh-CHT","Date",{months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],months_abbr:["一","二","三","四","五","六","七","八","九","十","十一","十二"],days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],days_abbr:["日","一","二","三","四","五","六"],dateOrder:["year","month","date"],shortDate:"%Y-%m-%d",shortTime:"%I:%M%p",AM:"AM",PM:"PM",firstDayOfWeek:1,ordinal:"",lessThanMinuteAgo:"不到1分鐘前",minuteAgo:"大約1分鐘前",minutesAgo:"{delta}分鐘之前",hourAgo:"大約1小時前",hoursAgo:"大約{delta}小時前",dayAgo:"1天前",daysAgo:"{delta}天前",weekAgo:"1星期前",weeksAgo:"{delta}星期前",monthAgo:"1个月前",monthsAgo:"{delta}个月前",yearAgo:"1年前",yearsAgo:"{delta}年前",lessThanMinuteUntil:"從現在開始不到1分鐘",minuteUntil:"從現在開始約1分鐘",minutesUntil:"從現在開始約{delta}分鐘",hourUntil:"從現在開始1小時",hoursUntil:"從現在開始約{delta}小時",dayUntil:"從現在開始1天",daysUntil:"從現在開始{delta}天",weekUntil:"從現在開始1星期",weeksUntil:"從現在開始{delta}星期",monthUntil:"從現在開始一個月",monthsUntil:"從現在開始{delta}個月",yearUntil:"從現在開始1年",yearsUntil:"從現在開始{delta}年"}),"undefined"==typeof JSON&&(this.JSON={}),function(){var special={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},escape=function(t){return special[t]||"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)};JSON.validate=function(t){return t=t.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(t)},JSON.encode=JSON.stringify?function(t){return JSON.stringify(t)}:function(t){switch(t&&t.toJSON&&(t=t.toJSON()),typeOf(t)){case"string":return'"'+t.replace(/[\x00-\x1f\\"]/g,escape)+'"';case"array":return"["+t.map(JSON.encode).clean()+"]";case"object":case"hash":var e=[];return Object.each(t,(function(t,n){var r=JSON.encode(t);r&&e.push(JSON.encode(n)+":"+r)})),"{"+e+"}";case"number":case"boolean":return""+t;case"null":return"null"}return null},JSON.decode=function(string,secure){if(!string||"string"!=typeOf(string))return null;if(secure||JSON.secure){if(JSON.parse)return JSON.parse(string);if(!JSON.validate(string))throw new Error("JSON could not decode the input; security is enabled and the value is not secure.")}return eval("("+string+")")}}();
  2. //公用部分---------------------------------------------------------
  3. bind = this || {};
  4. function toJsJson(o){
  5. var type = typeOf(o);
  6. switch (type){
  7. case "array":
  8. o.each(function(item, idx){
  9. o[idx] = toJsJson(item);
  10. });
  11. return o;
  12. case "object":
  13. if (o.getClass){
  14. return JSON.parse(Java.type("com.x.base.core.project.gson.XGsonBuilder").toJson(o));
  15. }else{
  16. for (key in o){
  17. o[key] = toJsJson(o[key]);
  18. }
  19. }
  20. return o;
  21. default:
  22. return o;
  23. }
  24. }
  25. var library = {
  26. 'version': '4.0',
  27. "defineProperties": Object.defineProperties || function (obj, properties) {
  28. function convertToDescriptor(desc) {
  29. function hasProperty(obj, prop) {
  30. return Object.prototype.hasOwnProperty.call(obj, prop);
  31. }
  32. function isCallable(v) {
  33. // NB: modify as necessary if other values than functions are callable.
  34. return typeof v === "function";
  35. }
  36. if (typeof desc !== "object" || desc === null)
  37. throw new TypeError("bad desc");
  38. var d = {};
  39. if (hasProperty(desc, "enumerable"))
  40. d.enumerable = !!obj.enumerable;
  41. if (hasProperty(desc, "configurable"))
  42. d.configurable = !!obj.configurable;
  43. if (hasProperty(desc, "value"))
  44. d.value = obj.value;
  45. if (hasProperty(desc, "writable"))
  46. d.writable = !!desc.writable;
  47. if (hasProperty(desc, "get")) {
  48. var g = desc.get;
  49. if (!isCallable(g) && typeof g !== "undefined")
  50. throw new TypeError("bad get");
  51. d.get = g;
  52. }
  53. if (hasProperty(desc, "set")) {
  54. var s = desc.set;
  55. if (!isCallable(s) && typeof s !== "undefined")
  56. throw new TypeError("bad set");
  57. d.set = s;
  58. }
  59. if (("get" in d || "set" in d) && ("value" in d || "writable" in d))
  60. throw new TypeError("identity-confused descriptor");
  61. return d;
  62. }
  63. if (typeof obj !== "object" || obj === null)
  64. throw new TypeError("bad obj");
  65. properties = Object(properties);
  66. var keys = Object.keys(properties);
  67. var descs = [];
  68. for (var i = 0; i < keys.length; i++)
  69. descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);
  70. for (var i = 0; i < descs.length; i++)
  71. Object.defineProperty(obj, descs[i][0], descs[i][1]);
  72. return obj;
  73. },
  74. 'typeOf': function(item){
  75. if (item == null) return 'null';
  76. if (item.$family != null) return item.$family();
  77. if (item.constructor == Array) return 'array';
  78. if (item.nodeName){
  79. if (item.nodeType == 1) return 'element';
  80. if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
  81. } else if (typeof item.length == 'number'){
  82. if (item.callee) return 'arguments';
  83. //if ('item' in item) return 'collection';
  84. }
  85. return typeof item;
  86. },
  87. 'JSONDecode': JSON.parse,
  88. 'JSONEncode': JSON.stringify
  89. };
  90. (function(){
  91. var o={"indexOf": {
  92. "value": function(item, from){
  93. var length = this.length >>> 0;
  94. for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
  95. if (this[i] === item) return i;
  96. }
  97. return -1;
  98. }
  99. }};
  100. Object.defineProperties(Array.prototype, o);
  101. })();
  102. bind.library = library;
  103. if (!bind.oPrint) bind.oPrint = print;
  104. var print = function(str, type){
  105. var d = new Date();
  106. var t = (type || "PRINT").toUpperCase();
  107. var l = "[script]";
  108. bind.oPrint(d.format("db")+"."+d.getMilliseconds()+" "+l+" "+t+" "+str);
  109. }
  110. var _parsePrint = function(str){
  111. if (!str && str!==0 && str!==false) return str;
  112. var text = (typeOf(str)!=="string") ? str.toString() : str;
  113. try{
  114. var i = 1;
  115. while (text.indexOf("%s")!==-1 && i<arguments.length){
  116. text = text.replace(/\%s/, arguments[i].toString());
  117. i++;
  118. }
  119. while (i<arguments.length){
  120. text += " "+arguments[i].toString();
  121. i++;
  122. }
  123. }catch(e){}
  124. return text;
  125. };
  126. var console = {
  127. log: function(){ print(_parsePrint.apply(this, arguments)); },
  128. error: function(){ print(_parsePrint.apply(this, arguments), "ERROR"); },
  129. info: function(){ print(_parsePrint.apply(this, arguments), "INFO"); },
  130. warn: function(){ print(_parsePrint.apply(this, arguments), "WARN"); }
  131. }
  132. var Error = function(msg){
  133. this.msg = msg;
  134. }
  135. Error.prototype.toString = function(){
  136. return this.msg;
  137. }
  138. var exec = function(code, _self){
  139. var returnValue;
  140. //try{
  141. if (!_self) _self = this;
  142. try {
  143. var f = eval("(function(){return function(){\n"+code+"\n}})();");
  144. returnValue = f.apply(_self);
  145. }catch(e){
  146. console.log("exec", new Error("exec script error"));
  147. console.log(e);
  148. }
  149. return returnValue;
  150. }
  151. bind.print = print;
  152. bind.exec = exec;
  153. //方法定义
  154. bind.define = function(name, fun, overwrite){
  155. var over = true;
  156. if (overwrite===false) over = false;
  157. var o = {};
  158. o[name] = {"value": fun, "configurable": over};
  159. Object.defineProperties(bind, o);
  160. }
  161. //restful服务Action
  162. bind.Action = function(root, json){
  163. this.actions = json;
  164. // Object.keys(json).forEach(function(key){
  165. // this.actions[key] = json[key];
  166. // });
  167. //Object.merge(actions[root], json);
  168. this.root = root;
  169. //this.actions = actions[root];
  170. var invokeFunction = function(service, parameters, key){
  171. var _self = this;
  172. return function(){
  173. var i = parameters.length-1;
  174. var n = arguments.length;
  175. var functionArguments = arguments;
  176. var parameter = {};
  177. var success, failure, async, data, file;
  178. if (typeOf(functionArguments[0])==="function"){
  179. i=-1;
  180. success = (n>++i) ? functionArguments[i] : null;
  181. failure = (n>++i) ? functionArguments[i] : null;
  182. parameters.each(function(p, x){
  183. parameter[p] = (n>++i) ? functionArguments[i] : null;
  184. });
  185. if (service.method && (service.method.toLowerCase()==="post" || service.method.toLowerCase()==="put")){
  186. data = (n>++i) ? functionArguments[i] : null;
  187. }
  188. }else{
  189. parameters.each(function(p, x){
  190. parameter[p] = (n>x) ? functionArguments[x] : null;
  191. });
  192. if (service.method && (service.method.toLowerCase()==="post" || service.method.toLowerCase()==="put")){
  193. data = (n>++i) ? functionArguments[i] : null;
  194. }
  195. success = (n>++i) ? functionArguments[i] : null;
  196. failure = (n>++i) ? functionArguments[i] : null;
  197. }
  198. return _self.invoke({"name": key, "data": data, "parameter": parameter, "success": success, "failure": failure});
  199. };
  200. };
  201. var createMethod = function(service, key){
  202. var jaxrsUri = service.uri;
  203. var re = new RegExp("\{.+?\}", "g");
  204. var replaceWords = jaxrsUri.match(re);
  205. var parameters = [];
  206. if (replaceWords) parameters = replaceWords.map(function(s){
  207. return s.substring(1,s.length-1);
  208. });
  209. this[key] = invokeFunction.call(this, service, parameters, key);
  210. };
  211. Object.keys(this.actions).forEach(function(key){
  212. var service = this.actions[key];
  213. if (service.uri) if (!this[key]) createMethod.call(this, service, key);
  214. }, this);
  215. this.invoke = function(option){
  216. if (this.actions[option.name]){
  217. var uri = this.actions[option.name].uri;
  218. var method = this.actions[option.name].method || "get";
  219. if (option.parameter){
  220. Object.keys(option.parameter).forEach(function(key){
  221. var v = option.parameter[key];
  222. uri = uri.replace("{"+key+"}", v);
  223. });
  224. }
  225. var res = null;
  226. try{
  227. switch (method.toLowerCase()){
  228. case "get":
  229. res = bind.applications.getQuery(this.root, uri);
  230. break;
  231. case "post":
  232. res = bind.applications.postQuery(this.root, uri, JSON.stringify(option.data));
  233. break;
  234. case "put":
  235. res = bind.applications.putQuery(this.root, uri, JSON.stringify(option.data));
  236. break;
  237. case "delete":
  238. res = bind.applications.deleteQuery(this.root, uri);
  239. break;
  240. default:
  241. res = bind.applications.getQuery(this.root, uri);
  242. }
  243. if (res && res.getType().toString()==="success"){
  244. var json = JSON.parse(res.toString());
  245. if (option.success) option.success(json);
  246. }else{
  247. if (option.failure) option.failure(((res) ? JSON.parse(res.toString()) : null));
  248. }
  249. return res;
  250. }catch(e){
  251. if (option.failure) option.failure(e);
  252. }
  253. }
  254. };
  255. }
  256. bind.Action.applications = bind.applications;
  257. bind.Actions = {
  258. "loadedActions": {},
  259. "load": function(root){
  260. if (this.loadedActions[root]) return this.loadedActions[root];
  261. var jaxrsString = bind.applications.describeApi(root);
  262. var json = JSON.parse(jaxrsString.toString());
  263. if (json && json.jaxrs){
  264. var actionObj = {};
  265. json.jaxrs.each(function(o){
  266. if (o.methods && o.methods.length){
  267. var actions = {};
  268. o.methods.each(function(m){
  269. var o = {"uri": "/"+m.uri};
  270. if (m.method) o.method = m.method;
  271. if (m.enctype) o.enctype = m.enctype;
  272. actions[m.name] = o;
  273. }.bind(this));
  274. actionObj[o.name] = new bind.Action(root, actions);
  275. }
  276. }.bind(this));
  277. this.loadedActions[root] = actionObj;
  278. return actionObj;
  279. }
  280. return null;
  281. }
  282. };
  283. //组织相关
  284. var getNameFlag = function(name){
  285. var t = library.typeOf(name);
  286. if (t==="array"){
  287. var v = [];
  288. name.forEach(function(id){
  289. v.push((library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  290. });
  291. return v;
  292. }else{
  293. return [(t==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  294. }
  295. };
  296. bind.org = {
  297. "group": function() { return this.oGroup},
  298. "identity": function() { return this.oIdentity},
  299. "person": function() { return this.oPerson},
  300. "personAttribute": function() { return this.oPersonAttribute},
  301. "role": function() { return this.oRole},
  302. "unit": function() { return this.oUnit},
  303. "unitAttribute": function() { return this.oUnitAttribute},
  304. "unitDuty": function() { return this.oUnitDuty},
  305. "getObject": function(o, v){
  306. var arr = [];
  307. if (!v || !v.length){
  308. return null;
  309. }else{
  310. for (var i=0; i<v.length; i++){
  311. var g = o.getObject(v[i]);
  312. if (g) arr.push(JSON.parse(g.toString()));
  313. }
  314. }
  315. return arr;
  316. },
  317. //群组***************
  318. //获取群组--返回群组的对象数组
  319. getGroup: function(name){
  320. var v = this.oGroup.listObject(getNameFlag(name));
  321. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  322. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  323. },
  324. //查询下级群组--返回群组的对象数组
  325. //nested 布尔 true嵌套下级;false直接下级;默认false;
  326. listSubGroup: function(name, nested){
  327. var v = null;
  328. if (nested){
  329. v = this.oGroup.listWithGroupSubNested(getNameFlag(name));
  330. }else{
  331. v = this.oGroup.listWithGroupSubDirect(getNameFlag(name));
  332. }
  333. return this.getObject(this.oGroup, v);
  334. },
  335. //查询上级群组--返回群组的对象数组
  336. //nested 布尔 true嵌套上级;false直接上级;默认false;
  337. listSupGroup:function(name, nested){
  338. var v = null;
  339. if (nested){
  340. v = this.oGroup.listWithGroupSupNested(getNameFlag(name));
  341. }else{
  342. v = this.oGroup.listWithGroupSupDirect(getNameFlag(name));
  343. }
  344. return this.getObject(this.oGroup, v);
  345. },
  346. //人员所在群组(嵌套)--返回群组的对象数组
  347. listGroupWithPerson:function(name){
  348. var v = this.oGroup.listWithPerson(getNameFlag(name));
  349. return this.getObject(this.oGroup, v);
  350. },
  351. //群组是否拥有角色--返回true, false
  352. groupHasRole: function(name, role){
  353. nameFlag = (library.typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  354. return this.oGroup.hasRole(nameFlag, getNameFlag(role));
  355. },
  356. //角色***************
  357. //获取角色--返回角色的对象数组
  358. getRole: function(name){
  359. var v = this.oRole.listObject(getNameFlag(name));
  360. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  361. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  362. },
  363. //人员所有角色(嵌套)--返回角色的对象数组
  364. listRoleWithPerson:function(name){
  365. var v = this.oRole.listWithPerson(getNameFlag(name));
  366. return this.getObject(this.oRole, v);
  367. },
  368. //人员***************
  369. //人员是否拥有角色--返回true, false
  370. personHasRole: function(name, role){
  371. nameFlag = (library.typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  372. return this.oPerson.hasRole(nameFlag, getNameFlag(role));
  373. },
  374. //获取人员,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
  375. getPersonData: function(name){
  376. var v = this.oPerson.getExt(name);
  377. var v_json = (!v) ? null: JSON.parse(v.toString());
  378. return v_json;
  379. },
  380. //获取人员--返回人员的对象数组
  381. getPerson: function(name, findCN){
  382. var v = this.oPerson.listObject(getNameFlag(name), !!findCN);
  383. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  384. // if (!v || !v.length) v = null;
  385. // return (v && v.length===1) ? v[0] : v;
  386. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  387. },
  388. //查询下级人员--返回人员的对象数组
  389. //nested 布尔 true嵌套下级;false直接下级;默认false;
  390. listSubPerson: function(name, nested){
  391. var v = null;
  392. if (nested){
  393. v = this.oPerson.listWithPersonSubNested(getNameFlag(name));
  394. }else{
  395. v = this.oPerson.listWithPersonSubDirect(getNameFlag(name));
  396. }
  397. return this.getObject(this.oPerson, v);
  398. },
  399. //查询上级人员--返回人员的对象数组
  400. //nested 布尔 true嵌套上级;false直接上级;默认false;
  401. listSupPerson: function(name, nested){
  402. var v = null;
  403. if (nested){
  404. v = this.oPerson.listWithPersonSupNested(getNameFlag(name));
  405. }else{
  406. v = this.oPerson.listWithPersonSupDirect(getNameFlag(name));
  407. }
  408. return this.getObject(this.oPerson, v);
  409. },
  410. //获取群组的所有人员--返回人员的对象数组
  411. listPersonWithGroup: function(name){
  412. var v = this.oPerson.listWithGroup(getNameFlag(name));
  413. return this.getObject(this.oPerson, v);
  414. // if (!v || !v.length) v = null;
  415. // return v;
  416. // var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  417. // return v_json;
  418. },
  419. //获取角色的所有人员--返回人员的对象数组
  420. listPersonWithRole: function(name){
  421. var v = this.oPerson.listWithRole(getNameFlag(name));
  422. return this.getObject(this.oPerson, v);
  423. },
  424. //获取身份的所有人员--返回人员的对象数组
  425. listPersonWithIdentity: function(name){
  426. var v = this.oPerson.listWithIdentity(getNameFlag(name));
  427. return this.getObject(this.oPerson, v);
  428. },
  429. //获取身份的所有人员--返回人员的对象数组
  430. getPersonWithIdentity: function(name){
  431. var v = this.oPerson.listWithIdentity(getNameFlag(name));
  432. var arr = this.getObject(this.oPerson, v);
  433. return (arr && arr.length==1) ? arr[0] : arr;
  434. },
  435. //查询组织成员的人员--返回人员的对象数组
  436. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  437. listPersonWithUnit: function(name, nested){
  438. var v = null;
  439. if (nested){
  440. v = this.oPerson.listWithUnitSubNested(getNameFlag(name));
  441. }else{
  442. v = this.oPerson.listWithUnitSubDirect(getNameFlag(name));
  443. }
  444. return this.getObject(this.oPerson, v);
  445. },
  446. //人员属性************
  447. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  448. appendPersonAttribute: function(person, attr, values){
  449. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  450. return this.oPersonAttribute.appendWithPersonWithName(personFlag, attr, values);
  451. },
  452. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  453. setPersonAttribute: function(person, attr, values){
  454. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  455. return this.oPersonAttribute.setWithPersonWithName(personFlag, attr, values);
  456. },
  457. //获取人员属性值
  458. getPersonAttribute: function(person, attr){
  459. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  460. var v = this.oPersonAttribute.listAttributeWithPersonWithName(personFlag, attr);
  461. var v_json = [];
  462. if (v && v.length){
  463. for (var i=0; i<v.length; i++){
  464. v_json.push(v[i].toString());
  465. }
  466. }
  467. return v_json;
  468. },
  469. //列出人员所有属性的名称
  470. listPersonAttributeName: function(name){
  471. var p = getNameFlag(name);
  472. var nameList = [];
  473. for (var i=0; i<p.length; i++){
  474. var v = this.oPersonAttribute.listNameWithPerson(p[i]);
  475. if (v && v.length){
  476. for (var j=0; j<v.length; j++){
  477. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  478. }
  479. }
  480. }
  481. return nameList;
  482. },
  483. // //列出人员的所有属性
  484. // listPersonAllAttribute: function(name){
  485. // var p = getNameFlag(name);
  486. // var v = this.oPersonAttribute.listNameWithPerson(p);
  487. //
  488. // var data = {"personList":getNameFlag(name)};
  489. // var v = null;
  490. // orgActions.listPersonAllAttribute(data, function(json){v = json.data;}, null, false);
  491. // return v;
  492. // },
  493. //身份**********
  494. //获取身份
  495. getIdentity: function(name){
  496. var v = this.oIdentity.listObject(getNameFlag(name));
  497. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  498. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  499. // if (!v || !v.length) v = null;
  500. // return (v && v.length===1) ? v[0] : v;
  501. },
  502. //列出人员的身份
  503. listIdentityWithPerson: function(name){
  504. var v = this.oIdentity.listWithPerson(getNameFlag(name));
  505. return this.getObject(this.oIdentity, v);
  506. },
  507. //查询组织成员身份--返回身份的对象数组
  508. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  509. listIdentityWithUnit: function(name, nested){
  510. var v = null;
  511. if (nested){
  512. v = this.oIdentity.listWithUnitSubNested(getNameFlag(name));
  513. }else{
  514. v = this.oIdentity.listWithUnitSubDirect(getNameFlag(name));
  515. }
  516. return this.getObject(this.oIdentity, v);
  517. },
  518. //组织**********
  519. //获取组织
  520. getUnit: function(name, findCN){
  521. var v = this.oUnit.listObject(getNameFlag(name), !!findCN);
  522. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  523. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  524. // if (!v || !v.length) v = null;
  525. // return (v && v.length===1) ? v[0] : v;
  526. },
  527. //查询组织的下级--返回组织的对象数组
  528. //nested 布尔 true嵌套下级;false直接下级;默认false;
  529. listSubUnit: function(name, nested){
  530. var v = null;
  531. if (nested){
  532. v = this.oUnit.listWithUnitSubNested(getNameFlag(name));
  533. }else{
  534. v = this.oUnit.listWithUnitSubDirect(getNameFlag(name));
  535. }
  536. return this.getObject(this.oUnit, v);
  537. },
  538. //查询组织的上级--返回组织的对象数组
  539. //nested 布尔 true嵌套上级;false直接上级;默认false;
  540. listSupUnit: function(name, nested){
  541. var v = null;
  542. if (nested){
  543. v = this.oUnit.listWithUnitSupNested(getNameFlag(name));
  544. }else{
  545. v = this.oUnit.listWithUnitSupDirect(getNameFlag(name));
  546. }
  547. return this.getObject(this.oUnit, v);
  548. },
  549. //根据个人身份获取组织
  550. //flag 数字 表示获取第几层的组织
  551. // 字符串 表示获取指定类型的组织
  552. // 空 表示获取直接所在的组织
  553. getUnitByIdentity: function(name, flag){
  554. //getOrgActions();
  555. var getUnitMethod = "current";
  556. var v;
  557. if (flag){
  558. if (library.typeOf(flag)==="string") getUnitMethod = "type";
  559. if (library.typeOf(flag)==="number") getUnitMethod = "level";
  560. }
  561. var n = getNameFlag(name)[0];
  562. switch (getUnitMethod){
  563. case "current":
  564. v = this.oUnit.getWithIdentity(n);
  565. break;
  566. case "type":
  567. v = this.oUnit.getWithIdentityWithType(n, flag);
  568. break;
  569. case "level":
  570. v = this.oUnit.getWithIdentityWithLevel(n, flag);
  571. break;
  572. }
  573. var o = this.getObject(this.oUnit, [v]);
  574. return (o && o.length===1) ? o[0] : o;
  575. },
  576. //列出身份所在组织的所有上级组织
  577. listAllSupUnitWithIdentity: function(name){
  578. var v = this.oUnit.listWithIdentitySupNested(getNameFlag(name));
  579. return this.getObject(this.oUnit, v);
  580. },
  581. //获取人员所在的所有组织(直接所在组织)
  582. listUnitWithPerson: function(name){
  583. var v = this.oUnit.listWithPerson(getNameFlag(name));
  584. return this.getObject(this.oUnit, v);
  585. },
  586. //列出人员所在组织的所有上级组织
  587. listAllSupUnitWithPerson: function(name){
  588. var v = this.oUnit.listWithPersonSupNested(getNameFlag(name));
  589. return this.getObject(this.oUnit, v);
  590. },
  591. //根据组织属性,获取所有符合的组织
  592. listUnitWithAttribute: function(name, attribute){
  593. var v = this.oUnit.listWithUnitAttribute(name, attribute);
  594. return this.getObject(this.oUnit, v);
  595. },
  596. //根据组织职务,获取所有符合的组织
  597. listUnitWithDuty: function(name, id){
  598. var idflag = (library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id;
  599. var v = this.oUnit.listWithUnitDuty(name, idflag);
  600. return this.getObject(this.oUnit, v);
  601. },
  602. //组织职务***********
  603. //获取指定的组织职务的身份
  604. getDuty: function(duty, id){
  605. var unit = (library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id;
  606. var v = this.oUnitDuty.listIdentityWithUnitWithName(unit, duty);
  607. return this.getObject(this.oIdentity, v);
  608. },
  609. //获取身份的所有职务名称
  610. listDutyNameWithIdentity: function(name){
  611. var ids = getNameFlag(name);
  612. var nameList = [];
  613. for (var i=0; i<ids.length; i++){
  614. var v = this.oUnitDuty.listNameWithIdentity(ids[i]);
  615. if (v && v.length){
  616. for (var j=0; j<v.length; j++){
  617. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  618. }
  619. }
  620. }
  621. return nameList;
  622. },
  623. //获取组织的所有职务名称
  624. listDutyNameWithUnit: function(name){
  625. var ids = getNameFlag(name);
  626. var nameList = [];
  627. for (var i=0; i<ids.length; i++){
  628. var v = this.oUnitDuty.listNameWithUnit(ids[i]);
  629. if (v && v.length){
  630. for (var j=0; j<v.length; j++){
  631. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  632. }
  633. }
  634. }
  635. return nameList;
  636. },
  637. //获取组织的所有职务
  638. listUnitAllDuty: function(name){
  639. var u = getNameFlag(name)[0];
  640. var ds = this.oUnitDuty.listNameWithUnit(u);
  641. var o = []
  642. for (var i=0; i<ds.length; i++){
  643. v = this.oUnitDuty.listIdentityWithUnitWithName(u, ds[i]);
  644. o.push({"name": ds[i], "identityList": this.getObject(this.oIdentity, v)});
  645. }
  646. return o;
  647. },
  648. //组织属性**************
  649. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  650. appendUnitAttribute: function(unit, attr, values){
  651. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  652. return this.oUnitAttribute.appendWithUnitWithName(unitFlag, attr, values);
  653. },
  654. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  655. setUnitAttribute: function(unit, attr, values){
  656. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  657. return this.oUnitAttribute.setWithUnitWithName(unitFlag, attr, values);
  658. },
  659. //获取组织属性值
  660. getUnitAttribute: function(unit, attr){
  661. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  662. var v = this.oUnitAttribute.listAttributeWithUnitWithName(unitFlag, attr);
  663. var v_json = [];
  664. if (v && v.length){
  665. for (var i=0; i<v.length; i++){
  666. v_json.push(v[i].toString());
  667. }
  668. }
  669. return v_json;
  670. },
  671. //列出组织所有属性的名称
  672. listUnitAttributeName: function(name){
  673. var p = getNameFlag(name);
  674. var nameList = [];
  675. for (var i=0; i<p.length; i++){
  676. var v = this.oUnitAttribute.listNameWithUnit(p[i]);
  677. if (v && v.length){
  678. for (var j=0; j<v.length; j++){
  679. if (nameList.indexOf(v[j])==-1) nameList.push(v[j]);
  680. }
  681. }
  682. }
  683. return nameList;
  684. },
  685. //列出组织的所有属性
  686. listUnitAllAttribute: function(name){
  687. var u = getNameFlag(name)[0];
  688. var ds = this.oUnitAttribute.listNameWithUnit(u);
  689. var o = []
  690. for (var i=0; i<ds.length; i++){
  691. v = this.getUnitAttribute(u, ds[i]);
  692. o.push({"name": ds[i], "valueList":v});
  693. }
  694. return o;
  695. }
  696. };
  697. Object.defineProperties(bind.org, {
  698. "oGroup": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().group()} },
  699. "oIdentity": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().identity()} },
  700. "oPerson": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().person()} },
  701. "oPersonAttribute": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().personAttribute()} },
  702. "oRole": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().role()} },
  703. "oUnit": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().unit()} },
  704. "oUnitAttribute": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().unitAttribute()} },
  705. "oUnitDuty": { "configurable": true, "get": function(){return bind.java_resources.getOrganization().unitDuty()} }
  706. });
  707. //定义所需的服务
  708. bind.processActions = new bind.Action("x_processplatform_assemble_surface", {
  709. "getDictionary": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{applicationFlag}"},
  710. "getDictRoot": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/data"},
  711. "getDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data"},
  712. "setDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "PUT"},
  713. "addDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "POST"},
  714. "deleteDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "DELETE"},
  715. "getScript": {"uri": "/jaxrs/script/{flag}/application/{applicationFlag}", "method": "POST"},
  716. });
  717. bind.cmsActions = new bind.Action("x_cms_assemble_control", {
  718. "getDictionary": {"uri": "/jaxrs/design/appdict/{appDictId}"},
  719. "getDictRoot": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/data"},
  720. "getDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data"},
  721. "setDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "PUT"},
  722. "addDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "POST"},
  723. "deleteDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "DELETE"},
  724. "getDictRootAnonymous" : {"uri": "/jaxrs/anonymous/surface/appdict/{appDictId}/appInfo/{appId}/data"},
  725. "getDictDataAnonymous" : {"uri": "/jaxrs/anonymous/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data"},
  726. "getScript": {"uri": "/jaxrs/script/{flag}/appInfo/{appInfoFlag}", "method": "POST"},
  727. });
  728. bind.portalActions = new bind.Action("x_portal_assemble_surface", {
  729. "getDictionary": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}"},
  730. "getDictRoot": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/data"},
  731. "getDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data"},
  732. "setDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "PUT"},
  733. "addDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "POST"},
  734. "deleteDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "DELETE"},
  735. "getScript": {"uri": "/jaxrs/script/portal/{portal}/name/{name}","method": "POST"}
  736. });
  737. bind.serviceActions = new bind.Action("x_program_center", {
  738. "getDictionary": {"uri": "/jaxrs/dict/{id}"},
  739. "getDictRoot": {"uri": "/jaxrs/dict/{dictFlag}/data"},
  740. "getDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data"},
  741. "setDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "PUT"},
  742. "addDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "POST"},
  743. "deleteDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "DELETE"},
  744. "getScript": {"uri": "/jaxrs/script/name/{name}","method": "POST"}
  745. });
  746. //include 引用脚本
  747. //optionsOrName : {
  748. // type : "", 默认为process, 可以为 portal process cms
  749. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  750. // name : "" // 脚本名称/别名/id
  751. //}
  752. //或者name: "" // 脚本名称/别名/id
  753. var includedScripts = bind.includedScripts || {};
  754. bind.includedScripts = includedScripts;
  755. bind.include = function( optionsOrName , callback ){
  756. var options = optionsOrName;
  757. if( typeOf( options ) == "string" ){
  758. options = { name : options };
  759. }
  760. var name = options.name;
  761. var type;
  762. if( options.type === "service" ){
  763. type = options.type;
  764. }else{
  765. type = ( options.type && options.application ) ? options.type : "process";
  766. }
  767. var application = type === "service" ? "service" : options.application;
  768. if (!name || !type || !application){
  769. console.log("include", new Error("can not find script. missing script name or application"));
  770. return false;
  771. }
  772. if (!includedScripts[application]) includedScripts[application] = [];
  773. if (includedScripts[application].indexOf( name )> -1){
  774. if (callback) callback.apply(this);
  775. return;
  776. }
  777. var scriptAction;
  778. var scriptData;
  779. switch ( type ){
  780. case "portal" :
  781. bind.portalActions.getScript( application, name, {"importedList":includedScripts[application]}, function(json){
  782. if (json.data){
  783. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  784. scriptData = json.data;
  785. }
  786. }.bind(this));
  787. break;
  788. case "process" :
  789. bind.processActions.getScript( name, application, {"importedList":includedScripts[application]}, function(json){
  790. if (json.data){
  791. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  792. scriptData = json.data;
  793. }
  794. }.bind(this));
  795. break;
  796. case "cms" :
  797. bind.cmsActions.getScript(name, application, {"importedList":includedScripts[application]}, function(json){
  798. if (json.data){
  799. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  800. scriptData = json.data;
  801. }
  802. }.bind(this));
  803. break;
  804. case "service" :
  805. bind.serviceActions.getScript(name, {"importedList":includedScripts[application]}, function(json){
  806. if (json.data){
  807. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  808. scriptData = json.data;
  809. }
  810. }.bind(this));
  811. break;
  812. }
  813. includedScripts[application].push(name);
  814. if (scriptData && scriptData.text){
  815. exec(scriptData.text, this);
  816. if (callback) callback.apply(this);
  817. }
  818. };
  819. //optionsOrName : {
  820. // type : "", //默认为process, 可以为 process cms
  821. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  822. // name : "", // 数据字典名称/别名/id
  823. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  824. //}
  825. //或者name: "" // 数据字典名称/别名/id
  826. bind.Dict = function(optionsOrName){
  827. var options = optionsOrName;
  828. if( typeOf( options ) == "string" ){
  829. options = { name : options };
  830. }
  831. var name = this.name = options.name;
  832. var type;
  833. if( options.type === "service"){
  834. type = options.type;
  835. }else{
  836. type = ( options.type && options.application ) ? options.type : "process";
  837. }
  838. var applicationId = options.application || ((bind.java_workContext) ? bind.java_workContext.getWork().application : "");
  839. var enableAnonymous = options.enableAnonymous || false;
  840. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  841. var action;
  842. if( type == "cms" ){
  843. action = bind.cmsActions;
  844. }else if( type == "service" ){
  845. action = bind.serviceActions;
  846. }else if( type == "portal" ){
  847. action = bind.portalActions;
  848. }else{
  849. action = bind.processActions;
  850. }
  851. var encodePath = function( path ){
  852. var arr = path.split(/\./g);
  853. var ar = arr.map(function(v){
  854. return encodeURIComponent(v);
  855. });
  856. return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/");
  857. };
  858. this.get = function(path, success, failure){
  859. var value = null;
  860. if( type === "service" ){
  861. if (path){
  862. var p = encodePath( path );
  863. action.getDictData(encodeURIComponent(this.name), p, function(json){
  864. value = json.data;
  865. if (success) success(json.data);
  866. }, function(xhr, text, error){
  867. if (failure) failure(xhr, text, error);
  868. });
  869. }else{
  870. action.getDictRoot(encodeURIComponent(this.name), function(json){
  871. value = json.data;
  872. if (success) success(json.data);
  873. }, function(xhr, text, error){
  874. if (failure) failure(xhr, text, error);
  875. }, false);
  876. }
  877. }else{
  878. if (path){
  879. var p = encodePath( path );
  880. action[(enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData"](encodeURIComponent(this.name), applicationId, p, function(json){
  881. value = json.data;
  882. if (success) success(json.data);
  883. }, function(xhr, text, error){
  884. if (failure) failure(xhr, text, error);
  885. });
  886. }else{
  887. action[(enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot"](encodeURIComponent(this.name), applicationId, function(json){
  888. value = json.data;
  889. if (success) success(json.data);
  890. }, function(xhr, text, error){
  891. if (failure) failure(xhr, text, error);
  892. }, false);
  893. }
  894. }
  895. return value;
  896. };
  897. this.set = function(path, value, success, failure){
  898. var p = encodePath( path );
  899. //var p = path.replace(/\./g, "/");
  900. if( type === "service" ){
  901. action.setDictData(encodeURIComponent(this.name), p, value, function(json){
  902. if (success) success(json.data);
  903. }, function(xhr, text, error){
  904. if (failure) failure(xhr, text, error);
  905. }, false, false);
  906. }else{
  907. action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  908. if (success) success(json.data);
  909. }, function(xhr, text, error){
  910. if (failure) failure(xhr, text, error);
  911. }, false, false);
  912. }
  913. };
  914. this.add = function(path, value, success, failure){
  915. var p = encodePath( path );
  916. //var p = path.replace(/\./g, "/");
  917. if( type === "service" ) {
  918. action.addDictData(encodeURIComponent(this.name), p, value, function(json){
  919. if (success) success(json.data);
  920. }, function(xhr, text, error){
  921. if (failure) failure(xhr, text, error);
  922. }, false, false);
  923. }else{
  924. action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  925. if (success) success(json.data);
  926. }, function(xhr, text, error){
  927. if (failure) failure(xhr, text, error);
  928. }, false, false);
  929. }
  930. };
  931. this["delete"] = function(path, success, failure){
  932. var p = encodePath( path );
  933. //var p = path.replace(/\./g, "/");
  934. if( type === "service" ) {
  935. action.deleteDictData(encodeURIComponent(this.name), p, function(json){
  936. if (success) success(json.data);
  937. }, function(xhr, text, error){
  938. if (failure) failure(xhr, text, error);
  939. }, false, false);
  940. }else{
  941. action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  942. if (success) success(json.data);
  943. }, function(xhr, text, error){
  944. if (failure) failure(xhr, text, error);
  945. }, false, false);
  946. }
  947. };
  948. this.destory = this["delete"];
  949. };
  950. bind.Table = function(name){
  951. this.name = name;
  952. this.action = Actions.load("x_query_assemble_surface").TableAction;
  953. this.listRowNext = function(id, count, success, error, async){
  954. this.action.listRowNext(this.name, id, count, success, error, async);
  955. };
  956. this.listRowPrev = function(id, count, success, error, async){
  957. this.action.listRowPrev(this.name, id, count, success, error, async);
  958. };
  959. this.listRowSelect = function(where, orderBy, size, success, error, async){
  960. this.action.listRowSelect(this.name, {"where": where, "orderBy": orderBy, "size": size || ""}, success, error, async);
  961. };
  962. this.listRowSelectWhere = function(where, success, error, async){
  963. this.action.listRowSelectWhere(this.name, where, success, error, async);
  964. };
  965. this.rowCountWhere = function(where, success, error, async){
  966. this.action.rowCountWhere(this.name, where, success, error, async);
  967. };
  968. this.deleteRow = function(id, success, error, async){
  969. this.action.rowDelete(this.name, id, success, error, async);
  970. };
  971. this.deleteAllRow = function(success, error, async){
  972. this.action.rowDeleteAll(this.name, success, error, async);
  973. };
  974. this.getRow = function(id, success, error, async){
  975. this.action.rowGet(this.name, id, success, error, async);
  976. };
  977. this.insertRow = function(data, success, error, async){
  978. this.action.rowInsert(this.name, data, success, error, async);
  979. };
  980. this.addRow = function(data, success, error, async){
  981. this.action.rowInsertOne(this.name, data, success, error, async);
  982. };
  983. this.updateRow = function(id, data, success, error, async){
  984. this.action.rowUpdate(this.name, id, data, success, error, async);
  985. };
  986. }
  987. bind.statement = {
  988. execute: function (obj, callback) {
  989. if( obj.format ){
  990. return this._execute(obj, callback, obj.format);
  991. }else{
  992. if( this.needCheckFormat(obj) ){
  993. var value;
  994. var _self = this;
  995. bind.Actions.load("x_query_assemble_surface").StatementAction.getFormat(obj.name, function(json){
  996. value = _self._execute(obj, callback, json.data.format);
  997. });
  998. return value;
  999. }else{
  1000. return this._execute(obj, callback, "");
  1001. }
  1002. }
  1003. },
  1004. needCheckFormat: function(s){
  1005. if( s.format )return false;
  1006. if( typeOf(s.parameter) === "object" ){
  1007. for( var p in s.parameter ){
  1008. if( typeOf( s.parameter[p] ) === "date" )return true;
  1009. }
  1010. }
  1011. if( typeOf(s.filter) === "array" ){
  1012. for( var i=0; i< s.filter.length; i++){
  1013. var fType = s.filter[i].formatType;
  1014. if( ["dateTimeValue", "datetimeValue", "dateValue", "timeValue"].indexOf( fType ) > -1 )return true;
  1015. }
  1016. }
  1017. return false;
  1018. },
  1019. _execute: function (statement, callback, format) {
  1020. var parameter = this.parseParameter(statement.parameter, format);
  1021. var filterList = this.parseFilter(statement.filter, parameter, format);
  1022. var obj = {
  1023. "filterList": filterList,
  1024. "parameter" : parameter
  1025. };
  1026. var value;
  1027. bind.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  1028. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  1029. function (json) {
  1030. if (callback) callback(json);
  1031. value = json;
  1032. }
  1033. );
  1034. return value;
  1035. },
  1036. parseFilter : function( filter, parameter, format ){
  1037. if( typeOf(filter) !== "array" )return [];
  1038. if( !parameter )parameter = {};
  1039. var filterList = [];
  1040. ( filter || [] ).each( function (d) {
  1041. //var parameterName = d.path.replace(/\./g, "_");
  1042. var pName = d.path.replace(/\./g, "_");
  1043. var parameterName = pName;
  1044. var suffix = 1;
  1045. while( parameter[parameterName] ){
  1046. parameterName = pName + "_" + suffix;
  1047. suffix++;
  1048. }
  1049. var value = d.value;
  1050. if( d.comparison === "like" || d.comparison === "notLike" ){
  1051. if( value.substr(0, 1) !== "%" )value = "%"+value;
  1052. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  1053. parameter[ parameterName ] = value; //"%"+value+"%";
  1054. }else{
  1055. if( ["sql", "sqlScript"].contains(format) ) {
  1056. if (d.formatType === "numberValue") {
  1057. value = parseFloat(value);
  1058. }
  1059. }else{
  1060. if (d.formatType === "dateTimeValue" || d.formatType === "datetimeValue") {
  1061. value = "{ts '" + value + "'}"
  1062. } else if (d.formatType === "dateValue") {
  1063. value = "{d '" + value + "'}"
  1064. } else if (d.formatType === "timeValue") {
  1065. value = "{t '" + value + "'}"
  1066. } else if (d.formatType === "numberValue") {
  1067. value = parseFloat(value);
  1068. }
  1069. }
  1070. parameter[ parameterName ] = value;
  1071. }
  1072. d.value = parameterName;
  1073. filterList.push( d );
  1074. });
  1075. return filterList;
  1076. },
  1077. parseParameter : function( obj, format ){
  1078. if( typeOf(obj) !== "object" )return {};
  1079. var parameter = {};
  1080. //传入的参数
  1081. for( var p in obj ){
  1082. var value = obj[p];
  1083. if( typeOf( value ) === "date" ){
  1084. if( ["sql", "sqlScript"].contains(format) ){
  1085. value = value.format("db");
  1086. }else{
  1087. value = "{ts '"+value.format("db")+"'}"
  1088. }
  1089. }
  1090. parameter[ p ] = value;
  1091. }
  1092. return parameter;
  1093. },
  1094. "select": function () {}
  1095. };
  1096. bind.view = {
  1097. "lookup": function(view, callback){
  1098. var filterList = {"filterList": (view.filter || null)};
  1099. var value;
  1100. bind.Actions.load("x_query_assemble_surface").ViewAction.executeWithQuery(view.view, view.application, filterList, function(json){
  1101. var data = {
  1102. "grid": json.data.grid || json.data.groupGrid,
  1103. "groupGrid": json.data.groupGrid
  1104. };
  1105. if (callback) callback(data);
  1106. value = data;
  1107. });
  1108. return value;
  1109. },
  1110. "select": function(view, callback, options){}
  1111. };
  1112. bind.service = {
  1113. restful: function(method, url, headers, body, connectTimeout, readTimeout){
  1114. var service = bind.java_resources.getWebservicesClient();
  1115. var bodyData = ((typeof body)==="object") ? JSON.stringify(body) : (body||"");
  1116. var res = service.restful(method, url, (headers||null), bodyData, (connectTimeout||2000), (readTimeout||300000));
  1117. var o = {
  1118. "responseCode" : res.responseCode,
  1119. "headers" : res.headers,
  1120. "body": res.body
  1121. }
  1122. try {
  1123. o.json = JSON.parse(res.body);
  1124. }catch(e){}
  1125. return o;
  1126. },
  1127. "get": function(url, headers, connectTimeout, readTimeout){
  1128. return this.restful("get", url, headers, "", connectTimeout, readTimeout);
  1129. },
  1130. "post": function(url, headers, body, connectTimeout, readTimeout){
  1131. return this.restful("post", url, headers, body, connectTimeout, readTimeout);
  1132. },
  1133. soap: function(wsdl, method, pars){
  1134. var service = bind.java_resources.getWebservicesClient();
  1135. return service.soap(wsdl, method, pars);
  1136. },
  1137. soapXml: function(wsdl, xml){
  1138. var service = bind.java_resources.getWebservicesClient();
  1139. return service.jaxwsXml(wsdl, xml);
  1140. }
  1141. }
  1142. //----------------------------------------------------------
  1143. //java_workcontext work上下文对象,流程相关的脚本中可获取
  1144. /**
  1145. * 您可以在流程事件、流程路由事件、流程活动事件中通过workContext获取和流程相关的流程实例对象数据。
  1146. * @module server.workContext
  1147. * @o2cn 流程实例
  1148. * @o2category server.process
  1149. * @o2range {Process} 所有流程配置中的脚本可以使用此对象
  1150. * @o2ordernumber 200
  1151. * @o2syntax
  1152. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前流程实例数据,如下:
  1153. * var context = this.workContext;
  1154. */
  1155. bind.workContext = {
  1156. /**
  1157. * 当前流程实例正在流转中,并且当前用户有待办,则返回当前用户的待办对象。
  1158. * 事实上在后端的活动事件中,大部分的情况下,此方法获取到的是taskCompleted对象,因为在人工活动的事件中,除了“待办处理前”事件,其他事件处理时,当前用户的待办都已经转为已办了。
  1159. * @summary 获取当前流程与当前用户相关的待办或已办对象:task对象或taskCompleted对象。
  1160. * @methodOf module:server.workContext
  1161. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.get|example=Task|Task对象:
  1162. * @method getTask
  1163. * @static
  1164. * @return {(Task|TaskCompleted|Null)} 当前用户的待办任务对象:task。当前用户没有对此流程实例的待办时,或流程实例已经流转结束,返回null。
  1165. * @o2syntax
  1166. * var task = this.workContext.getTask();
  1167. */
  1168. "getTask": function(){ //根据work获取当前处理的的task或者TaskCompleted json字符串 只能在流转的过程中获取到
  1169. var taskString = bind.java_workContext.getTaskOrTaskCompleted();
  1170. var task = (taskString) ? JSON.parse(taskString) : null;
  1171. if (task){
  1172. task.personDn = task.person || "";
  1173. task.unitDn = task.unit || "";
  1174. task.unitDnList = task.unitList || "";
  1175. task.identityDn = task.identity || "";
  1176. task.creatorPersonDn = task.creatorPerson ||"";
  1177. task.creatorUnitDn = task.creatorUnit ||"";
  1178. task.creatorUnitDnList = task.creatorUnitList ||"";
  1179. task.creatorIdentityDn = task.creatorIdentity ||"";
  1180. }
  1181. return task;
  1182. },
  1183. /**
  1184. * 获取当前流程实例对象:work对象或workCompleted对象。
  1185. * @method getWork
  1186. * @methodOf module:server.workContext
  1187. * @static
  1188. * @return {(Work|WorkCompleted)} 流程实例对象;如果流程已结束,返回已结束的流程实例对象。
  1189. * @o2ActionOut x_processplatform_assemble_surface.WorkAction.manageGet|example=Work|ignoreNoDescr=true|ignoreProps=[properties,manualTaskIdentityMatrix]|Work对象:
  1190. * @o2ActionOut x_processplatform_assemble_surface.WorkCompletedAction.get|example=WorkCompleted|ignoreProps=[properties,data,taskCompletedList,readCompletedList,reviewList,recordList,workLogList,storeForm,mobileStoreForm]|WorkCompleted对象:
  1191. * @o2syntax
  1192. * var work = this.workContext.getWork();
  1193. */
  1194. "getWork": function(){ //work的字符串
  1195. var work = JSON.parse(bind.java_workContext.getWork());
  1196. work.creatorPersonDn = work.creatorPerson ||"";
  1197. work.creatorUnitDn = work.creatorUnit ||"";
  1198. work.creatorUnitDnList = work.creatorUnitList ||"";
  1199. work.creatorIdentityDn = work.creatorIdentity ||"";
  1200. return work;
  1201. },
  1202. /**
  1203. * 获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  1204. * @method getTaskList
  1205. * @methodOf module:server.workContext
  1206. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithWork|example=Task
  1207. * @static
  1208. * @return {(Task[])} 待办任务列表.
  1209. * @o2syntax
  1210. * var taskList = this.workContext.getTaskList();
  1211. */
  1212. "getTaskList": function(){return JSON.parse(bind.java_workContext.getTaskList());}, //根据work获取所有的task数组 json字符串
  1213. /**
  1214. * 获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  1215. * @method getTaskCompletedList
  1216. * @methodOf module:server.workContext
  1217. * @static
  1218. * @return {(TaskCompleted[])} 已办任务列表.
  1219. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithWork|example=Task
  1220. * @o2syntax
  1221. * var taskCompletedList = this.workContext.getTaskCompletedList();
  1222. */
  1223. "getTaskCompletedList": function(){return JSON.parse(bind.java_workContext.getTaskCompletedList());}, //根据work获取所有的TaskCompleted数组 json字符串
  1224. /**
  1225. * @summary 获取当前流程实例的所有待阅对象数组。如果流程实例无待阅,则返回一个空数组。
  1226. * @method getReadList
  1227. * @methodOf module:server.workContext
  1228. * @static
  1229. * @return {(Read[])} 当前流程实例的所有待阅对象数组.
  1230. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.get|example=Read
  1231. * @o2syntax
  1232. * var readList = this.workContext.getReadList();
  1233. */
  1234. "getReadList": function(){return JSON.parse(bind.java_workContext.getReadList());}, //根据work获取所有的read数组 json字符串
  1235. /**
  1236. * @summary 获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  1237. * @method getReadCompletedList
  1238. * @methodOf module:server.workContext
  1239. * @static
  1240. * @return {(ReadCompleted[])} 当前流程实例的所有已阅对象数组.
  1241. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithWork|example=Read
  1242. * @o2syntax
  1243. * var readCompletedList = this.workContext.getReadCompletedList();
  1244. */
  1245. "getReadCompletedList": function(){return JSON.parse(bind.java_workContext.getReadCompletedList());}, //根据work获取所有的ReadCompleted数组 json字符串
  1246. /**
  1247. * @summary 获取当前流程实例的所有review对象。如果流程实例没有review,则返回一个空数组。
  1248. * @method getReviewList
  1249. * @alias getReviewListByJob
  1250. * @methodOf module:server.workContext
  1251. * @static
  1252. * @return {(Review[])} 当前流程实例的所有review对象数组.
  1253. * @o2ActionOut x_processplatform_assemble_surface.ReviewAction.listWithJob|example=Review
  1254. * @o2syntax
  1255. * var reviewList = this.workContext.getReviewList();
  1256. */
  1257. "getReviewList": function(){return JSON.parse(bind.java_workContext.getJobReviewList());},
  1258. /**
  1259. * @summary getTaskListByJob方法的别名。
  1260. * @method getJobTaskList
  1261. * @static
  1262. * @see server.module:workContext.getTaskListByJob
  1263. */
  1264. "getJobTaskList": function(){return JSON.parse(bind.java_workContext.getJobTaskList());}, //根据jobid获取所有的task数组 json字符串
  1265. /**
  1266. * @summary getTaskCompletedListByJob方法的别名。
  1267. * @method getJobTaskCompletedList
  1268. * @static
  1269. * @see server.module:workContext.getTaskCompletedListByJob
  1270. */
  1271. "getJobTaskCompletedList": function(){return JSON.parse(bind.java_workContext.getJobTaskCompletedList());}, //根据jobid获取所有的TaskCompleted数组 json字符串
  1272. /**
  1273. * @summary getReadListByJob方法的别名。
  1274. * @method getJobReadList
  1275. * @static
  1276. * @see server.module:workContext.getReadListByJob
  1277. */
  1278. "getJobReadList": function(){return JSON.parse(bind.java_workContext.getJobReadList());}, //根据jobid获取所有的read数组 json字符串
  1279. /**
  1280. * @summary getReadCompletedListByJob方法的别名。
  1281. * @method getJobReadCompletedList
  1282. * @static
  1283. * @see server.module:workContext.getReadCompletedListByJob
  1284. */
  1285. "getJobReadCompletedList": function(){return JSON.parse(bind.java_workContext.getJobReadCompletedList());}, //根据jobid获取所有的ReadCompleted数组 json字符串
  1286. /**
  1287. * @summary getReviewList方法的别名。
  1288. * @method getJobReviewList
  1289. * @static
  1290. * @see server.module:workContext.getReviewList
  1291. */
  1292. "getJobReviewList": function (){return this.getReviewList();}, //根据jobid获取所有的Review数组 json字符串
  1293. /**
  1294. * 根据当前工作的job获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  1295. * @method getTaskListByJob
  1296. * @methodOf module:server.workContext
  1297. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithJob|example=Task
  1298. * @static
  1299. * @return {(Task[])} 待办任务列表.
  1300. * @o2syntax
  1301. * var taskList = this.workContext.getTaskListByJob();
  1302. */
  1303. "getTaskListByJob": function(){return this.getJobTaskList();},
  1304. /**
  1305. * 根据当前工作的job获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  1306. * @method getTaskCompletedListByJob
  1307. * @methodOf module:server.workContext
  1308. * @static
  1309. * @return {(TaskCompleted[])} 已办任务列表.
  1310. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithJob|example=Task
  1311. * @o2syntax
  1312. * var taskCompletedList = this.workContext.getTaskCompletedListByJob();
  1313. */
  1314. "getTaskCompletedListByJob": this.getJobTaskCompletedList,
  1315. /**
  1316. * @summary 根据当前工作的job获取当前流程实例的所有待阅对象。如果流程实例无待阅,则返回一个空数组。
  1317. * @method getReadListByJob
  1318. * @methodOf module:server.workContext
  1319. * @static
  1320. * @return {(Read[])} 当前流程实例的所有待阅对象数组.
  1321. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.listWithJob|example=Read
  1322. * @o2syntax
  1323. * var readList = this.workContext.getReadListByJob();
  1324. */
  1325. "getReadListByJob": function(){return this.getJobReadList();},
  1326. /**
  1327. * @summary 根据当前工作的job获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  1328. * @method getReadCompletedListByJob
  1329. * @methodOf module:server.workContext
  1330. * @static
  1331. * @return {(ReadCompleted[])} 当前流程实例的所有已阅对象数组.
  1332. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithJob|example=Read
  1333. * @o2syntax
  1334. * var readCompletedList = this.workContext.getReadCompletedListByJob();
  1335. */
  1336. "getReadCompletedListByJob": function(){return this.getJobReadCompletedList();},
  1337. /**
  1338. * @summary getReviewList方法的别名。
  1339. * @method getReviewListByJob
  1340. * @static
  1341. * @see server.module:workContext.getReviewList
  1342. */
  1343. "getReviewListByJob": function(){return this.getJobReviewList();},
  1344. /**
  1345. * 获取当前流程实例所在的活动节点对象:activity对象。
  1346. * @method getActivity
  1347. * @static
  1348. * @return {(Activity|Null)} 当前流程实例所在的活动节点对象,如果当前流程实例已流转完成,则返回null.
  1349. * <pre><code class='language-js'>{
  1350. * "id": "801087c5-a4e6-4b91-bf4d-a81cdaa04471", //节点ID
  1351. * "name": "办理", //节点名称
  1352. * "description": "", //节点描述
  1353. * "alias": "", //节点别名
  1354. * "resetRange": "department", //重置处理人范围
  1355. * "resetCount": 0, //重置处理人数字
  1356. * "allowReset": true, //是否允许重置
  1357. * "manualMode": "single", //处理方式 单人single, 并行parallel, 串行queue, grab抢办
  1358. * "customData": { //节点上的自定义属性,如果没有设置,不输出该值
  1359. *
  1360. * }
  1361. * }</code></pre>
  1362. * @o2syntax
  1363. * var activity = this.workContext.getActivity();
  1364. */
  1365. "getActivity": function(){return JSON.parse(bind.java_workContext.getActivity());}, //活动对象字符串
  1366. /**
  1367. * @summary 获取当前流程实例的所有流程记录(WorkLog)。
  1368. * @method getWorkLogList
  1369. * @static
  1370. * @return {WorkLog[]} 流程记录对象.
  1371. * @o2ActionOut x_processplatform_assemble_surface.WorkLogAction.listWithJob|example=WorkLog|ignoreProps=[properties,goBackFromActivityType]
  1372. * @o2syntax
  1373. * var workLogList = this.workContext.getWorkLogList();
  1374. */
  1375. "getWorkLogList": function(){return JSON.parse(bind.java_workContext.getWorkLogList());}, //WorkLogList对象数组的字符串
  1376. /**
  1377. * @summary 获取当前流程实例的所有流程记录(Record)。
  1378. * @method getRecordList
  1379. * @o2ActionOut x_processplatform_assemble_surface.RecordAction.listWithJob|example=Record
  1380. * @static
  1381. * @return {Record[]} 流程记录(Record)对象.
  1382. * @o2syntax
  1383. * var recordList = this.workContext.getRecordList();
  1384. */
  1385. "getRecordList": function(){return JSON.parse(bind.java_workContext.getRecordList());}, //RecordList对象数组的字符串,需要新增
  1386. /**
  1387. * @summary 最后一条Record对象,在活动流转完成事件中,获取本次流转的record;在其它事件中获取的是整个job的最后一条record,并不是本次流转的record。
  1388. * @method getRecord
  1389. * @o2ActionOut x_processplatform_assemble_surface.RecordAction.listWithJob|example=Record
  1390. * @static
  1391. * @return {Record[]} 流程记录(Record)对象.
  1392. * @o2syntax
  1393. * var record = this.workContext.getRecord();
  1394. */
  1395. "getRecord": function(){return JSON.parse(bind.java_workContext.getRecord());}, //最后一条Record对象,(在活动流转完成事件中,获取本次流转的record;在其它事件中获取的是整个job的最后一条record,并不是本次流转的record)
  1396. /**
  1397. * @summary 获取当前流程实例的附件对象列表。
  1398. * @method getAttachmentList
  1399. * @static
  1400. * @return {WorkAttachmentData[]} 附件数据.
  1401. * @o2ActionOut x_processplatform_assemble_surface.AttachmentAction.getWithWorkOrWorkCompleted|example=Attachment|ignoreProps=[properties]
  1402. * @o2syntax
  1403. * //获取附件列表
  1404. * var attachmentList = this.workContext.getAttachmentList();
  1405. */
  1406. "getAttachmentList": function(){return JSON.parse(bind.java_workContext.getAttachmentList());}, //附件对象数组的字符串
  1407. /**
  1408. * @summary 获取可选路由对象数组的字符串(流转事件中,获取到流转中的可选路由列表,根据当前work状态获取)。
  1409. * @method getRouteList
  1410. * @static
  1411. * @return {String[]} 路由字符串数组.
  1412. * @o2syntax
  1413. * var routeList = this.workContext.getRouteList();
  1414. */
  1415. "getRouteList": function(){return JSON.parse(bind.java_workContext.getRouteList());}, //可选路由对象数组的字符串(流转事件中,获取到流转中的可选路由列表,根据当前work状态获取)
  1416. /**
  1417. * @summary 重新设置流程实例标题
  1418. * @method setTitle
  1419. * @static
  1420. * @param {String} title - 标题字符串.
  1421. * @o2syntax
  1422. * this.workContext.setTitle(title);
  1423. * @example
  1424. * this.workContext.setTitle("标题");
  1425. */
  1426. "setTitle": function(title){bind.java_workContext.setTitle(title);}, //设置title
  1427. "getControl": function(){return null;},
  1428. "getInquiredRouteList": function(){return null;}
  1429. };
  1430. bind.workContent = bind.workContext;
  1431. //person, 直接注入,oauth配置和默认生成口令脚本中
  1432. /**
  1433. * 在流程事件、流程路由事件、流程活动事件中通过this.data获取流程实例的业务数据。(内容管理无后台脚本)。<br/>
  1434. * 这些数据一般情况下是通过您创建的表单收集而来的,也可以通过脚本进行创建和增删改查操作。<br/>
  1435. * data对象基本上是一个JSON对象,您可以用访问JSON对象的方法访问data对象的所有数据。
  1436. * @module server.data
  1437. * @o2cn 流程数据
  1438. * @o2category server.process
  1439. * @o2ordernumber 205
  1440. * @example
  1441. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下:
  1442. * var data = this.data;
  1443. * @borrows module:data#[property] as [property]
  1444. */
  1445. //bind.data = this.java_data; //业务数据data,直接注入
  1446. //封装java对象data, 以兼容javascript对象
  1447. (function (bind) {
  1448. Object.prototype.containsKey = function(key){
  1449. return Object.keys(this).indexOf(key)!==-1;
  1450. }
  1451. Object.prototype.put = function(key, value){
  1452. this[key] = value;
  1453. }
  1454. var javaClass;
  1455. try {
  1456. javaClass = {
  1457. map: java.util.Map,
  1458. array: java.util.ArrayList,
  1459. work: com.x.processplatform.core.entity.content.Data$DataWork
  1460. }
  1461. }catch (e){
  1462. javaClass = {
  1463. map: Object,
  1464. array: Array,
  1465. work: new Function()
  1466. }
  1467. }
  1468. function proxyWork(data) {
  1469. return (data instanceof javaClass.work) && JSON.parse(data.toString());
  1470. }
  1471. function proxyJavaObject(data) {
  1472. return (data instanceof javaClass.map) && new ProxyData(data);
  1473. }
  1474. function proxyArray(data) {
  1475. return ((data instanceof javaClass.array) || typeOf(data) === "array") && createProxyArray(data);
  1476. }
  1477. function createProxyArray(data) {
  1478. var arr = [];
  1479. data.forEach(function (d) {
  1480. arr.push(createProxyData(d));
  1481. });
  1482. return arr;
  1483. // return data.map(function (d) {
  1484. // return createProxyData(d);
  1485. // });
  1486. }
  1487. function createProxyData(data) {
  1488. var proxyData;
  1489. [proxyJavaObject, proxyArray, proxyWork].some(function (fun) {
  1490. return proxyData = fun(data);
  1491. });
  1492. return proxyData || data;
  1493. }
  1494. function _getter(key, tData, proxy) {
  1495. return function () {
  1496. if (!proxy.proxyData.hasOwnProperty(key)) {
  1497. proxy.proxyData[key] = createProxyData(tData[key], proxy);
  1498. }
  1499. return proxy.proxyData[key];
  1500. }
  1501. }
  1502. function _setter(key, data, proxy) {
  1503. return function (value) {
  1504. proxy.proxyData[key] = createProxyData(value, proxy);
  1505. data.put(key, value);
  1506. // data[key] = value;
  1507. }
  1508. }
  1509. function _addData(data, proxy) {
  1510. return function (key, value) {
  1511. if (proxy.hasOwnProperty(key)) {
  1512. proxy[key] = value;
  1513. } else {
  1514. data.put(key, value);
  1515. //data[key] = value;
  1516. Object.defineProperty(proxy, key, {
  1517. configurable: true,
  1518. enumerable: true,
  1519. get: _getter(key, data, proxy),
  1520. set: _setter(key, data, proxy)
  1521. })
  1522. }
  1523. }
  1524. }
  1525. function _delData(data, proxy) {
  1526. return function (key) {
  1527. if (proxy.hasOwnProperty(key)) {
  1528. data.remove(key);
  1529. delete proxy[key];
  1530. }
  1531. }
  1532. }
  1533. function isProxyData(data){
  1534. return ProxyData.prototype.isPrototypeOf(data);
  1535. }
  1536. function commitArray(arrList, proxy){
  1537. proxy.forEach(function(d, i){
  1538. if (Array.isArray(d)){
  1539. if (arrList.length<=i) arrList.add(new java.util.ArrayList());
  1540. commitArray(arrList[i], d)
  1541. }else if (isProxyData(d)){
  1542. d.commit();
  1543. }else if (d instanceof Object) {
  1544. if (arrList.length<=i) arrList.add(new java.util.LinkedHashMap());
  1545. commitObject(arrList[i], d)
  1546. }else{
  1547. if (arrList.length<=i){
  1548. arrList.add(d);
  1549. }else if (arrList[i]!==d){
  1550. arrList[i]=d;
  1551. }
  1552. }
  1553. });
  1554. }
  1555. function commitObject(map, proxy){
  1556. Object.keys(proxy).forEach(function(key){
  1557. var d = proxy[key];
  1558. if (Array.isArray(d)){
  1559. if (!map.containsKey(key)) map.put(key, new java.util.ArrayList());
  1560. commitArray(map[key], d)
  1561. }else if (isProxyData(d)){
  1562. d.commit();
  1563. }else if (d instanceof Object) {
  1564. if (!map.containsKey(key)) map.put(key, new java.util.LinkedHashMap());
  1565. commitObject(map[key], d)
  1566. }else{
  1567. if (!map.containsKey(key) || map[key] !== d) map.put(key, d);
  1568. }
  1569. });
  1570. }
  1571. function commitData(data, proxy) {
  1572. Object.keys(proxy).forEach(function (key) {
  1573. var d = proxy[key];
  1574. if (isProxyData(d)){
  1575. d.commit();
  1576. }else if (Array.isArray(d)) {
  1577. if (!data.containsKey(key)) data[key] = new java.util.ArrayList();
  1578. commitArray(data[key], d)
  1579. }else if (!data.containsKey(key)){
  1580. data[key] = d;
  1581. }
  1582. })
  1583. }
  1584. function ProxyData(tData) {
  1585. Object.defineProperty(this, "proxyData", {
  1586. value: {}
  1587. });
  1588. var _self = this;
  1589. var keys = tData.keySet();
  1590. var o = {};
  1591. keys.forEach(function (key) {
  1592. o[key] = {
  1593. configurable: true,
  1594. enumerable: true,
  1595. get: _getter(key, tData, _self),
  1596. set: _setter(key, tData, _self)
  1597. }
  1598. });
  1599. o.add = {
  1600. value: _addData(tData, _self)
  1601. };
  1602. o.del = {
  1603. value: _delData(tData, _self)
  1604. };
  1605. o.commit = {
  1606. value: function(){
  1607. commitData(tData, _self);
  1608. }
  1609. };
  1610. Object.defineProperties(this, o);
  1611. }
  1612. Object.defineProperty(bind, "data", {
  1613. configurable: true,
  1614. enumerable: true,
  1615. get: function(){
  1616. if (!this.__data__) this.__data__ = (bind.java_data) && new ProxyData(bind.java_data);
  1617. return this.__data__;
  1618. }
  1619. })
  1620. })(this);
  1621. //流程调用脚本,数据脚本--------------------------------------------
  1622. //{
  1623. // data:{},
  1624. // application:"",
  1625. // process:"",
  1626. // identity: "",
  1627. // attachmentList: [],
  1628. // title: "",
  1629. // processing: true
  1630. //}
  1631. //后续计划通过return 返回assignData,
  1632. /**
  1633. * 用于流程配置的流程调用活动中的“数据脚本”,可以通过assignData对象获取要调用的流程的相关信息,以及要传递给被调用流程实例的业务数据。<br>
  1634. * 也可以修改业务数据,并通过assignData的set方法,将业务数据传递到被调用的流程实例。<br/>
  1635. * @o2range 流程配置-流程调用活动中的“数据脚本”中可用
  1636. * @module server.assignData
  1637. * @o2cn 流程实例业务数据
  1638. * @o2category server.process
  1639. * @o2ordernumber 210
  1640. * @example
  1641. * //在流程调用活动中的“数据脚本”,通过下面的代码修改业务数据,并传递给被调用流程的实例:
  1642. * var data = this.assignData.get();
  1643. * data.data.parentProcessData = "父流程实例的信息";
  1644. * this.assignData.set(data);
  1645. * @example
  1646. * <caption>
  1647. * assignData.set方法是为了兼容以前的版本。<br>
  1648. * <b>建议通过return一个json对象的方式来设置data内容</b>
  1649. * </caption>
  1650. * //也可以通过return一个json对象的方式来代替assignData.set方法
  1651. * var data = this.assignData.get();
  1652. * data.data.parentProcessData = "父流程实例的信息";
  1653. * return data;
  1654. */
  1655. bind.assignData = { //java_assignData 应用调用活动的创建的流程实例的业务数据处理对象,get set 方法
  1656. _data: null,
  1657. /**
  1658. * @summary 获取要调用的流程的相关信息,以及要传递给被调用流程实例的业务数据。
  1659. * @method get
  1660. * @methodOf module:server.assignData
  1661. * @static
  1662. * @return {Object} 描述被调用的流程的信息,及要传递的业务数据.
  1663. * <pre><code class='language-js'>{
  1664. * "application": "application id", //被调用的应用id
  1665. * "process": "process id", //被调用的流程id
  1666. * "identity": "xxx@xxx@I", //被调用流程的启动这身份
  1667. * "title": "title", //被调用流程实例的标题
  1668. * "attachmentList": [], //要传递到被调用的流程实例的附件对象
  1669. * "data": {}, //要传递到被调用的流程实例的业务数据
  1670. * "attachmentSoftCopy" //如果为true,不拷贝附件文件。默认false @todo
  1671. * }</code></pre>
  1672. * @o2syntax
  1673. * var data = this.assignData.get();
  1674. */
  1675. "get": function(){
  1676. this.data = JSON.parse(bind.java_assignData.get());
  1677. return this.data;
  1678. },
  1679. /**
  1680. * @summary 设置修改后的assignData对象。(set方法为了兼容早期的版本。建议使用 return data; 方式直接返回json对象)
  1681. * @method set
  1682. * @methodOf module:server.assignData
  1683. * @static
  1684. * @param {Object} [data] 要设置的assignData对象,一般情况都是通过assignData.get()获取并做必要修改的对象。
  1685. * @o2syntax
  1686. * this.assignData.set(data);
  1687. * @deprecated set方法已不建议使用了。建议return一个json对象或数组的方式来设置data。
  1688. * @example
  1689. * var data = this.assignData.get();
  1690. * data.data.parentProcessData = "父流程实例的信息";
  1691. * return data;
  1692. */
  1693. "set": function(data){
  1694. bind.java_assignData.set(JSON.stringify(data || this.data));
  1695. }
  1696. };
  1697. Object.defineProperties(bind.assignData, {"data": {
  1698. "configurable": true,
  1699. "get": function(){
  1700. if (this._data) return this._data;
  1701. return JSON.parse(bind.java_assignData.get());
  1702. },
  1703. "set": function(v){this._data = v;}
  1704. }});
  1705. //--------------------------------------------------------------
  1706. //服务调用活动,相关脚本--------------------------------------------
  1707. //调用活动中的参数 java_jaxwsParameters webservice调用; java_jaxrsParameterss rest调用
  1708. //后续计划通过return 返回json(jaxrs)或数组(jaxws)
  1709. /**
  1710. * 用于流程配置的服务调用活动中的“参数脚本”,为jaxrs和jaxws两种服务调用方式传递参数。<br>
  1711. * 当调用类型为jaxrs时:可使用parameters.put和parameters.remove方法<br/>
  1712. * 当调用类型为jaxws时:可使用parameters.add和parameters.remove方法<br/>
  1713. * @o2range 流程配置-服务调用活动中的“参数脚本”中可用
  1714. * @module server.parameters
  1715. * @o2cn 服务调用参数
  1716. * @o2category server.process
  1717. * @o2ordernumber 215
  1718. * @deprecated parameters对象已经不建议使用了。建议return一个json对象或数组的方式来设置参数。
  1719. * @example
  1720. * //使用jaxrs方式的服务调用活动的参数脚本中
  1721. * //如果rest服务地址为:xxx/{id}/xx/{name},则需要传入两个参数:id和name,可使用如下代码:
  1722. * this.parameters.put("id", "id value");
  1723. * this.parameters.put("name", "name value");
  1724. *
  1725. * //或者
  1726. * this.parameters.put({
  1727. * "id": "id value",
  1728. * "name": "name value"
  1729. * });
  1730. *
  1731. * @example
  1732. * //使用jaxws方式的服务调用活动的参数脚本中
  1733. * //如果需要传入三个参数,可使用如下代码:
  1734. * this.parameters.add("参数1");
  1735. * this.parameters.add("参数2");
  1736. * this.parameters.add("参数3");
  1737. *
  1738. * //或者
  1739. * this.parameters.add(["参数1", "参数2", "参数3"]);
  1740. *
  1741. * @example
  1742. * <caption>
  1743. * 以上两个例子中使用了parameters对象来收集参数,这主要是为了兼容以前的版本。<br>
  1744. * <b>我们更建议通过return一个json对象或数组的方式来设置参数</b>
  1745. * </caption>
  1746. * //以上两个例子中使用了parameters对象来收集参数
  1747. * //更好的方式是:通过return一个json对象或数组的方式来设置参数
  1748. * //对于jaxrs方式:
  1749. * return {
  1750. * "id": "id value",
  1751. * "name": "name value"
  1752. * }
  1753. *
  1754. * //对于jaxws方式:
  1755. * return ["参数1", "参数2", "参数3"];
  1756. */
  1757. bind.parameters = {
  1758. /**
  1759. * @summary jaxws方式的服务调用活动,“参数脚本”中,使用parameters.add设置参数。
  1760. * @method add
  1761. * @methodOf module:server.parameters
  1762. * @static
  1763. * @param {Any|Array} [value] 要设置的参数值。
  1764. * @o2syntax
  1765. * this.parameters.add(value);
  1766. * @deprecated 不建议使用,建议return一个数组的方式来设置参数。如:
  1767. * <pre><code class='language-js'>return ["参数1", "参数2", "参数3"];</code></pre>
  1768. */
  1769. "add": function(value){
  1770. try{
  1771. if (bind.java_jaxwsParameters){
  1772. if (Array.isArray(value)){
  1773. value.forEach(function(v){
  1774. bind.java_jaxwsParameters.add(v);
  1775. });
  1776. }else{
  1777. bind.java_jaxwsParameters.add(value);
  1778. }
  1779. }
  1780. }catch(e){}
  1781. },
  1782. /**
  1783. * @summary jaxrs方式的服务调用活动,“参数脚本”中,使用parameters.put设置参数。
  1784. * @method put
  1785. * @methodOf module:server.parameters
  1786. * @static
  1787. * @param {String|Object} [name] 要设置的参数key,或参数json对象。
  1788. * @param {String|Number|boolean} [value] 要设置的参数值。
  1789. * @o2syntax
  1790. * this.parameters.put(name, value);
  1791. * this.parameters.put(obj);
  1792. * @deprecated 不建议使用,建议return一个json对象的方式来设置参数。如:
  1793. * <pre><code class='language-js'>return {
  1794. * "id": "id value",
  1795. * "name": "name value"
  1796. * };</code></pre>
  1797. */
  1798. "put": function(name, value){
  1799. try{
  1800. if ((typeof name)==="object"){
  1801. var _keys = Object.keys(name);
  1802. for (var i=0; i<_keys.length; i++){
  1803. if (bind.java_jaxrsParameters) bind.java_jaxrsParameters.put(_keys[i], name[_keys[i]]);
  1804. }
  1805. }else{
  1806. if (bind.java_jaxrsParameters) bind.java_jaxrsParameters.put(name, value);
  1807. }
  1808. }catch(e){}
  1809. },
  1810. /**
  1811. * @summary 服务调用活动,“参数脚本”中,删除已设置参数。
  1812. * @method remove
  1813. * @methodOf module:server.parameters
  1814. * @static
  1815. * @param {String|Number} [name] jaxrs方式的服务调用活动,传入要删除参数的key;jaxws方式的服务调用活动,传入要删除的参数的索引。
  1816. * @o2syntax
  1817. * this.parameters.remove(name);
  1818. * @deprecated 不建议使用
  1819. */
  1820. "remove": function(name){
  1821. try{
  1822. if (bind.java_jaxwsParameters) bind.java_jaxwsParameters.remove(name);
  1823. if (bind.java_jaxrsParameters) bind.java_jaxrsParameters.remove(name);
  1824. }catch(e){}
  1825. }
  1826. };
  1827. //java_jaxrsBody //调用活动的 body
  1828. //后续计划通过return返回
  1829. /**
  1830. * 用于流程配置的服务调用活动中的“消息体脚本”,仅在jaxrs方式的服务调用活动中可用。<br>
  1831. * @o2range 流程配置-服务调用活动中的“消息体脚本”,服务协议为jaxrs
  1832. * @module server.body
  1833. * @o2cn 服务调用消息体
  1834. * @o2category server.process
  1835. * @o2ordernumber 220
  1836. * @deprecated body对象已经不建议使用了。建议return一个json对象的方式来设置body。如:
  1837. * <pre><code class='language-js'>return {
  1838. * "key1": "value1",
  1839. * "key2": "value2",
  1840. * "key3": "value3"
  1841. * };</code></pre>
  1842. * @example
  1843. * //设置jaxrs服务调用的消息体
  1844. * this.body.set({
  1845. * "key1": "value1",
  1846. * "key2": "value2",
  1847. * "key3": "value3"
  1848. * })
  1849. *
  1850. * //或者设置
  1851. * this.body.set("this is body data");
  1852. *
  1853. * @example
  1854. * <caption>
  1855. * body.set方法是为了兼容以前的版本。<br>
  1856. * <b>建议通过return一个json对象的方式来设置消息体内容</b>
  1857. * </caption>
  1858. * return {
  1859. * "key1": "value1",
  1860. * "key2": "value2",
  1861. * "key3": "value3"
  1862. * };
  1863. *
  1864. * //或
  1865. * return "this is body data";
  1866. */
  1867. bind.body = {
  1868. /**
  1869. * @summary 服务调用活动中的“消息体脚本”,用于设置消息体内容。
  1870. * @method set
  1871. * @methodOf module:server.body
  1872. * @static
  1873. * @param {String|Object} [data] 消息体内容。
  1874. * @o2syntax
  1875. * this.body.set(data);
  1876. * @deprecated 不建议使用,建议return一个json对象或数组的方式来设置body。
  1877. */
  1878. "set": function(data){
  1879. if ((typeof data)==="string"){
  1880. bind.java_jaxrsBody.set(data);
  1881. }
  1882. if ((typeof data)==="object"){
  1883. bind.java_jaxrsBody.set(JSON.stringify(data));
  1884. }
  1885. }
  1886. };
  1887. //java_jaxrsHeaders //调用活动的 headers
  1888. //后续计划通过return返回
  1889. /**
  1890. * 用于流程配置的服务调用活动中的“消息头脚本”,仅在jaxrs方式的服务调用活动中可用。<br>
  1891. * @o2range 流程配置-服务调用活动中的“消息头脚本”,服务协议为jaxrs
  1892. * @module server.headers
  1893. * @o2cn 服务调用消息头
  1894. * @o2category server.process
  1895. * @o2ordernumber 225
  1896. * @deprecated headers对象已经不建议使用了,建议return一个json对象的方式来设置headers。如:
  1897. * <pre><code class='language-js'>return {
  1898. * "Content-Type": "application/x-www-form-urlencoded",
  1899. * "Accept-Language": "en"
  1900. * };</code></pre>
  1901. * @example
  1902. * //设置jaxrs服务调用的消息头
  1903. * this.headers.put("Content-Type", "application/x-www-form-urlencoded");
  1904. *
  1905. * //或者
  1906. * this.headers.put({
  1907. * "Content-Type": "application/x-www-form-urlencoded",
  1908. * "Accept-Language": "en"
  1909. * });
  1910. *
  1911. * @example
  1912. * <caption>
  1913. * headers.put方法是为了兼容以前的版本。<br>
  1914. * <b>建议通过return一个json对象的方式来设置消息头内容</b>
  1915. * </caption>
  1916. * return {
  1917. * "Content-Type": "application/x-www-form-urlencoded",
  1918. * "Accept-Language": "en"
  1919. * };
  1920. */
  1921. bind.headers = {
  1922. /**
  1923. * @summary jaxrs方式的服务调用活动,“消息头脚本”中,headers.put设置消息头。
  1924. * @method add
  1925. * @methodOf module:server.headers
  1926. * @static
  1927. * @param {String|Object} [name] 要设置的消息头名称,或消息头json对象。
  1928. * @param {String} [value] 要设置的消息头值。
  1929. * @o2syntax
  1930. * this.headers.put(name, value);
  1931. * this.headers.put(obj);
  1932. * @deprecated 不建议使用,建议return一个json对象的方式来设置headers。如:
  1933. * <pre><code class='language-js'>return {
  1934. * "Content-Type": "application/x-www-form-urlencoded",
  1935. * "Accept-Language": "en"
  1936. * };</code></pre>
  1937. */
  1938. "put": function(name, value){
  1939. try{
  1940. if ((typeof name)==="object"){
  1941. var _keys = Object.keys(name);
  1942. for (var i=0; i<_keys.length; i++){
  1943. if (bind.java_jaxrsHeaders) bind.java_jaxrsHeaders.put(_keys[i], name[_keys[i]]);
  1944. }
  1945. }else{
  1946. if (bind.java_jaxrsHeaders) bind.java_jaxrsHeaders.put(name, value);
  1947. }
  1948. }catch(e){}
  1949. },
  1950. /**
  1951. * @summary jaxrs方式的服务调用活动,“消息头脚本”中,删除已经设置消息头。
  1952. * @method remove
  1953. * @methodOf module:server.headers
  1954. * @static
  1955. * @param {String} [name] 要删除的消息头名称。
  1956. * @o2syntax
  1957. * this.headers.remove(name);
  1958. * @deprecated 不建议使用
  1959. */
  1960. "remove": function(name){
  1961. try{
  1962. if (bind.java_jaxrsHeaders) bind.java_jaxrsHeaders.remove(name);
  1963. }catch(e){}
  1964. }
  1965. };
  1966. //java_jaxrsResponse, type()
  1967. //java_jaxrsResponse, get() 字符串
  1968. //java_jaxwsResponse 直接返回不做处理
  1969. /**
  1970. * 用于流程配置的服务调用活动中的“响应脚本”,描述调用服务后得到的响应。(注意:调用方式为异步时,“响应脚本”不会执行)<br>
  1971. * @o2range 流程配置-服务调用活动中的“响应脚本”
  1972. * @module server.response
  1973. * @o2cn 服务调用的响应
  1974. * @o2category server.process
  1975. * @o2ordernumber 230
  1976. * @o2syntax
  1977. * var res = this.response;
  1978. */
  1979. bind.response = {};
  1980. /**
  1981. * @summary jaxrs方式的服务调用活动,请求返回的状态。有四个可能的值:
  1982. * <pre><code class="language-js">success : 表示请求成功
  1983. * warn : 当调用的是平台内部服务时,虽然请求成功,但产生了警告
  1984. * error : 请求调用错误
  1985. * connectFatal : 网络连接错误</code></pre>
  1986. * @member {String} status
  1987. * @memberOf server.module:response
  1988. * @o2syntax
  1989. * var status = this.response.status;
  1990. */
  1991. Object.defineProperty(bind.response, "status", {enumerable: true,configurable: true,
  1992. get: function(){ return (bind.java_jaxrsResponse) ? bind.java_jaxrsResponse.type() : ""; }
  1993. });
  1994. /**
  1995. * @summary 请求返回的值,如果是jaxrs服务,得到的是响应的文本,如果是jaxws服务,响应类型取决于服务的返回。
  1996. * @member {String|Any} value
  1997. * @memberOf server.module:response
  1998. * @o2syntax
  1999. * var value = this.response.value;
  2000. * @example
  2001. * //处理json对象的返回信息
  2002. * var value = this.response.value;
  2003. * var resData = JSON.parse(value);
  2004. */
  2005. Object.defineProperty(bind.response, "value", {enumerable: true,configurable: true,
  2006. get: function(){
  2007. if (bind.java_jaxrsResponse){
  2008. return bind.java_jaxrsResponse.get();
  2009. }else if(_self.jaxwsResponse){
  2010. return bind.java_jaxwsResponse;
  2011. }
  2012. }
  2013. });
  2014. /**
  2015. * @summary 获取请求返回的值,如果是jaxrs服务,会尽可能将响应数据转换为json对象,如果不能解析为json对象的,则返回文本,如果是jaxws服务,响应类型取决于服务的返回。
  2016. * @method get
  2017. * @methodOf server.module:response
  2018. * @static
  2019. * @return {Object|String|Any} 响应的内容.
  2020. * @o2syntax
  2021. * var res = this.response.get();
  2022. */
  2023. Object.defineProperty(bind.response, "get", {enumerable: true,configurable: true,
  2024. get: function(){
  2025. return function(){
  2026. if (bind.java_jaxrsResponse){
  2027. var value = bind.java_jaxrsResponse.get();
  2028. if (JSON.validate(value)){
  2029. return JSON.decode(value);
  2030. }
  2031. return value;
  2032. }else if(bind.java_jaxwsResponse){
  2033. return bind.java_jaxwsResponse || null
  2034. }
  2035. };
  2036. }
  2037. });
  2038. //-----------------------------------------------------------------------------------
  2039. //后端没有form
  2040. bind.form = null;
  2041. //java_requestText, 服务活动,请求数据字符串
  2042. /**
  2043. * 用于流程配置的服务活动中的“服务响应脚本”,描述发起服务的请求对象。<br>
  2044. * @o2range 流程配置-服务活动中的“响应脚本”
  2045. * @module server.request
  2046. * @o2cn 服务调用请求对象
  2047. * @o2category server.process
  2048. * @o2ordernumber 235
  2049. * @o2syntax
  2050. * var res = this.request;
  2051. */
  2052. bind.request = {
  2053. /**
  2054. * @summary 获取请求的body内容。
  2055. * @method getBody
  2056. * @methodOf server.module:request
  2057. * @static
  2058. * @return {Object|String} 请求的body内容,如果能转换为json,则返回json对象,否则返回请求的内容的文本.
  2059. * @o2syntax
  2060. * var req = this.request.getBody();
  2061. */
  2062. "getBody": function(){
  2063. try{
  2064. return JSON.parse(bind.java_requestText);
  2065. }catch(e){
  2066. return bind.java_requestText;
  2067. }
  2068. }
  2069. }
  2070. /**
  2071. * @summary 获取请求的body的原始内容。
  2072. * @member {String} text
  2073. * @memberOf server.module:request
  2074. * @o2syntax
  2075. * var req = this.request.text;
  2076. */
  2077. Object.defineProperties(bind, {
  2078. "text": {
  2079. "configurable": true,
  2080. "get": function(){return bind.java_requestText;}
  2081. }
  2082. });
  2083. //活动时效计算对象,流程时效得去掉
  2084. //java_expire,
  2085. //脚本返回JSON数据:
  2086. //{
  2087. // hour: 3 //几小时后超时
  2088. // workHour: 5 //几个工作小时后超时
  2089. // date: '2016-08-01' //到达指定时间后超时
  2090. //}
  2091. //设置指定的超时时间:
  2092. //this.expire.setDate([Date or String] date)
  2093. //设置几小时后超时:
  2094. //this.expire.setHour([Int] hour)
  2095. //设置几个工作小时后超时:
  2096. //this.expire.setWorkHour([Int] hour)
  2097. /**
  2098. * 用于流程配置的人工活动的“时效脚本”中,用于设置超时时间。可以通过设置小时数,工作小时数,和指定时间点来设置超时,如果全部设置,则优先级为:工作小时>小时>时间<br>
  2099. * @o2range 流程配置-人工活动中的“时效脚本”
  2100. * @module server.expire
  2101. * @o2cn 超时时间设置
  2102. * @o2category server.process
  2103. * @o2ordernumber 240
  2104. * @deprecated expire对象已经不建议使用了。建议return一个json对象的方式来设置超时时间。
  2105. * @example
  2106. * //设置超时时限为待办产生后5小时
  2107. * this.expire.setHour(5);
  2108. *
  2109. * //设置超时时限为待办产生后5个工作小时(只计算工作时间)
  2110. * this.expire.setWorkHour(5);
  2111. *
  2112. * //设置超时时限为指定时间,如业务数据中的设定的办理期限(processingTime)
  2113. * this.expire.setDate(this.data.processingTime);
  2114. *
  2115. * @example
  2116. * <caption>
  2117. * expire对象是为了兼容以前的版本。<br>
  2118. * <b>建议可以直接返回一个json对象来设置超时时间</b>
  2119. * </caption>
  2120. * //设置超时时限为待办产生后5小时
  2121. * return {"hour": 5};
  2122. *
  2123. * //设置超时时限为待办产生后5个工作小时(只计算工作时间)
  2124. * return {"workHour": 5};
  2125. *
  2126. * //设置超时时限为指定时间,如业务数据中的设定的办理期限(processingTime)
  2127. * return {"date": this.data.processingTime};
  2128. */
  2129. bind.expire = {
  2130. /**
  2131. * @summary 设置超时小时数。
  2132. * @method setHour
  2133. * @methodOf server.module:expire
  2134. * @static
  2135. * @param {Number} [hour] 超时的小时数。
  2136. * @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如:
  2137. * <pre><code class='language-js'>return {"hour": 5}</code></pre>
  2138. */
  2139. "setHour": function(hour){
  2140. try{bind.java_expire.setHour(hour);}catch(e){}
  2141. },
  2142. /**
  2143. * @summary 设置超时工作小时数。
  2144. * @method setWorkHour
  2145. * @methodOf server.module:expire
  2146. * @static
  2147. * @param {Number} [hour] 超时的工作小时数。
  2148. * @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如:
  2149. * <pre><code class='language-js'>return {"workHour": 5}</code></pre>
  2150. */
  2151. "setWorkHour": function(hour){
  2152. try{bind.java_expire.setWorkHour(hour);}catch(e){}
  2153. },
  2154. /**
  2155. * @summary 设置超时时间。
  2156. * @method setDate
  2157. * @methodOf server.module:expire
  2158. * @static
  2159. * YYYY-MM-DD HH:mm:SS
  2160. * @param {String} [date] 一个表示日期时间的字符串,按以下格式:
  2161. * <pre><code class="language-js">yyyy-MM-dd HH:mm:ss //如2021-09-12 18:26:51</code></pre>
  2162. * @deprecated 不建议使用,建议return一个json对象的方式来设置超时时间。如:
  2163. * <pre><code class='language-js'>return {"date": "2021-09-12 18:26:51"}</code></pre>
  2164. */
  2165. "setDate": function(date){
  2166. try{bind.java_expire.setDate(date);}catch(e){}
  2167. }
  2168. };
  2169. /**
  2170. * 在流程调用活动中。当启用流程等待的情况下,在"子流程成功后"、"子流程取消后"、"子流程完成后",三个事件脚本中,可以访问到embedData对象<br/>
  2171. * embedData对象就是被调用的子流程的业务数据,它是一个类似JSON的对象,您可以用访问JSON对象的方法访问embedData对象的所有数据。<br/>
  2172. * 如果您需要获取embedData的json文本,请使用embedData.toString()方法。<b>注意:JSON.stringify()方法不能用于embedData对象</b><br>
  2173. * 您可以通过work对象的embedCompleted值来判断被调用的子流程是否正常完成。 cancel end terminate
  2174. * <pre><code class='language-js'>
  2175. * var embedStatus = this.workContext.getWork().embedCompleted;
  2176. * if (embedStatus=="end"){
  2177. * //被调用的子流程正常流转到了结束活动
  2178. * }
  2179. * if (embedStatus=="cancel"){
  2180. * //被调用的子流程流转到了取消活动
  2181. * }
  2182. * if (embedStatus=="terminate"){
  2183. * //被调用的子流程被终止了
  2184. * }
  2185. * </code></pre>
  2186. * @o2range 流程配置-流程调用活动中,当启用流程等待的情况下,在"子流程成功后"、"子流程取消后"、"子流程完成后",三个事件中可用
  2187. * @module server.embedData
  2188. * @o2cn 调用活动的子流程业务数据
  2189. * @o2category server.process
  2190. * @o2ordernumber 205
  2191. * @example
  2192. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下:
  2193. * var embedData = this.embedData;
  2194. */
  2195. var o= {
  2196. "context": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getContext() : null)} },
  2197. "applications": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getApplications() : null)} },
  2198. "organization": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getOrganization() : null)} },
  2199. // "service": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getWebservicesClient() : null)} },
  2200. "currentPerson": { "configurable": true, "get": function(){return (bind.java_effectivePerson || null)} },
  2201. "effectivePerson": { "configurable": true, "get": function(){return (bind.java_effectivePerson || null)} },
  2202. "resources": { "configurable": true, "get": function(){return (bind.java_resources || null)} }
  2203. }
  2204. Object.defineProperties(bind, o);
  2205. /* 清除 engine */
  2206. this.engine = null;