initialServiceScriptText.js 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  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. library.defineProperties(Array.prototype, o);
  101. })();
  102. bind.library = library;
  103. //print 重载, console, Error
  104. if (!bind.oPrint) bind.oPrint = print;
  105. var print = function(str, type){
  106. var d = new Date();
  107. var t = (type || "PRINT").toUpperCase();
  108. var l = "[Script]";
  109. bind.oPrint(d.format("db")+"."+d.getMilliseconds()+" "+t+" "+l+" "+str);
  110. }
  111. var _parsePrint = function(str){
  112. if (!str && str!==0 && str!==false) return str;
  113. var text = (typeOf(str)!=="string") ? str.toString() : str;
  114. try{
  115. var i = 1;
  116. while (text.indexOf("%s")!==-1 && i<arguments.length){
  117. text = text.replace(/\%s/, arguments[i].toString());
  118. i++;
  119. }
  120. while (i<arguments.length){
  121. text += " "+arguments[i].toString();
  122. i++;
  123. }
  124. }catch(e){}
  125. return text;
  126. };
  127. var console = {
  128. log: function(){ print(_parsePrint.apply(this, arguments)); },
  129. error: function(){ print("[ERROR] "+_parsePrint.apply(this, arguments)); },
  130. info: function(){ print("[INFO] "+_parsePrint.apply(this, arguments)); },
  131. warn: function(){ print("[WARN] "+_parsePrint.apply(this, arguments)); }
  132. }
  133. var Error = function(msg){
  134. this.msg = msg;
  135. }
  136. Error.prototype.toString = function(){
  137. return this.msg;
  138. }
  139. var exec = function(code, _self){
  140. var returnValue;
  141. //try{
  142. if (!_self) _self = this;
  143. try {
  144. var f = eval("(function(){return function(){\n"+code+"\n}})();");
  145. returnValue = f.apply(_self);
  146. }catch(e){
  147. console.log("exec", new Error("exec script error"));
  148. console.log(e);
  149. }
  150. return returnValue;
  151. }
  152. bind.print = print;
  153. bind.exec = exec;
  154. //方法定义
  155. bind.define = function(name, fun, overwrite){
  156. var over = true;
  157. if (overwrite===false) over = false;
  158. var o = {};
  159. o[name] = {"value": fun, "configurable": over};
  160. library.defineProperties(bind, o);
  161. }
  162. //restful服务Action
  163. bind.Action = function(root, json){
  164. this.actions = json;
  165. // Object.keys(json).forEach(function(key){
  166. // this.actions[key] = json[key];
  167. // });
  168. //Object.merge(actions[root], json);
  169. this.root = root;
  170. //this.actions = actions[root];
  171. var invokeFunction = function(service, parameters, key){
  172. var _self = this;
  173. return function(){
  174. var i = parameters.length-1;
  175. var n = arguments.length;
  176. var functionArguments = arguments;
  177. var parameter = {};
  178. var success, failure, async, data, file;
  179. if (typeOf(functionArguments[0])==="function"){
  180. i=-1;
  181. success = (n>++i) ? functionArguments[i] : null;
  182. failure = (n>++i) ? functionArguments[i] : null;
  183. parameters.each(function(p, x){
  184. parameter[p] = (n>++i) ? functionArguments[i] : null;
  185. });
  186. if (service.method && (service.method.toLowerCase()==="post" || service.method.toLowerCase()==="put")){
  187. data = (n>++i) ? functionArguments[i] : null;
  188. }
  189. }else{
  190. parameters.each(function(p, x){
  191. parameter[p] = (n>x) ? functionArguments[x] : null;
  192. });
  193. if (service.method && (service.method.toLowerCase()==="post" || service.method.toLowerCase()==="put")){
  194. data = (n>++i) ? functionArguments[i] : null;
  195. }
  196. success = (n>++i) ? functionArguments[i] : null;
  197. failure = (n>++i) ? functionArguments[i] : null;
  198. }
  199. return _self.invoke({"name": key, "data": data, "parameter": parameter, "success": success, "failure": failure});
  200. };
  201. };
  202. var createMethod = function(service, key){
  203. var jaxrsUri = service.uri;
  204. var re = new RegExp("\{.+?\}", "g");
  205. var replaceWords = jaxrsUri.match(re);
  206. var parameters = [];
  207. if (replaceWords) parameters = replaceWords.map(function(s){
  208. return s.substring(1,s.length-1);
  209. });
  210. this[key] = invokeFunction.call(this, service, parameters, key);
  211. };
  212. Object.keys(this.actions).forEach(function(key){
  213. var service = this.actions[key];
  214. if (service.uri) if (!this[key]) createMethod.call(this, service, key);
  215. }, this);
  216. this.invoke = function(option){
  217. if (this.actions[option.name]){
  218. var uri = this.actions[option.name].uri;
  219. var method = this.actions[option.name].method || "get";
  220. if (option.parameter){
  221. Object.keys(option.parameter).forEach(function(key){
  222. var v = option.parameter[key];
  223. uri = uri.replace("{"+key+"}", v);
  224. });
  225. }
  226. var res = null;
  227. try{
  228. switch (method.toLowerCase()){
  229. case "get":
  230. res = bind.applications.getQuery(this.root, uri);
  231. break;
  232. case "post":
  233. res = bind.applications.postQuery(this.root, uri, JSON.stringify(option.data));
  234. break;
  235. case "put":
  236. res = bind.applications.putQuery(this.root, uri, JSON.stringify(option.data));
  237. break;
  238. case "delete":
  239. res = bind.applications.deleteQuery(this.root, uri);
  240. break;
  241. default:
  242. res = bind.applications.getQuery(this.root, uri);
  243. }
  244. if (res && res.getType().toString()==="success"){
  245. var json = JSON.parse(res.toString());
  246. if (option.success) option.success(json);
  247. }else{
  248. if (option.failure) option.failure(((res) ? JSON.parse(res.toString()) : null));
  249. }
  250. return res;
  251. }catch(e){
  252. if (option.failure) option.failure(e);
  253. }
  254. }
  255. };
  256. }
  257. bind.Action.applications = bind.applications;
  258. bind.Actions = {
  259. "loadedActions": {},
  260. "load": function(root){
  261. if (this.loadedActions[root]) return this.loadedActions[root];
  262. var jaxrsString = bind.applications.describeApi(root);
  263. var json = JSON.parse(jaxrsString.toString());
  264. if (json && json.jaxrs){
  265. var actionObj = {};
  266. json.jaxrs.each(function(o){
  267. if (o.methods && o.methods.length){
  268. var actions = {};
  269. o.methods.each(function(m){
  270. var o = {"uri": "/"+m.uri};
  271. if (m.method) o.method = m.method;
  272. if (m.enctype) o.enctype = m.enctype;
  273. actions[m.name] = o;
  274. }.bind(this));
  275. actionObj[o.name] = new bind.Action(root, actions);
  276. }
  277. }.bind(this));
  278. this.loadedActions[root] = actionObj;
  279. return actionObj;
  280. }
  281. return null;
  282. }
  283. };
  284. //组织相关
  285. var getNameFlag = function(name){
  286. var t = library.typeOf(name);
  287. if (t==="array"){
  288. var v = [];
  289. name.forEach(function(id){
  290. v.push((library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  291. });
  292. return v;
  293. }else{
  294. return [(t==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  295. }
  296. };
  297. bind.org = {
  298. "group": function() { return this.oGroup},
  299. "identity": function() { return this.oIdentity},
  300. "person": function() { return this.oPerson},
  301. "personAttribute": function() { return this.oPersonAttribute},
  302. "role": function() { return this.oRole},
  303. "unit": function() { return this.oUnit},
  304. "unitAttribute": function() { return this.oUnitAttribute},
  305. "unitDuty": function() { return this.oUnitDuty},
  306. "getObject": function(o, v){
  307. var arr = [];
  308. if (!v || !v.length){
  309. return null;
  310. }else{
  311. for (var i=0; i<v.length; i++){
  312. var g = o.getObject(v[i]);
  313. if (g) arr.push(JSON.parse(g.toString()));
  314. }
  315. }
  316. return arr;
  317. },
  318. //群组***************
  319. //获取群组--返回群组的对象数组
  320. getGroup: function(name){
  321. var v = this.oGroup.listObject(getNameFlag(name));
  322. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  323. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  324. },
  325. //查询下级群组--返回群组的对象数组
  326. //nested 布尔 true嵌套下级;false直接下级;默认false;
  327. listSubGroup: function(name, nested){
  328. var v = null;
  329. if (nested){
  330. v = this.oGroup.listWithGroupSubNested(getNameFlag(name));
  331. }else{
  332. v = this.oGroup.listWithGroupSubDirect(getNameFlag(name));
  333. }
  334. return this.getObject(this.oGroup, v);
  335. },
  336. //查询上级群组--返回群组的对象数组
  337. //nested 布尔 true嵌套上级;false直接上级;默认false;
  338. listSupGroup:function(name, nested){
  339. var v = null;
  340. if (nested){
  341. v = this.oGroup.listWithGroupSupNested(getNameFlag(name));
  342. }else{
  343. v = this.oGroup.listWithGroupSupDirect(getNameFlag(name));
  344. }
  345. return this.getObject(this.oGroup, v);
  346. },
  347. //人员所在群组(嵌套)--返回群组的对象数组
  348. listGroupWithPerson:function(name){
  349. var v = this.oGroup.listWithPerson(getNameFlag(name));
  350. return this.getObject(this.oGroup, v);
  351. },
  352. //群组是否拥有角色--返回true, false
  353. groupHasRole: function(name, role){
  354. nameFlag = (library.typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  355. return this.oGroup.hasRole(nameFlag, getNameFlag(role));
  356. },
  357. //角色***************
  358. //获取角色--返回角色的对象数组
  359. getRole: function(name){
  360. var v = this.oRole.listObject(getNameFlag(name));
  361. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  362. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  363. },
  364. //人员所有角色(嵌套)--返回角色的对象数组
  365. listRoleWithPerson:function(name){
  366. var v = this.oRole.listWithPerson(getNameFlag(name));
  367. return this.getObject(this.oRole, v);
  368. },
  369. //人员***************
  370. //人员是否拥有角色--返回true, false
  371. personHasRole: function(name, role){
  372. nameFlag = (library.typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  373. return this.oPerson.hasRole(nameFlag, getNameFlag(role));
  374. },
  375. //获取人员,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
  376. getPersonData: function(name){
  377. var v = this.oPerson.getExt(name);
  378. var v_json = (!v) ? null: JSON.parse(v.toString());
  379. return v_json;
  380. },
  381. //获取人员--返回人员的对象数组
  382. getPerson: function(name, findCN){
  383. var v = this.oPerson.listObject(getNameFlag(name), !!findCN);
  384. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  385. // if (!v || !v.length) v = null;
  386. // return (v && v.length===1) ? v[0] : v;
  387. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  388. },
  389. //查询下级人员--返回人员的对象数组
  390. //nested 布尔 true嵌套下级;false直接下级;默认false;
  391. listSubPerson: function(name, nested){
  392. var v = null;
  393. if (nested){
  394. v = this.oPerson.listWithPersonSubNested(getNameFlag(name));
  395. }else{
  396. v = this.oPerson.listWithPersonSubDirect(getNameFlag(name));
  397. }
  398. return this.getObject(this.oPerson, v);
  399. },
  400. //查询上级人员--返回人员的对象数组
  401. //nested 布尔 true嵌套上级;false直接上级;默认false;
  402. listSupPerson: function(name, nested){
  403. var v = null;
  404. if (nested){
  405. v = this.oPerson.listWithPersonSupNested(getNameFlag(name));
  406. }else{
  407. v = this.oPerson.listWithPersonSupDirect(getNameFlag(name));
  408. }
  409. return this.getObject(this.oPerson, v);
  410. },
  411. //获取群组的所有人员--返回人员的对象数组
  412. listPersonWithGroup: function(name){
  413. var v = this.oPerson.listWithGroup(getNameFlag(name));
  414. return this.getObject(this.oPerson, v);
  415. // if (!v || !v.length) v = null;
  416. // return v;
  417. // var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  418. // return v_json;
  419. },
  420. //获取角色的所有人员--返回人员的对象数组
  421. listPersonWithRole: function(name){
  422. var v = this.oPerson.listWithRole(getNameFlag(name));
  423. return this.getObject(this.oPerson, v);
  424. },
  425. //获取身份的所有人员--返回人员的对象数组
  426. listPersonWithIdentity: function(name){
  427. var v = this.oPerson.listWithIdentity(getNameFlag(name));
  428. return this.getObject(this.oPerson, v);
  429. },
  430. //获取身份的所有人员--返回人员的对象数组
  431. getPersonWithIdentity: function(name){
  432. var v = this.oPerson.listWithIdentity(getNameFlag(name));
  433. var arr = this.getObject(this.oPerson, v);
  434. return (arr && arr.length) ? arr[0] : null;
  435. },
  436. //查询组织成员的人员--返回人员的对象数组
  437. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  438. listPersonWithUnit: function(name, nested){
  439. var v = null;
  440. if (nested){
  441. v = this.oPerson.listWithUnitSubNested(getNameFlag(name));
  442. }else{
  443. v = this.oPerson.listWithUnitSubDirect(getNameFlag(name));
  444. }
  445. return this.getObject(this.oPerson, v);
  446. },
  447. //人员属性************
  448. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  449. appendPersonAttribute: function(person, attr, values){
  450. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  451. return this.oPersonAttribute.appendWithPersonWithName(personFlag, attr, values);
  452. },
  453. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  454. setPersonAttribute: function(person, attr, values){
  455. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  456. return this.oPersonAttribute.setWithPersonWithName(personFlag, attr, values);
  457. },
  458. //获取人员属性值
  459. getPersonAttribute: function(person, attr){
  460. var personFlag = (library.typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  461. var v = this.oPersonAttribute.listAttributeWithPersonWithName(personFlag, attr);
  462. var v_json = [];
  463. if (v && v.length){
  464. for (var i=0; i<v.length; i++){
  465. v_json.push(v[i].toString());
  466. }
  467. }
  468. return v_json;
  469. },
  470. //列出人员所有属性的名称
  471. listPersonAttributeName: function(name){
  472. var p = getNameFlag(name);
  473. var nameList = [];
  474. for (var i=0; i<p.length; i++){
  475. var v = this.oPersonAttribute.listNameWithPerson(p[i]);
  476. if (v && v.length){
  477. for (var j=0; j<v.length; j++){
  478. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  479. }
  480. }
  481. }
  482. return nameList;
  483. },
  484. //列出人员的所有属性
  485. //listPersonAllAttribute: function(name){
  486. // getOrgActions();
  487. // var data = {"personList":getNameFlag(name)};
  488. // var v = null;
  489. // orgActions.listPersonAllAttribute(data, function(json){v = json.data;}, null, false);
  490. // return v;
  491. //},
  492. //身份**********
  493. //获取身份
  494. getIdentity: function(name){
  495. var v = this.oIdentity.listObject(getNameFlag(name));
  496. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  497. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  498. // if (!v || !v.length) v = null;
  499. // return (v && v.length===1) ? v[0] : v;
  500. },
  501. //列出人员的身份
  502. listIdentityWithPerson: function(name){
  503. var v = this.oIdentity.listWithPerson(getNameFlag(name));
  504. return this.getObject(this.oIdentity, v);
  505. },
  506. //查询组织成员身份--返回身份的对象数组
  507. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  508. listIdentityWithUnit: function(name, nested){
  509. var v = null;
  510. if (nested){
  511. v = this.oIdentity.listWithUnitSubNested(getNameFlag(name));
  512. }else{
  513. v = this.oIdentity.listWithUnitSubDirect(getNameFlag(name));
  514. }
  515. return this.getObject(this.oIdentity, v);
  516. },
  517. //组织**********
  518. //获取组织
  519. getUnit: function(name, findCN){
  520. var v = this.oUnit.listObject(getNameFlag(name), !!findCN);
  521. var v_json = (!v || !v.length) ? null: JSON.parse(v.toString());
  522. return (v_json && v_json.length===1) ? v_json[0] : v_json;
  523. // if (!v || !v.length) v = null;
  524. // return (v && v.length===1) ? v[0] : v;
  525. },
  526. //查询组织的下级--返回组织的对象数组
  527. //nested 布尔 true嵌套下级;false直接下级;默认false;
  528. listSubUnit: function(name, nested){
  529. var v = null;
  530. if (nested){
  531. v = this.oUnit.listWithUnitSubNested(getNameFlag(name));
  532. }else{
  533. v = this.oUnit.listWithUnitSubDirect(getNameFlag(name));
  534. }
  535. return this.getObject(this.oUnit, v);
  536. },
  537. //查询组织的上级--返回组织的对象数组
  538. //nested 布尔 true嵌套上级;false直接上级;默认false;
  539. listSupUnit: function(name, nested){
  540. var v = null;
  541. if (nested){
  542. v = this.oUnit.listWithUnitSupNested(getNameFlag(name));
  543. }else{
  544. v = this.oUnit.listWithUnitSupDirect(getNameFlag(name));
  545. }
  546. return this.getObject(this.oUnit, v);
  547. },
  548. //根据个人身份获取组织
  549. //flag 数字 表示获取第几层的组织
  550. // 字符串 表示获取指定类型的组织
  551. // 空 表示获取直接所在的组织
  552. getUnitByIdentity: function(name, flag){
  553. //getOrgActions();
  554. var getUnitMethod = "current";
  555. var v;
  556. if (flag){
  557. if (library.typeOf(flag)==="string") getUnitMethod = "type";
  558. if (library.typeOf(flag)==="number") getUnitMethod = "level";
  559. }
  560. var n = getNameFlag(name)[0];
  561. switch (getUnitMethod){
  562. case "current":
  563. v = this.oUnit.getWithIdentity(n);
  564. break;
  565. case "type":
  566. v = this.oUnit.getWithIdentityWithType(n, flag);
  567. break;
  568. case "level":
  569. v = this.oUnit.getWithIdentityWithLevel(n, flag);
  570. break;
  571. }
  572. var o = this.getObject(this.oUnit, [v]);
  573. return (o && o.length===1) ? o[0] : o;
  574. },
  575. //列出身份所在组织的所有上级组织
  576. listAllSupUnitWithIdentity: function(name){
  577. var v = this.oUnit.listWithIdentitySupNested(getNameFlag(name));
  578. return this.getObject(this.oUnit, v);
  579. },
  580. //获取人员所在的所有组织(直接所在组织)
  581. listUnitWithPerson: function(name){
  582. var v = this.oUnit.listWithPerson(getNameFlag(name));
  583. return this.getObject(this.oUnit, v);
  584. },
  585. //列出人员所在组织的所有上级组织
  586. listAllSupUnitWithPerson: function(name){
  587. var v = this.oUnit.listWithPersonSupNested(getNameFlag(name));
  588. return this.getObject(this.oUnit, v);
  589. },
  590. //根据组织属性,获取所有符合的组织
  591. listUnitWithAttribute: function(name, attribute){
  592. var v = this.oUnit.listWithUnitAttribute(name, attribute);
  593. return this.getObject(this.oUnit, v);
  594. },
  595. //根据组织职务,获取所有符合的组织
  596. listUnitWithDuty: function(name, id){
  597. var idflag = (library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id;
  598. var v = this.oUnit.listWithUnitDuty(name, idflag);
  599. return this.getObject(this.oUnit, v);
  600. },
  601. //组织职务***********
  602. //获取指定的组织职务的身份
  603. getDuty: function(duty, id){
  604. var unit = (library.typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id;
  605. var v = this.oUnitDuty.listIdentityWithUnitWithName(unit, duty);
  606. return this.getObject(this.oIdentity, v);
  607. },
  608. //获取身份的所有职务名称
  609. listDutyNameWithIdentity: function(name){
  610. var ids = getNameFlag(name);
  611. var nameList = [];
  612. for (var i=0; i<ids.length; i++){
  613. var v = this.oUnitDuty.listNameWithIdentity(ids[i]);
  614. if (v && v.length){
  615. for (var j=0; j<v.length; j++){
  616. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  617. }
  618. }
  619. }
  620. return nameList;
  621. },
  622. //获取组织的所有职务名称
  623. listDutyNameWithUnit: function(name){
  624. var ids = getNameFlag(name);
  625. var nameList = [];
  626. for (var i=0; i<ids.length; i++){
  627. var v = this.oUnitDuty.listNameWithUnit(ids[i]);
  628. if (v && v.length){
  629. for (var j=0; j<v.length; j++){
  630. if (nameList.indexOf(v[j])==-1) nameList.push(v[j].toString());
  631. }
  632. }
  633. }
  634. return nameList;
  635. },
  636. //获取组织的所有职务
  637. listUnitAllDuty: function(name){
  638. var u = getNameFlag(name)[0];
  639. var ds = this.oUnitDuty.listNameWithUnit(u);
  640. var o = []
  641. for (var i=0; i<ds.length; i++){
  642. v = this.oUnitDuty.listIdentityWithUnitWithName(u, ds[i]);
  643. o.push({"name": ds[i], "identityList": this.getObject(this.oIdentity, v)});
  644. }
  645. return o;
  646. },
  647. //组织属性**************
  648. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  649. appendUnitAttribute: function(unit, attr, values){
  650. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  651. return this.oUnitAttribute.appendWithUnitWithName(unitFlag, attr, values);
  652. },
  653. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  654. setUnitAttribute: function(unit, attr, values){
  655. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  656. return this.oUnitAttribute.setWithUnitWithName(unitFlag, attr, values);
  657. },
  658. //获取组织属性值
  659. getUnitAttribute: function(unit, attr){
  660. var unitFlag = (library.typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  661. var v = this.oUnitAttribute.listAttributeWithUnitWithName(unitFlag, attr);
  662. var v_json = [];
  663. if (v && v.length){
  664. for (var i=0; i<v.length; i++){
  665. v_json.push(v[i].toString());
  666. }
  667. }
  668. return v_json;
  669. },
  670. //列出组织所有属性的名称
  671. listUnitAttributeName: function(name){
  672. var p = getNameFlag(name);
  673. var nameList = [];
  674. for (var i=0; i<p.length; i++){
  675. var v = this.oUnitAttribute.listNameWithUnit(p[i]);
  676. if (v && v.length){
  677. for (var j=0; j<v.length; j++){
  678. if (nameList.indexOf(v[j])==-1) nameList.push(v[j]);
  679. }
  680. }
  681. }
  682. return nameList;
  683. },
  684. //列出组织的所有属性
  685. listUnitAllAttribute: function(name){
  686. var u = getNameFlag(name)[0];
  687. var ds = this.oUnitAttribute.listNameWithUnit(u);
  688. var o = []
  689. for (var i=0; i<ds.length; i++){
  690. v = this.getUnitAttribute(u, ds[i]);
  691. o.push({"name": ds[i], "valueList":v});
  692. }
  693. return o;
  694. }
  695. };
  696. library.defineProperties(bind.org, {
  697. "oGroup": { "configurable": true, "get": function(){return bind.organization.group()} },
  698. "oIdentity": { "configurable": true, "get": function(){return bind.organization.identity()} },
  699. "oPerson": { "configurable": true, "get": function(){return bind.organization.person()} },
  700. "oPersonAttribute": { "configurable": true, "get": function(){return bind.organization.personAttribute()} },
  701. "oRole": { "configurable": true, "get": function(){return bind.organization.role()} },
  702. "oUnit": { "configurable": true, "get": function(){return bind.organization.unit()} },
  703. "oUnitAttribute": { "configurable": true, "get": function(){return bind.organization.unitAttribute()} },
  704. "oUnitDuty": { "configurable": true, "get": function(){return bind.organization.unitDuty()} }
  705. });
  706. //定义所需的服务
  707. bind.processActions = new bind.Action("x_processplatform_assemble_surface", {
  708. "getDictionary": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{applicationFlag}"},
  709. "getDictRoot": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/data"},
  710. "getDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data"},
  711. "setDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "PUT"},
  712. "addDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "POST"},
  713. "deleteDictData": {"uri": "/jaxrs/applicationdict/{applicationDict}/application/{application}/{path}/data", "method": "DELETE"},
  714. "getScript": {"uri": "/jaxrs/script/{flag}/application/{applicationFlag}", "method": "POST"},
  715. });
  716. bind.cmsActions = new bind.Action("x_cms_assemble_control", {
  717. "getDictionary": {"uri": "/jaxrs/design/appdict/{appDictId}"},
  718. "getDictRoot": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/data"},
  719. "getDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data"},
  720. "setDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "PUT"},
  721. "addDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "POST"},
  722. "deleteDictData": {"uri": "/jaxrs/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data", "method": "DELETE"},
  723. "getDictRootAnonymous" : {"uri": "/jaxrs/anonymous/surface/appdict/{appDictId}/appInfo/{appId}/data"},
  724. "getDictDataAnonymous" : {"uri": "/jaxrs/anonymous/surface/appdict/{appDictId}/appInfo/{appId}/{path}/data"},
  725. "getScript": {"uri": "/jaxrs/script/{flag}/appInfo/{appInfoFlag}", "method": "POST"},
  726. });
  727. bind.portalActions = new bind.Action("x_portal_assemble_surface", {
  728. "getDictionary": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}"},
  729. "getDictRoot": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/data"},
  730. "getDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data"},
  731. "setDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "PUT"},
  732. "addDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "POST"},
  733. "deleteDictData": {"uri": "/jaxrs/dict/{dictFlag}/portal/{portalFlag}/{path}/data", "method": "DELETE"},
  734. "getScript": {"uri": "/jaxrs/script/portal/{portal}/name/{name}","method": "POST"}
  735. });
  736. bind.serviceActions = new bind.Action("x_program_center", {
  737. "getDictionary": {"uri": "/jaxrs/dict/{id}"},
  738. "getDictRoot": {"uri": "/jaxrs/dict/{dictFlag}/data"},
  739. "getDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data"},
  740. "setDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "PUT"},
  741. "addDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "POST"},
  742. "deleteDictData": {"uri": "/jaxrs/dict/{dictFlag}/{path}/data", "method": "DELETE"},
  743. "getScript": {"uri": "/jaxrs/script/name/{name}","method": "POST"}
  744. });
  745. //include 引用脚本
  746. //optionsOrName : {
  747. // type : "", 默认为process, 可以为 portal process cms
  748. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  749. // name : "" // 脚本名称/别名/id
  750. //}
  751. //或者name: "" // 脚本名称/别名/id
  752. var includedScripts = bind.includedScripts || {};
  753. bind.includedScripts = includedScripts;
  754. bind.include = function( optionsOrName , callback ){
  755. var options = optionsOrName;
  756. if( typeOf( options ) == "string" ){
  757. options = { name : options };
  758. }
  759. var name = options.name;
  760. var type;
  761. if( options.type === "service" ){
  762. type = options.type;
  763. }else{
  764. type = ( options.type && options.application ) ? options.type : "service";
  765. }
  766. var application = type === "service" ? "service" : options.application;
  767. if (!name || !type || !application){
  768. console.log("include", new Error("can not find script. missing script name or application"));
  769. return false;
  770. }
  771. if (!includedScripts[application]) includedScripts[application] = [];
  772. if (includedScripts[application].indexOf( name )> -1){
  773. if (callback) callback.apply(this);
  774. return;
  775. }
  776. var scriptAction;
  777. var scriptData;
  778. switch ( type ){
  779. case "portal" :
  780. bind.portalActions.getScript( application, name, {"importedList":includedScripts[application]}, function(json){
  781. if (json.data){
  782. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  783. scriptData = json.data;
  784. }
  785. }.bind(this));
  786. break;
  787. case "process" :
  788. bind.processActions.getScript( name, application, {"importedList":includedScripts[application]}, function(json){
  789. if (json.data){
  790. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  791. scriptData = json.data;
  792. }
  793. }.bind(this));
  794. break;
  795. case "cms" :
  796. bind.cmsActions.getScript(name, application, {"importedList":includedScripts[application]}, function(json){
  797. if (json.data){
  798. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  799. scriptData = json.data;
  800. }
  801. }.bind(this));
  802. break;
  803. case "service" :
  804. bind.serviceActions.getScript(name, {"importedList":includedScripts[application]}, function(json){
  805. if (json.data){
  806. includedScripts[application] = includedScripts[application].concat(json.data.importedList);
  807. scriptData = json.data;
  808. }
  809. }.bind(this));
  810. break;
  811. }
  812. includedScripts[application].push(name);
  813. if (scriptData && scriptData.text){
  814. exec(scriptData.text, this);
  815. if (callback) callback.apply(this);
  816. }
  817. };
  818. //optionsOrName : {
  819. // type : "", //默认为process, 可以为 process cms
  820. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  821. // name : "", // 数据字典名称/别名/id
  822. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  823. //}
  824. //或者name: "" // 数据字典名称/别名/id
  825. bind.Dict = function(optionsOrName){
  826. var options = optionsOrName;
  827. if( typeOf( options ) == "string" ){
  828. options = { name : options };
  829. }
  830. var name = this.name = options.name;
  831. var type;
  832. if( options.type === "service"){
  833. type = options.type;
  834. }else{
  835. type = ( options.type && options.application ) ? options.type : "service";
  836. }
  837. var applicationId = options.application;
  838. var enableAnonymous = options.enableAnonymous || false;
  839. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  840. var action;
  841. if( type == "cms" ){
  842. action = bind.cmsActions;
  843. }else if( type == "service" ){
  844. action = bind.serviceActions;
  845. }else if( type == "portal" ){
  846. action = bind.portalActions;
  847. }else{
  848. action = bind.processActions;
  849. }
  850. var encodePath = function( path ){
  851. var arr = path.split(/\./g);
  852. var ar = arr.map(function(v){
  853. return encodeURIComponent(v);
  854. });
  855. return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/");
  856. };
  857. this.get = function(path, success, failure){
  858. var value = null;
  859. if( type === "service" ){
  860. if (path){
  861. var p = encodePath( path );
  862. action.getDictData(encodeURIComponent(this.name), p, function(json){
  863. value = json.data;
  864. if (success) success(json.data);
  865. }, function(xhr, text, error){
  866. if (failure) failure(xhr, text, error);
  867. });
  868. }else{
  869. action.getDictRoot(encodeURIComponent(this.name), function(json){
  870. value = json.data;
  871. if (success) success(json.data);
  872. }, function(xhr, text, error){
  873. if (failure) failure(xhr, text, error);
  874. }, false);
  875. }
  876. }else{
  877. if (path){
  878. var p = encodePath( path );
  879. action[(enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData"](encodeURIComponent(this.name), applicationId, p, function(json){
  880. value = json.data;
  881. if (success) success(json.data);
  882. }, function(xhr, text, error){
  883. if (failure) failure(xhr, text, error);
  884. });
  885. }else{
  886. action[(enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot"](encodeURIComponent(this.name), applicationId, function(json){
  887. value = json.data;
  888. if (success) success(json.data);
  889. }, function(xhr, text, error){
  890. if (failure) failure(xhr, text, error);
  891. }, false);
  892. }
  893. }
  894. return value;
  895. };
  896. this.set = function(path, value, success, failure){
  897. var p = encodePath( path );
  898. //var p = path.replace(/\./g, "/");
  899. if( type === "service" ){
  900. action.setDictData(encodeURIComponent(this.name), p, value, function(json){
  901. if (success) success(json.data);
  902. }, function(xhr, text, error){
  903. if (failure) failure(xhr, text, error);
  904. }, false, false);
  905. }else{
  906. action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  907. if (success) success(json.data);
  908. }, function(xhr, text, error){
  909. if (failure) failure(xhr, text, error);
  910. }, false, false);
  911. }
  912. };
  913. this.add = function(path, value, success, failure){
  914. var p = encodePath( path );
  915. //var p = path.replace(/\./g, "/");
  916. if( type === "service" ) {
  917. action.addDictData(encodeURIComponent(this.name), p, value, function(json){
  918. if (success) success(json.data);
  919. }, function(xhr, text, error){
  920. if (failure) failure(xhr, text, error);
  921. }, false, false);
  922. }else{
  923. action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  924. if (success) success(json.data);
  925. }, function(xhr, text, error){
  926. if (failure) failure(xhr, text, error);
  927. }, false, false);
  928. }
  929. };
  930. this["delete"] = function(path, success, failure){
  931. var p = encodePath( path );
  932. //var p = path.replace(/\./g, "/");
  933. if( type === "service" ) {
  934. action.deleteDictData(encodeURIComponent(this.name), p, function(json){
  935. if (success) success(json.data);
  936. }, function(xhr, text, error){
  937. if (failure) failure(xhr, text, error);
  938. }, false, false);
  939. }else{
  940. action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  941. if (success) success(json.data);
  942. }, function(xhr, text, error){
  943. if (failure) failure(xhr, text, error);
  944. }, false, false);
  945. }
  946. };
  947. this.destory = this["delete"];
  948. };
  949. bind.Table = function(name){
  950. this.name = name;
  951. this.action = Actions.load("x_query_assemble_surface").TableAction;
  952. this.listRowNext = function(id, count, success, error, async){
  953. this.action.listRowNext(this.name, id, count, success, error, async);
  954. };
  955. this.listRowPrev = function(id, count, success, error, async){
  956. this.action.listRowPrev(this.name, id, count, success, error, async);
  957. };
  958. this.listRowSelect = function(where, orderBy, size, success, error, async){
  959. this.action.listRowSelect(this.name, {"where": where, "orderBy": orderBy, "size": size || ""}, success, error, async);
  960. };
  961. this.listRowSelectWhere = function(where, success, error, async){
  962. this.action.listRowSelectWhere(this.name, where, success, error, async);
  963. };
  964. this.rowCountWhere = function(where, success, error, async){
  965. this.action.rowCountWhere(this.name, where, success, error, async);
  966. };
  967. this.deleteRow = function(id, success, error, async){
  968. this.action.rowDelete(this.name, id, success, error, async);
  969. };
  970. this.deleteAllRow = function(success, error, async){
  971. this.action.rowDeleteAll(this.name, success, error, async);
  972. };
  973. this.getRow = function(id, success, error, async){
  974. this.action.rowGet(this.name, id, success, error, async);
  975. };
  976. this.insertRow = function(data, success, error, async){
  977. this.action.rowInsert(this.name, data, success, error, async);
  978. };
  979. this.addRow = function(data, success, error, async){
  980. this.action.rowInsertOne(this.name, data, success, error, async);
  981. };
  982. this.updateRow = function(id, data, success, error, async){
  983. this.action.rowUpdate(this.name, id, data, success, error, async);
  984. };
  985. }
  986. bind.statement = {
  987. execute: function (obj, callback) {
  988. if( obj.format ){
  989. return this._execute(obj, callback, obj.format);
  990. }else{
  991. if( this.needCheckFormat(obj) ){
  992. var value;
  993. var _self = this;
  994. bind.Actions.load("x_query_assemble_surface").StatementAction.getFormat(obj.name, function(json){
  995. value = _self._execute(obj, callback, json.data.format);
  996. });
  997. return value;
  998. }else{
  999. return this._execute(obj, callback, "");
  1000. }
  1001. }
  1002. },
  1003. needCheckFormat: function(s){
  1004. if( s.format )return false;
  1005. if( typeOf(s.parameter) === "object" ){
  1006. for( var p in s.parameter ){
  1007. if( typeOf( s.parameter[p] ) === "date" )return true;
  1008. }
  1009. }
  1010. if( typeOf(s.filter) === "array" ){
  1011. for( var i=0; i< s.filter.length; i++){
  1012. var fType = s.filter[i].formatType;
  1013. if( ["dateTimeValue", "datetimeValue", "dateValue", "timeValue"].indexOf( fType ) > -1 )return true;
  1014. }
  1015. }
  1016. return false;
  1017. },
  1018. _execute: function (statement, callback, format) {
  1019. var parameter = this.parseParameter(statement.parameter, format);
  1020. var filterList = this.parseFilter(statement.filter, parameter, format);
  1021. var obj = {
  1022. "filterList": filterList,
  1023. "parameter" : parameter
  1024. };
  1025. var value;
  1026. bind.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  1027. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  1028. function (json) {
  1029. if (callback) callback(json);
  1030. value = json;
  1031. }
  1032. );
  1033. return value;
  1034. },
  1035. parseFilter : function( filter, parameter, format ){
  1036. if( typeOf(filter) !== "array" )return [];
  1037. if( !parameter )parameter = {};
  1038. var filterList = [];
  1039. ( filter || [] ).each( function (d) {
  1040. //var parameterName = d.path.replace(/\./g, "_");
  1041. var pName = d.path.replace(/\./g, "_");
  1042. var parameterName = pName;
  1043. var suffix = 1;
  1044. while( parameter[parameterName] ){
  1045. parameterName = pName + "_" + suffix;
  1046. suffix++;
  1047. }
  1048. var value = d.value;
  1049. if( d.comparison === "like" || d.comparison === "notLike" ){
  1050. if( value.substr(0, 1) !== "%" )value = "%"+value;
  1051. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  1052. parameter[ parameterName ] = value; //"%"+value+"%";
  1053. }else{
  1054. if( ["sql", "sqlScript"].contains(format) ) {
  1055. if (d.formatType === "numberValue") {
  1056. value = parseFloat(value);
  1057. }
  1058. }else{
  1059. if (d.formatType === "dateTimeValue" || d.formatType === "datetimeValue") {
  1060. value = "{ts '" + value + "'}"
  1061. } else if (d.formatType === "dateValue") {
  1062. value = "{d '" + value + "'}"
  1063. } else if (d.formatType === "timeValue") {
  1064. value = "{t '" + value + "'}"
  1065. } else if (d.formatType === "numberValue") {
  1066. value = parseFloat(value);
  1067. }
  1068. }
  1069. parameter[ parameterName ] = value;
  1070. }
  1071. d.value = parameterName;
  1072. filterList.push( d );
  1073. });
  1074. return filterList;
  1075. },
  1076. parseParameter : function( obj, format ){
  1077. if( typeOf(obj) !== "object" )return {};
  1078. var parameter = {};
  1079. //传入的参数
  1080. for( var p in obj ){
  1081. var value = obj[p];
  1082. if( typeOf( value ) === "date" ){
  1083. if( ["sql", "sqlScript"].contains(format) ){
  1084. value = value.format("db");
  1085. }else{
  1086. value = "{ts '"+value.format("db")+"'}"
  1087. }
  1088. }
  1089. parameter[ p ] = value;
  1090. }
  1091. return parameter;
  1092. },
  1093. "select": function () {}
  1094. };
  1095. bind.view = {
  1096. "lookup": function(view, callback){
  1097. var filterList = {"filterList": (view.filter || null)};
  1098. var value;
  1099. bind.Actions.load("x_query_assemble_surface").ViewAction.executeWithQuery(view.view, view.application, filterList, function(json){
  1100. var data = {
  1101. "grid": json.data.grid || json.data.groupGrid,
  1102. "groupGrid": json.data.groupGrid
  1103. };
  1104. if (callback) callback(data);
  1105. value = data;
  1106. });
  1107. return value;
  1108. },
  1109. "select": function(view, callback, options){}
  1110. };
  1111. bind.service = {
  1112. restful: function(method, url, headers, body, connectTimeout, readTimeout){
  1113. var service = bind.java_resources.getWebservicesClient();
  1114. var bodyData = ((typeof body)==="object") ? JSON.stringify(body) : (body||"");
  1115. var res = service.restful(method, url, (headers||null), bodyData, (connectTimeout||2000), (readTimeout||300000));
  1116. var o = {
  1117. "responseCode" : res.responseCode,
  1118. "headers" : res.headers,
  1119. "body": res.body
  1120. }
  1121. try {
  1122. o.json = JSON.parse(res.body);
  1123. }catch(e){}
  1124. return o;
  1125. },
  1126. "get": function(url, headers, connectTimeout, readTimeout){
  1127. return this.restful("get", url, headers, "", connectTimeout, readTimeout);
  1128. },
  1129. "post": function(url, headers, body, connectTimeout, readTimeout){
  1130. return this.restful("post", url, headers, body, connectTimeout, readTimeout);
  1131. },
  1132. soap: function(wsdl, method, pars){
  1133. var service = bind.java_resources.getWebservicesClient();
  1134. return service.soap(wsdl, method, pars);
  1135. },
  1136. soapXml: function(wsdl, xml){
  1137. var service = bind.java_resources.getWebservicesClient();
  1138. return service.jaxwsXml(wsdl, xml);
  1139. }
  1140. }
  1141. //----------------------------------------------------------
  1142. //java对象: invoke
  1143. //java_resources: getContext(); getApplications(); getOrganization(); getWebservicesClient(); ok
  1144. //java_effectivePerson ;
  1145. //java_customResponse
  1146. //java_requestText;
  1147. //java_request
  1148. //agent
  1149. //java_resources: getContext(); getApplications(); getOrganization(); getWebservicesClient(); ok
  1150. //JPQL
  1151. //java_resources: getContext(); getApplications(); getOrganization(); getWebservicesClient(); ok
  1152. //java_effectivePerson ;
  1153. //java_parameters;
  1154. //接口响应对象
  1155. /**
  1156. * 用于服务管理的接口脚本,描述服务的响应对象。<br>
  1157. * @o2range 服务管理-接口
  1158. * @o2cn 服务的响应对象
  1159. * @module server.service.response
  1160. * @o2category server.service
  1161. * @o2ordernumber 245
  1162. * @o2syntax
  1163. * var res = this.response;
  1164. */
  1165. var response = {
  1166. /**
  1167. * @summary 服务返回一个303跳转。
  1168. * @method seeOther
  1169. * @methodOf service.service.module:response
  1170. * @static
  1171. * @param {String} [url] 跳转的url。
  1172. * @o2syntax
  1173. * this.response.seeOther(url);
  1174. */
  1175. seeOther: function(url){
  1176. bind.java_customResponse.seeOther(url);
  1177. },
  1178. /**
  1179. * @summary 服务返回一个301跳转。
  1180. * @method redirect
  1181. * @methodOf service.service.module:response
  1182. * @static
  1183. * @param {String} [url] 跳转的url。
  1184. * @o2syntax
  1185. * this.response.redirect(url);
  1186. */
  1187. redirect: function(url){
  1188. bind.java_customResponse.temporaryRedirect(url);
  1189. },
  1190. /**
  1191. * @summary 服务返回一个301跳转。
  1192. * @method setBody
  1193. * @methodOf service.service.module:response
  1194. * @static
  1195. * @param {String|Object} [body] 响应内容,文本或json对象。
  1196. * @param {String} [contentType] 响应头的Content-Type。
  1197. * @o2syntax
  1198. * this.response.setBody(body, contentType);
  1199. * @example
  1200. * //设置json格式的响应内容
  1201. * this.response.setBody({
  1202. * "key1": "value1",
  1203. * "key2": "value2"
  1204. * }, "application/json");
  1205. */
  1206. setBody: function(body, contentType){
  1207. var o = body;
  1208. if (typeOf(o)==="object"){
  1209. o = JSON.stringify(o);
  1210. }
  1211. bind.java_customResponse.setBody(o, contentType || "");
  1212. }
  1213. }
  1214. library.defineProperties(response, {
  1215. "customResponse": {
  1216. "configurable": true,
  1217. "get": function(){ return bind.java_customResponse || null }
  1218. }
  1219. });
  1220. function _get(key, java_data){
  1221. if (!bind["o"+key]) bind["o"+key] = JSON.parse(java_data);
  1222. return bind["o"+key];
  1223. }
  1224. var o= {
  1225. "entityManager": { "configurable": true, "get": function(){return null;} },
  1226. "context": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getContext() : null)} },
  1227. "applications": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getApplications() : null)} },
  1228. "organization": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getOrganization() : null)} },
  1229. //"service": { "configurable": true, "get": function(){return ((bind.java_resources) ? bind.java_resources.getWebservicesClient() : null)} },
  1230. /**
  1231. * 获取当前用户的全称。
  1232. * @module server.currentPerson
  1233. * @o2cn 当前用户全称
  1234. * @o2category server.common
  1235. * @o2ordernumber 250
  1236. * @o2syntax
  1237. * var user = this.currentPerson;
  1238. */
  1239. "currentPerson": { "configurable": true, "get": function(){return (bind.java_effectivePerson || null)} },
  1240. "effectivePerson": { "configurable": true, "get": function(){return (bind.java_effectivePerson || null)} },
  1241. /**
  1242. * 用于数据中心查询语句的脚本中,可获取语句参数。json对象,在调用此语句的时候传入<br>
  1243. * @o2range 数据中心-查询配置-通过脚本创建查询语句
  1244. * @o2cn 数据中心查询语句参数
  1245. * @module server.service.parameters
  1246. * @o2category server.service
  1247. * @o2ordernumber 255
  1248. * @o2syntax
  1249. * var pars = this.parameters;
  1250. * @example
  1251. * <caption>
  1252. * 通过this.statement.execute调用一个名为“task”的查询配置,并传入parameters,代码如下:
  1253. * <pre><code class='language-js'>//用一个名为“task”的查询配置,并传入parameters
  1254. * this.statement.execute({
  1255. * "name": "task",
  1256. * "mode" : "all",
  1257. * "parameter" : {
  1258. * "person" : "xxx@xxx@p", //传入人员参数
  1259. * "startTime" : (new Date("2020-01-01")) //传入时间参数
  1260. * }
  1261. * }, function(json){
  1262. * var count = json.count; //总数语句执行后返回的数字
  1263. * var list = json.data; //查询语句后返回的数组
  1264. * //......
  1265. * });
  1266. * </code></pre>
  1267. *
  1268. * 在task查询配置的脚本中,parameters对象就可获取到执行查询时传入的parameters对象,以便于动态创建查询语句
  1269. * </caption>
  1270. * //动态生成查询指定用户,在指定时间之后的所有待办数据
  1271. * var user = this.parameters.person;
  1272. * var startTime = (new Date(this.parameters.startTime)).format("db"); //格式化为yyyy-mm-dd hh:mm:ss
  1273. * return "SELECT o FROM Task o WHERE o.person='"+user+"' AND o.startTime>{ts '"+startTime+"'}"
  1274. */
  1275. "parameters": { "configurable": true, "get": function(){return ((bind.java_parameters) ? _get("parameters", bind.java_parameters) : null)} },
  1276. /**
  1277. * 调用接口时传入的请求消息体的文本内容。
  1278. * @o2range 服务管理-接口
  1279. * @module server.requestText
  1280. * @o2cn 传入的服务消息体文本
  1281. * @o2category server.service
  1282. * @o2ordernumber 250
  1283. * @o2syntax
  1284. * var text = this.requestText;
  1285. * @example
  1286. * var text = this.requestText; //传入的服务消息体文本
  1287. * var object = JSON.parse(text); //转成对象
  1288. */
  1289. "requestText": { "configurable": true, "get": function(){return bind.java_requestText || null; } },
  1290. "request": { "configurable": true, "get": function(){return bind.java_request || null; } },
  1291. "resources": { "configurable": true, "get": function(){return (bind.java_resources || null)} },
  1292. "customResponse": { "configurable": true, "get": function(){return (bind.java_customResponse || null)} },
  1293. "message": { "configurable": true, "get": function(){return (bind.java_message) ? _get("message", bind.java_message) : null;} }
  1294. }
  1295. library.defineProperties(bind, o);
  1296. /* 清除 engine */
  1297. this.engine = null;